0
orders = sales_and_orders[["orders"]]
df1 = orders.cumsum()
sales = sales_and_orders[["sales"]]
df2 = sales.cumsum()

df1 and df2 are two dataframes.

     Pens Pencils Erasers Paper
Jan   400     550      80   480
Feb   770     970     135   930
Mar  1025    1272     160  1210
Apr  1175    1497     180  1410
May  1375    1772     221  1635
Jun  1500    1942     246  1819
Jul  1550    2022     256  1919
Aug  1975    2622     346  2424
Sep  2398    3202     441  2949
Oct  2598    3427     501  3349
Nov  2703    3533     513  3552
Dec  2781    3602     528  3651
     orders                        
       Pens Pencils Erasers   Paper
Jan  1200.0  1500.0   400.0  1400.0
Feb  1200.0  1500.0   400.0  1400.0
Mar  1200.0  1500.0   400.0  1400.0
Apr  1700.0  2000.0   500.0  2000.0
May  1700.0  2000.0   500.0  2000.0
Jun  1700.0  2000.0   500.0  2000.0
Jul  2700.0  3400.0   900.0  3200.0
Aug  2700.0  3400.0   900.0  3200.0
Sep  2700.0  3400.0   900.0  3200.0
Oct  3200.0  3900.0  1000.0  3800.0
Nov  3200.0  3900.0  1000.0  3800.0
Dec  3200.0  3900.0  1000.0  3800.0

How to find the difference between these two data frames? the resulting data should be only 4 columns and 12 rows.

  • Maybe this stackoverflow section will help: https://stackoverflow.com/questions/48647534/python-pandas-find-difference-between-two-data-frames – Kylian Nov 12 '21 at 07:48

0 Answers0