[英]pandas dataFrame with datetime64[ns] as Index with microsecond precision
I have a pandas dataFrame
with datetime64[ns]
as Index. 我有一个以
datetime64[ns]
作为索引的pandas dataFrame
。 Since the data is of microsecond precision, I want to copy this date to another dataFrame
with second or minute level precision so that I can easily plot/visualize it. 由于数据具有微秒级的精度,因此我想将此日期复制到具有第二或分钟级精度的另一个
dataFrame
,以便我可以轻松地绘制/可视化它。 Any idea how to do this? 任何想法如何做到这一点? Also can this be done without copying the data to another
dataFrame
? 还可以在不将数据复制到另一个
dataFrame
情况下完成此操作吗?
Name Fruit
2016-11-03 21:20:15.555222 John Apple
2016-11-03 21:20:15.555266 John Kiwi
2016-11-03 21:20:15.555292 Mary Apple
2016-11-03 21:20:16.595222 Peter Apple
2016-11-03 21:20:16.599222 Peter Orange
2016-11-03 21:20:16.655222 John Apple
2016-11-03 21:20:17.659222 John Apple
2016-11-03 21:20:17.660222 John Apple
After the Change i wan't :
Name Fruit
2016-11-03 21:20:15.555222 John Apple
2016-11-03 21:20:16.595222 Peter Apple
2016-11-03 21:20:17.659222 John Apple
尝试重新采样并使用第二个的最后一个值。
df.resample(rule='1S').last()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.