【发布时间】:2017-06-23 18:38:28
【问题描述】:
我想将 5 分钟的间隔整合为 1 小时。有没有办法在熊猫本身中做到这一点?类似于如何使用重新采样来缩小和平均?我想使用 5 分钟的数据缩小并返回每 1 小时的积分。
import pandas as pd
np.random.seed(1234)
df = pd.DataFrame(np.random.rand(300,4), columns=list('ABCD'), index=pd.date_range('2017-01-01 09:00:00', periods=300, freq='5min'))
df=df.resample('1h').mean() #can as similar method be used to find the numerical integral (eg. with trapezoidal rule)?
【问题讨论】: