import pandas as pd
# If necessary, the date to be converted in the datetime column df
df.date = pd.to_datetime(df.date,format="%Y%m%d")
# Will be diverted out a good date format, set the index df
df.set_index('date',drop=True)
# Year to provide data (because the index is already a datetime, can be directly [] row fetching content)
df['2018']
df['2018':'2021']
# Monthly to mention data
df['2018-01']
df['2018-01':'2018-05']
Data presented by # days
df['2018-05-24':'2018-09-27']
# Summary data by date
# The data begins with the first day of the week W, M month, Q quarter, QS quarter, A Year, 10A decade, 10AS years of the date of the first day of the polymerization. The polymerized form
df.resample('W').sum()
df.resample('M').sum()
# Polymerization of specific data for a column
df.price.resample ( 'W'). sum (). fillna (0) # weeks polymerized to fill NaN values 0
# A two
df[['price','num']].resample('W').sum().fillna(0)
# Certain period of time, to W polymerization,
df["2018-5":"2018-9"].resample("M").sum().fillna(0)