pandas get data from upper row 1

pandas get data from upper row

df.shift(1)

Here is what the above code is Doing:
1. We’re creating a new column called ‘lag_1’ in our dataframe.
2. We’re using the shift() function to shift the values in the ‘Close’ column down by 1.
3. We’re using the shift() function to shift the values in the ‘Volume’ column down by 1.
4. We’re using the shift() function to shift the values in the ‘Open’ column down by 1.
5. We’re using the shift() function to shift the values in the ‘High’ column down by 1.
5. We’re using the shift() function to shift the values in the ‘Low’ column down by 1.

Similar Posts