想要计算D列的平均值,有个条件是以B列中的时间为轴,每隔1min计算一次。
代码如下
import pandas as pd
df=pd.read_excel("C:/Users/Desktop/average/LAST_mac_plot12.xlsx",names=['a','b','c','d'])
print(df.head())
看一下前5行数据:
可以看到数据的索引并不是时间,现在要将索引改为b列的时间。
DF=df.set_index(df['b'])
DF.index=pd.to_datetime(DF.index,format='%H:%M:%S')
print(DF.head())
再来看一下结果: