【问题标题】:Getting time duration between list of dates in Python获取Python中日期列表之间的持续时间
【发布时间】:2018-05-24 02:06:46
【问题描述】:

我有一个 csv 文件,其中包含很长的开始日期和结束日期列表,格式为 YYYYMMDD,即 20170516、20170430 .. 我必须找到start_datesell_date 之间的持续时间,它们最初是字符串格式的。 我必须添加这些日期之间的天数列。以下是我尝试过的。

import pandas as pd
import numpy as np
from datetime import datetime
from datetime import date

data = pd.read_csv('data/train.csv')

data['start_date'] = map(lambda t:datetime.strptime(t,'%Y%M%d'), data.start_date.values)
data['sell_date'] = map(lambda t:datetime.strptime(t,'%Y%M%d'), data.sell_date.values)
data['duration'] = data.sell_date.values - data.start_date.values

但这会产生以下错误

TypeError: unsupported operand type(s) for -: 'map' and 'map'

【问题讨论】:

    标签: python python-3.x pandas


    【解决方案1】:

    您的问题实际上非常困难和有趣。它需要复杂的计算,很抱歉。没有可用的 api 或库。然而,使用图像来完成这项任务是非常困难的。您应该使用另一种方法,例如距离传感器等

    如果你真的很想用图像来完成这个任务。 在我看来,我应该按如下方式实施

    1. Make a method to calculate real distance (in metrics) from image
    2. Take sequence of images, at least 30fps
    3. for each image detect the car
       if it is exist go to 4
       if it is not exist, repeat 3
    4. calculate the distance
    

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2020-02-11
      • 1970-01-01
      • 2021-08-03
      • 1970-01-01
      • 1970-01-01
      • 2018-11-23
      • 2023-03-25
      • 1970-01-01
      相关资源
      最近更新 更多