数据帧和数据
我有一个正在使用的数据集,我正在尝试更改时间列的格式。当前格式以这样的方式读取,例如:“ 2022-05-23 23:06:58”,我正在尝试更改此操作以显示我的时间并删除日期。
其他信息:我想在我的数据框架内进行此更改,而不仅仅是随机时间。我想更改超过100,000行,因此我需要一个功能或解决方案来这样做。整洁,橄榄酸,格式等。谢谢你们。
编辑:有一件事我可能没有充分阐明,我想保留确切的时间,什么也没有。因此,'23:48:07将是我寻找它的方式,而不仅仅是我们的方式。我需要它,以便最终可以减去两列之间的时间。你得到我吗?
I have a dataset that I’m working with and I’m trying to change the format of my time column. The current format reads like this, example: “2022-05-23 23:06:58”, I’m trying to change this to only show me the hour times and erase the dates.
Other info: I want to make this change within my data frame, not just random times. I want to change over 100,000 rows so I need a function or solution that will do so. Tidyverse, Lubridate, Format, etc. Thank you guys.
Edit: There was one thing I may not have articulated fully, I wanted to keep the exact time and nothing else. so ‘23:48:07 would’ be how I’m looking for it not just the our. I need it so I can eventually subtract the time passed between two columns. You get me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试一下
对于这里的第一个问题是要转换为一天小时的代码,
因为您想在大型数据集上申请,我们在下面使用该代码
,其中大_df是您的大型数据集,价值超过100,000个记录
突变将为结果打开另一列,该列被命名为“小时”列
DateTime是您的大_DF数据集中的DateTime列
Try this
for the first question here is the code to convert to the hour of the day
Since you want to apply on a large dataset we use this below
where the large_df is your large dataset worth over 100,000 records
The mutate will open another column for the result which is named the Hour column
and the Datetime is the DateTime column in your large_df dataset
是字符串的时间吗?原因然后您可以使用
substr
像这样提取小时和分钟:Just
Time
使用100.000行时间列Is the time as a string ok? Cause then you can use
substr
to extract the hour and minutes like so:Just
time
with your 100.000 row time column