Rolling Average in Pandas
问题 I have a dataframe with 2 columns - Date and Price. The data is sorted with newest date first (23 Jan in first row, 22 Jan in second row and so on). Date Price 23 Jan 100 22 Jan 95 21 Jan 90 . . . I want to calculate 2 days rolling average price for this time series data. I am using this: df.rolling(2).mean() What this does is, it assigns NaN to the first row (23 Jan) and then for the second row gives the output as the mean of prices on 23 Jan and 22 Jan. This is not useful as 22 Jan average