【问题标题】:how Do i get the time only, no date?我如何只得到时间,没有日期?
【发布时间】:2016-10-27 17:51:49
【问题描述】:

您好,我正在使用 pandas to_datetime 转换数据框中的数据列 但我只想要时间部分(小时和分钟),在这种情况下我不想要日期。

这是我的代码:

converted_air_time = pd.to_datetime(flight_data["AirTime"], unit = "s")
print converted_air_time
Output: 0        1970-01-01 00:02:12

我只想要 00:02:12 部分

如果有人知道请帮忙谢谢

【问题讨论】:

  • 试试这个:pd.to_datetime(flight_data["AirTime"], unit = "s").dt.time

标签: python datetime pandas dataframe


【解决方案1】:
print converted_air_time.strftime('%H:%M:%S')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-30
    • 1970-01-01
    • 2018-05-09
    • 2014-09-03
    • 1970-01-01
    • 1970-01-01
    • 2020-05-01
    相关资源
    最近更新 更多