Python 读取dataFrame列中的日期作为基准日以生成每小时数据
我在熊猫数据框中有一列数据,如: 日期: 我需要读取第一个值作为基准日(日期[0],即1960-01-01),以便在下面的函数中使用:Python 读取dataFrame列中的日期作为基准日以生成每小时数据,python,pandas,Python,Pandas,我在熊猫数据框中有一列数据,如: 日期: 我需要读取第一个值作为基准日(日期[0],即1960-01-01),以便在下面的函数中使用: Base = Date[0] arr = numpy.array( [base + datetime.timedelta(hours=i) for i in range(len(daily)] ) 错误: ufunc add cannot use operands with types dtype('<M8[ns]') and dtype('O')
Base = Date[0]
arr = numpy.array( [base + datetime.timedelta(hours=i) for i in range(len(daily)] )
错误:
ufunc add cannot use operands with types dtype('<M8[ns]') and dtype('O')
ufunc add无法使用类型为dtype(“替换此Python对象:
datetime.timedelta(hours=i)
与NumPy等效:
np.timedelta64(i, 'h')
“我不断出错。”什么错误?!我添加了错误:
np.timedelta64(i, 'h')