I have a huge dataframe in which I am filtering it on two conditions.
A reproducible toy example is as follows:
import pandas as pd
df_ = pd.DataFrame([["A",91,1], ["B",91,2], ["C",92,1]],
columns=['Name','Iteration','IP Weight'])
df2 = pd.DataFrame([["D",91,1], ["E",91,1], ["F",91,1]],
columns=['Name','Iteration','IP Weight'])
Objective
If df_
rows have the same "iteration" and "ip_weight" combination as the 1st row of df, filter that and append df, here 1st row will get removed from df_
and df2
will get appended to it.
I filtered it as follows,
df_[~((df_['Iteration']==df2['Iteration'][0]) & (df_['IP Weight']==df2['IP Weight'][0]))]
It runs fine in the notebook but when I put it in the script it fails with the message
" FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison"
Any help is highly appreciated.