Pandas timeseries resampling and interpolating together

前端 未结 1 1055
夕颜
夕颜 2021-01-06 06:52

I have timestamped sensor data. Because of technical details, I get data from the sensors at approximately one minute intervals. The data may look like this:

<
相关标签:
1条回答
  • 2021-01-06 07:13
    d = df.set_index('tstamp')
    t = d.index
    r = pd.date_range(t.min().date(), periods=24*60, freq='T')
    
    d.reindex(t.union(r)).interpolate('index').ix[r]
    


    Note, periods=24*60 works on daily data, not on the sample provided in the question. For that sample, periods=6 will work.

    0 讨论(0)
提交回复
热议问题