Drop specific date in dataframe

To achieve this, you can use the isin() functionality in python.

df = df[~df['date'].isin(dates_list)]

This will basically remove all the rows where the 'date' column contains a value which is in dates_list.


When using drop you're supposed to target an index or a column label. So either set your column to index and drop it:

df.set_index('year').drop(dates_list)

Or loc what you want directly:

df.loc[~df.year.isin(dates_list)]