我有以下格式的 Excel 表格:
我想使用pandas模块使用 Python 读取此表并计算发布日期和当前日期之间的差异。这是我当前的代码:
import pandas as pd
import datetime as dt
def abc():
a=pd.read_excel('date time.xlsx')
b=dt.date.today()
print(b)
c=(a['date of issue'])
h=(c[0])
f=dt.datetime(h)
d=b-f
print(d)
abc()
Run Code Online (Sandbox Code Playgroud)
它在第 7 行 ( f=dt.datetime(h)) 中显示错误。它读TypeError: an integer is required (got type Timestamp)。