0

I have three dataframes.

d1 - new data

 A;B;C A
 BC KG;8530;8604269 
 ABC KG;8530;8604290 
 ABC KG;8530;8604291

d2 is history data.

A;B;C 
ABC KG;8530;8604269 
ABC KG;8530;8604290 
Firm KG;8530;8604267 
Firm KG;8530;8604268

d3 changes

ABC KG;8530;8604291

If I have some rows in d1 which do not exist in d2 then changes in d3 will be the rows only from d1.

After compare I want to write d3 changes in file and then add d3 changes in d2 History.

After first run I will have in

d3 changes

ABC KG;8530;8604291

then d3 add to d2

After second run I will have in d3 changes NULL

Because ABC KG;8530;8604291 exists in d2

how to solve this problem?

David Buck
  • 3,752
  • 35
  • 31
  • 35
user1862965
  • 327
  • 3
  • 15
  • Have you tried anything so far? If so can you post [your code](https://stackoverflow.com/help/minimal-reproducible-example)? – David Buck Nov 26 '19 at 13:58
  • not 100% following your logic, you want to - replace data in d1 if it exists in d2 with data from d3? – Umar.H Nov 26 '19 at 14:43
  • please find the given link it matches your issue. https://stackoverflow.com/questions/48647534/python-pandas-find-difference-between-two-data-frames – Nandan Rana Nov 26 '19 at 14:47
  • Hi, i tried this:https://www.pybloggers.com/2019/01/quick-tip-comparing-two-pandas-dataframes-and-getting-the-differences/ and also this https://stackoverflow.com/questions/20225110/comparing-two-dataframes-and-getting-the-differences/59050461#59050461 – user1862965 Nov 27 '19 at 13:02
  • I want to scrape data and store into d1. d2 is my history dataframe. I want to check, does the data (rows) from d1 exist in d2 (history data) if No do nothing. If some or all rows from d1 not exist in d2 then this rows are new data(changed data) and this data i would like to write to d3 for next steps, and also new data (raws) add to d2 in history dataframe. – user1862965 Nov 28 '19 at 07:53

0 Answers0