I have data on the stock market for the past 20 years. There are roughly 10 million entries. Each entry is the stock symbol, the Date, and the close price of the stock for that day. Lets say I have the stock A on Jan 1 1999. I am trying to add a column to the existing data frame that contains the close price of stock A on Jan 1 2000. However there is an issue because Jan 1 2000 is a weekend and there is no stock data for this day. The code I have instead takes the data from 2001 and pastes it into the added column. Ideally, instead of taking 2001's data, I would like the new column for the entry "A" on Jan 1 1999 to just say 'n/a'. I am not sure how to do this
The current code I have uses the shift function and the code is as follows:
df['Following Year Close Price'] = df.groupby(['Symbol'], df['Date'].dt.month, df[Date'].dt.day])['Close'].shify(-1)