- Read data, specify time as the index, and convert time to standard format.
import pandas as pd
data=pd.read_csv('data.csv',index_col=0,parse_dates=True)
Analysis of sequence variations
- 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
- By week.
data.resample('1w').last()
- By week, specify labels.
data.resample('1w',label='left').last()
- Time window.
Short-term average calculation.