df = df.resample('60S').last()
import pandas as pd
aa =r'./data/datetime.xls'
# 设置数据显示的列数和宽度
pd.set_option('display.max_columns',500)
pd.set_option('display.width',1000)
# 解决数据输出时列名不对齐的问题
pd.set_option('display.unicode.ambiguous_as_wide', True)
pd.set_option('display.unicode.east_asian_width', True)
df = pd.DataFrame(pd.read_excel(aa))
df = df.set_index('订单付款时间') # 将date设置为index
df1 = df['金额'].resample('60S', label = 'right').sum()
df2= df['数量'].resample('60S', label = 'right').sum()
# 数据合并
df = pd.concat([df1,df2], axis = 1)
print(df)
df2.resample('AS').sum().to_period('A')
Q_df=df2.resample('Q').sum().to_period('Q')
df2.resample('M').sum().to_period('M')
df2.resample('W').sum().to_period('W').head()
import pandas as pd
aa =r'./data/TB2018.xls'
df = pd.DataFrame(pd.read_excel(aa))
df1=df[['订单付款时间','买家会员名','联系手机','买家实际支付金额']]
df1 = df1.set_index('订单付款时间') # 将date设置为index
# "MS"是每个月第一天为开始日期,"M"是每个月最后一天
df2=df1.resample('M').sum().to_period('M')
df2.to_excel('result2.xls')