- Data reading, specifying time as the index, and converting time to standard format
import pandas as pd
data=pd.read_csv('data.csv',index_col=0,parse_dates=True)
Analysis of sequence changes
- View the interpolation of the previous day
data.diff()
- Average difference
data.diff().mean()
- Growth rate
data.pct_change().round(3)
- Average growth rate
data.pct_change().mean()
Time series resampling
- Weekly basis
data.resample('1w').last()
- Weekly basis, specifying labels
data.resample('1w',label='left').last()
- Time window
Short-term average calculation