pandas 重新采样 [英] Pandas resample
问题描述
我有一些以下形式的不规则标记的时间序列数据,
I have some irregularly stamped time series data of the following form,
Time Pressure Humidity Temperature
2014-02-13 09:15:00.355000 124.283173 26.926562 6119.075
2014-02-13 09:15:00.356000 118.537935 22.228906 6111.625
2014-02-13 09:15:00.357000 118.537935 22.228906 6111.625
2014-02-13 09:15:00.359000 105.237890 10.919141 6104.625
2014-02-13 09:15:00.360000 105.237890 9.773438 6104.625...
2014-02-13 09:15:00.4530000 101.237890 7.773438 6101.625
2014-02-13 09:15:00.4590000 101.237890 7.773438 6101.625
我正在尝试将 Pandas 中的数据重新采样为常规的 100 毫秒或 S 频率.我希望这会奏效
I am trying to resample the data in pandas, to a regular 100 milliS or a S frequency. I expected this to work
x = ts.resample('100L', how='ffill')
x = ts.resample('100L', how='ffill')
那没有做任何事情,实际上它只是给了我相同的系列.然后我尝试了
That did not do anything, in fact it just gave me the same series back. Then I tried
x = ts.asfreq('100L', method = 'ffill') 似乎有效.难道我做错了什么?resample 不打算在这里使用吗?
x = ts.asfreq('100L', method = 'ffill') which seems to work. Am I doing something wrong? Is resample not meant to be used here?
在这里,我希望将采样降低到 100 毫秒的分辨率,因此我的目标输出是
Here I am looking to downsample to a 100 millisecond resolution, so my target output is
2014-02-13 09:15:00.355000 124.283173 26.926562 6119.075
2014-02-13 09:15:00.455000 101.237890 7.773438 6101.625
推荐答案
使用
x = ts.resample('100L', method='ffill')
代替
x = ts.resample('100L', how='ffill')
这篇关于 pandas 重新采样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!