简体   繁体   中英

Exclude dates based on a list from a pandas dataframe

I have a dataframe with a pd.to_datetime column df, where the column day is: df['Date'].dt.day:

Day
01.01.2020
02.01.2020
...

And I have another dataframe with a pd.to_datetime column closeddays:

Closed
01.01.2020
31.01.2020

How can I exclude every row which is on the closed list, i tried:

df = df.loc[~df['Day'].isin([closeddays['Closed']])]

which leads to an error: TypeError: 'Series' objects are mutable, thus they cannot be hashed

How can i get the outcome:

Day
02.01.2020
...

你可以试试这个——

df = df[~(df['Date'].isin(closeddays['Closed'].dt.date.tolist()))]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM