日期和INT列的我有一個數據幀,看起來像這樣:差異大熊貓
raw_data = {'SeriesDate':['2017-03-10','2017-03-13','2017-03-14','2017-03-15'],'Test':['1','2','3','4']}
import pandas as pd
df = pd.DataFrame(raw_data,columns=['SeriesDate','Test'])
df['SeriesDate'] = pd.to_datetime(df['SeriesDate'])
我想從日期字段減去數場以日期到達,但是當我這樣做:
df['TestDate'] = df['SeriesDate'] - pd.Series((dd) for dd in df['Test'])
我得到以下類型錯誤:
TypeError: incompatible type [object] for a datetime/timedelta operation
任何想法如何,我可以解決這個?
確實在測試項目代表天或秒或數年? – plasmon360
它代表天 – sg91