Reputation: 187
i have in df 2 column - DATE_G, RES.
df['DATE_G'] = pd.to_datetime(df['DATE_G'], format='%Y.%m.%d')
condition_11 = df['RES'] = 1
condition_12 = df['RES'] = 0
And I need 1) filter df on conditions 11 and 12. 2) find the maximum of the date column 3) subtract 1 day from the maximum
startdate = df['DATE_G'].max().where(condition_11 & condition_12) - 1
But I have:
AttributeError: 'Timestamp' object has no attribute 'where'
Upvotes: 0
Views: 66
Reputation: 654
.max()
is returning the maximum value value, not a pd.Series which you can perform .where()
on:
startdate = df.loc[df['DATE_G'] == df['DATE_G'].max()].where(condition_11 & condition_12)
final_startdate = startdate['DATE_G'] - pd.DateOffset(1)
Upvotes: 1