【问题标题】:Convert complex time string to datetime [duplicate]将复杂的时间字符串转换为日期时间 [重复]
【发布时间】:2020-09-03 02:09:25
【问题描述】:

尝试以下pd.to_datetime('2020-08-29 18:00:09:438') 会导致错误ValueError: ('Unknown string format:', '2020-08-29 18:00:09:438')

如何将此字符串转换为日期时间或时间戳?

【问题讨论】:

    标签: python pandas


    【解决方案1】:

    让我们传递正确的format

    pd.to_datetime('2020-08-29 18:00:09:438', format = '%Y-%m-%d %H:%M:%S:%f')
    Out[71]: Timestamp('2020-08-29 18:00:09.438000')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-16
      相关资源
      最近更新 更多