我需要将已用时间转换为总秒数。我用了三个函数,但没有成功。
第一个功能:
ny["Time Elapsed"].time()
AttributeError:“系列”对象没有属性“时间”
第二个功能:
ny["Time Elapsed"].total_seconds()
AttributeError:“Series”对象没有属性“total_seconds”
第三个功能:
ny["Time Elapsed"](int)
类型错误:“系列”对象不可调用
我正在尝试将经过时间列中的持续时间转换为秒。数据框的名称是“ny”。
出现您的问题是因为您没有使用 .dt 访问器。你应该使用:
ny['tot_s'] = ny["Time Elapsed"].dt.total_seconds()