将带有额外数字的时间列转换为全职列,为小时:分钟:SECS
我正在研究时间序列数据框架。DF如下:
0 2019-01-01 Contact Tuesday False January 04:00:00.118000 1
1 2019-01-01 Contact Tuesday False January 04:00:00.483000 1
2 2019-01-01 Contact Tuesday False January 08:00:00.162000 1
3 2019-01-01 Contact Tuesday False January 08:00:00.426000 1
4 2019-01-01 Contact Tuesday False January 08:00:00.564000 1
要获得此DF,我在上方进行了其他转换,因此这不是直接负载。 因此,我试图用04:00:00.118000
将第二列转换为04:00:00
。 实现这一目标的最快方法是什么?
I am working on a time series data frame.The df is as follows:
0 2019-01-01 Contact Tuesday False January 04:00:00.118000 1
1 2019-01-01 Contact Tuesday False January 04:00:00.483000 1
2 2019-01-01 Contact Tuesday False January 08:00:00.162000 1
3 2019-01-01 Contact Tuesday False January 08:00:00.426000 1
4 2019-01-01 Contact Tuesday False January 08:00:00.564000 1
To get this df I have done other transformation above hence, this is not a direct load.
so I am trying to convert the second last column with 04:00:00.118000
to 04:00:00
.
What is the quickest way to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的第二列中的条目是类型
dateTime.Time
,则可以使用以下内容:其中
name
是第二列到最后一列的名称。如果它们是类型str
,则可以使用此方法:If your entries in the second to last column are of type
datetime.time
, you could use the following:where
name
is the name of your second to last column. If they are of typestr
, then you could use this instead:,则应该起作用
尝试一下,如果您有对象类型数据
。
Try this, if you have the Object type data then it should work..
Sample data mimicking the data ..
Solution