rng = pd.date_range('1/1/2012', periods=100, freq='S') 返回:4s 数据 DatetimeIndex(['2012-01-01 00:00:00', '2012-01-01 00:00:01', '2012-01-01 00:00:02', '2012-01-01 00:00:03'], dtype='datetime64[ns]', freq='S') ts = pd.Series(np.random.randint(0, 500, len(rng)), index=rng) 返回: ts 2012-01-01 00:00:00 394 2012-01-01 00:00:01 186 2012-01-01 00:00:02 201 2012-01-01 00:00:03 389 Freq: S, dtype: int64 对2秒内的数据进行加和 ts.resample('2s').sum()