Reputation: 1688
I have a Dataframe with Datetime columns:
Parcela DS1 DC1 DS0 DC0
P1 2016-04-26 2016-09-26 2016-04-11 2016-09-11
P2 2016-04-26 2016-09-26 2016-04-11 2016-09-11
I've tried to create a new column with the following code:
df['sem'] = prec[df['DS0'].dt.strftime('%Y-%m%d'):df['DS1'].dt.strftime('%Y-%m-%d')].sum()
where prec
is another dataframe with a datetime index,
Datetime prec
2016-04-13 00:00:00 0.0
2016-04-13 00:10:00 0.0
but I get the following error
Cannot convert input of type <class 'pandas.core.series.Series'> to Timestamp
Could you help me?
Upvotes: 0
Views: 27
Reputation: 323226
You may check with
df['sem'] = [prec.loc[x:y,'prec'].sum() for x , y in zip(df['DS0'].dt.strftime('%Y-%m%d'),df['DS1'].dt.strftime('%Y-%m-%d'))]
Upvotes: 1