Resample hourly TimeSeries with certain starting hour

后端 未结 2 1286
日久生厌
日久生厌 2020-12-01 12:25

I want to resample a TimeSeries in daily (exactly 24 hours) frequence starting at a certain hour.

Like:

index = date_range(datetime(2012,1,1,17), fre         


        
相关标签:
2条回答
  • 2020-12-01 13:20

    2020 Update: for dataframes

    Use the base keyword as referred in the doc:

    Code example:

    df.resample(pd.Timedelta('24 hours'), # or '24H'
     base=17 # <--  ADD THIS
    ).sum() 
    
    0 讨论(0)
  • 2020-12-01 13:31

    Resample has an base argument which covers this case:

    ts.resample(rule='24H', closed='left', label='left', base=17).sum()
    

    Output:

    2012-01-01 17:00:00    24
    2012-01-02 17:00:00    24
    2012-01-03 17:00:00    12
    Freq: 24H
    
    0 讨论(0)
提交回复
热议问题