Reputation: 153
I am trying to drop rows in the month of December, January, and February.
Note: I set the date as index.
df.drop(df.loc[(df.index.month==12) | (df.index.month==1) | (df.index.month==2)])
Upvotes: 3
Views: 3658
Reputation: 402333
You can use Series.isin
:
# Boolean indexing.
# df = df.loc[~df.index.month.isin([12, 1, 2]), :] # For a copy.
df = df[~df.index.month.isin([12, 1, 2])]
# Equivalent code using df.drop.
df = df.drop(df.index[df.index.month.isin([12, 1, 2])])
Upvotes: 4