I have the following two DataFrames:
>>> history
above below
asn country
12345 US 5 4
MX 6 3
54321 MX 4 5
>>> current
above below
asn country
12345 MX 1 0
54321 MX 0 1
US 1 0
I save the counter "above" and "below" in the historyDataFrame like this:
>>> history = history.add(current, fill_value=0)
>>> history
above below
asn country
12345 MX 7.0 3.0
US 5.0 4.0
54321 MX 4.0 6.0
US 1.0 0.0
This works as long as currentthere are no extra columns in the DataFrame. However, when I add an extra column:
>>> current
above below cruft
asn country
12345 MX 1 0 999
54321 MX 0 1 999
US 1 0 999
I get the following:
>>> history = history.add(current, fill_value=0)
>>> history
above below cruft
asn country
12345 MX 7.0 3.0 999.0
US 5.0 4.0 NaN
54321 MX 4.0 6.0 999.0
US 1.0 0.0 999.0
I want this extra column to be ignored, as it is not present in both DataFrames. Desired Result:
>>> history
above below
asn country
12345 MX 7.0 3.0
US 5.0 4.0
54321 MX 4.0 6.0
US 1.0 0.0
source
share