0

I have 2 dataframe : code_ifc and demo_df

I would like to create demo_ER_df that contains all rows from

demo_df that does not contain all rows from `code_ifc` dataframe .

I try with this code , but i found that it does not delete rows from code_ifc.

Any idea please ? thanks

# NB: DSS supports several kinds of APIs for reading and writing data. Please see doc.

demo_ER_df =demo_df[(~demo_df['EXTERNAL_PARTNER_CODE'].isin(ifc_df['code_ifc']))]
butter
  • 73
  • 1
  • 7
  • 3
    Welcome to Stackoverflow. Please include a small sample of both the dataframes `code_ifc` and `demo_df` along with your `expected output` in text format . Also please take some time to read [`how-to-make-good-reproducible-pandas-examples`](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – Shubham Sharma Mar 14 '21 at 11:24

1 Answers1

0

Suppose that df1 is

   V1      V2      V3
0  aaa     34      67
1  aaa     34    4545
2  bbb     23  342344
3  bbb     56     776
4  ccc    878     754
5  ccc    454      66
6  ddd  78768      46
7  ddd     56     646

and

df2 is

   V1      V2   V3
0  aaa     34   67
1  ddd  78768   46
2  ddd     56  646

Then df1 without the rows from df2 is given by

df =pd.merge(df1,df2, indicator=True, how='outer').query('_merge=="left_only"').drop('_merge', axis=1)

which is

 V1    V2      V3
1  aaa   34    4545
2  bbb   23  342344
3  bbb   56     776
4  ccc  878     754
5  ccc  454      66