October 2019
Beginner to intermediate
674 pages
16h 43m
English
The union of two DataFrames occurs based on row and column indices. Let's understand this through an example. Consider two DataFrames:
ore1DF=pd.DataFrame(np.array([[20,35,25,20],[11,28,32,29]]),columns=['iron','magnesium','copper','silver'])ore2DF=pd.DataFrame(np.array([[14,34,26,26],[33,19,25,23]]),columns=['iron','magnesium','gold','silver'])
The + operator will add values in columns with the same labels in both DataFrames:
ore1DF + ore2DF
The following is the output:

The columns—copper and gold—were not found in both the DataFrames. Hence, NA has been appended in these columns.
If you combine a DataFrame object ...
Read now
Unlock full access