python - 如何将时间戳四舍五入到最接近的秒数?
问题描述
请帮助我将此时间戳四舍五入到秒我有数据帧索引是时间戳的系列,如下所示。如何将索引四舍五入到最接近的秒数?
Timestamp('2019-06-16 07:53:32.961000')
预期结果
Timestamp('2019-06-16 07:53:33')
解决方案
pd.Timestamp('2019-06-16 07:53:32.961000').round('s')
# Timestamp('2019-06-16 07:53:33')
推荐阅读
- android - 如何完全关闭android应用程序以便回收所有内存?
- entity-framework-6 - 从 WebJob 使用 EF6 查询 SQL 时,查询失败,因为它试图获取表的复数版本
- python - pyftdi:SPI - CLK空闲状态反转(模式3)
- c++ - 如何在 C++ (UNIX) 中完全阻止用户输入
- python - Python: Initializing and filling a list of lists from another list of lists
- algorithm - 检查数组是否有重复的、幼稚的接近时间分析
- python - Confusion about scoping in python classes
- python - Commenting python lines that are code, which style to use?
- amazon-web-services - Pipeline error when deploying beanstalk application
- javascript - Cannot destructure property `user` of 'undefined' or 'null'