Reputation: 69
I have two data frames df_semi_sup2
and df_confident_inst_no
and I want to drop all instances existing in df_confident_inst_no
from df_semi_sup2
. I made researches about that and I found the necessary code, but it dosen't give the results that I'm waiting for.
Here is the code :
for index, row in df_confident_inst_no.iterrows() :
df_semi_sup2= df_semi_sup2.drop(df_semi_sup2.index[index])
Can anyone help me find the problem in such code ?
Thanks!
Upvotes: 0
Views: 48
Reputation: 4028
See here (works if data structure is identical which you don't tell us):
df_new = df_semi_sup2[~df_semi_sup2.isin(df_confident_inst_no)].dropna() # No need to loop
You can use dropna()'s how
parameter like so:
‘any’ : If any NA values are present, drop that row or column.
‘all’ : If all values are NA, drop that row or column.
Upvotes: 1