Now for some analysis
Let's calculate the daily returns on close_price
You could calculate the percent change for any number of days on any colums by changing the arguments to the pct_change function.
So you need to calculate the 5 day returns on Adj Close then
But you need to get back in the original dataframe. So
You would get the following output
Instead of percentage values, you need the difference value, then
Let's calculate the daily returns on close_price
Python:
df['Close'].pct_change(1)
So you need to calculate the 5 day returns on Adj Close then
Python:
df['Adj Close'].pct_change(5)
Code:
df['DailyReturn'] = df['Close'].pct_change(1)
df
Instead of percentage values, you need the difference value, then
Python:
df['Close'].diff(1)