2024-06-28 19:36:51 发布
网友
我有一个数据帧,其中一列都是时间戳,如下所示。我现在需要做的是计算每个时间戳之间的差异,然后使用这些差异绘制直方图。 我无法解释如何计算差异。任何帮助都将不胜感激
0 2020-09-16 00:00:02.713264 1 2020-09-16 00:00:02.827854 2 2020-09-16 00:00:05.919288 3 2020-09-16 00:00:05.940775 4 2020-09-16 00:00:06.682184
给定一个虚拟df
# df # timestamp # 0 2020-09-16 00:00:02.713264 # 1 2020-09-16 00:00:02.827854 # 2 2020-09-16 00:00:05.919288 # 3 2020-09-16 00:00:05.940775 # 4 2020-09-16 00:00:06.682184
你应该能够使用
ax = df['timestamp'].diff().dropna().dt.total_seconds().plot.hist() ax.set_xlabel('timedelta[s]')
…这应该会产生一个像
给定一个虚拟df
你应该能够使用
…这应该会产生一个像![enter image description here](https://i.stack.imgur.com/NXoxo.png)
相关问题 更多 >
编程相关推荐