数据集:在电脑中/和-区别不大
train=pd.read_csv(‘./1.csv‘)
train[‘q‘]= pd.to_datetime(train[‘q‘],format=‘%Y/%m/%d‘)
startdate =pd.to_datetime(‘2007-06-01‘,format=‘%Y/%m/%d‘)//这就是为什么formet可以用/分割
print(train)
输出:
train[‘q‘]=train[‘q‘]-startdate
print(startdate)
输出:
print(train)
输出:
俩者作差得出相差天数