【问题标题】:Difference between two date columns in a dataframe using python使用python的数据框中两个日期列之间的差异
【发布时间】:2020-11-13 03:01:12
【问题描述】:

我在数据框中有两列,其格式也包含日期和时间。我需要找出小时的差异。当我尝试它给出类型错误时。

错误:TypeError:-: 'str' 和 'str' 的操作数类型不受支持。

Data example:

D1: 12/26/2014 7:45
    12/31/2014 6:30
D2: 1/1/2015 2:18
    1/1/2015 2:49

需要找到 D1-D2 的差异

【问题讨论】:

标签: python dataframe


【解决方案1】:

str函数不支持,需要转成datetime格式,在python中查找datetime模块

官方文档:https://docs.python.org/3/library/datetime.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-01-15
    • 1970-01-01
    • 1970-01-01
    • 2022-11-27
    • 2011-10-29
    • 2021-10-21
    • 1970-01-01
    • 2018-10-25
    相关资源
    最近更新 更多