I have two dataframes which have separate columns in them. I want the columns which are in dataframe 1 but not in 2 to be added to dataframe 2 (filled with 0's)
I wish for the remaining columns, not in dataframe 1 to be dropped from dataframe2.
I have manually done this, but I want it to be generalised for any two dataframes. I was hoping that .columns could be used however that is only usable if the dataframes have the same width.
before
df1
a b c d
0 1 2 3
1 2 4 5
0 1 0 1
df2
a c d e
0 2 3 0
1 3 2 1
1 0 1 0
after
df2
a b c d
0 0 2 3
1 0 3 2
1 0 0 1