mercredi 9 décembre 2020

Python | How to check if a string value does not exist in another dataframe?

I have 2 dataframes to focus: df_hours and new_df

I want to check if a string value of a dataframe(df_hours) does not exist in the whole dataframe(new_df).

For e.g. df_hours has a 'Category' column with string values 'A','B','C' etc. I want to check if 'A' does not exist in new_df.

I have 2 for loops and inside it I have the following if condition:

if df_hours.iloc[i,1] == df_hours_copy.iloc[j,1] and (~df_hours.iloc[i,1].isin(new_df)):

How can I code the second part of the if (the one after the 'and')?

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire