Ame*_*ina 9 python numpy pandas
假设我有一个包含多个时间戳和值的数据框.我想测量? values / ?t 每一2.5秒.Pandas是否提供时间差异化的任何工具?
time_stamp values
19492 2014-10-06 17:59:40.016000-04:00 1832128
167106 2014-10-06 17:59:41.771000-04:00 2671048
202511 2014-10-06 17:59:43.001000-04:00 2019434
161457 2014-10-06 17:59:44.792000-04:00 1294051
203944 2014-10-06 17:59:48.741000-04:00 867856
Run Code Online (Sandbox Code Playgroud)
它肯定会.首先,您需要将索引转换为pandas date_range格式,然后使用可用于与该类索引的系列/数据帧的自定义偏移函数.这里有用的文档.了解更多点击这里了解抵消别名.
此代码应将您的数据重新采样为2.5秒
#df is your dataframe
index = pd.date_range(df['time_stamp'])
values = pd.Series(df.values, index=index)
#Read above link about the different Offset Aliases, S=Seconds
resampled_values = values.resample('2.5S')
resampled_values.diff() #compute the difference between each point!
Run Code Online (Sandbox Code Playgroud)
应该这样做.
| 归档时间: |
|
| 查看次数: |
6028 次 |
| 最近记录: |