Combine and Update
Apply the combine and update methods for non-join DataFrame combinations.
We'll cover the following
Combining DataFrames
There are times when the JOIN operations provided by the merge()
function aren’t suitable for the non-join type combinations we want. In this lesson, we take a look at three DataFrame methods (combine_first
, combine
and update
) that allow us to perform special types of combinations.
Combine first
The combine_first()
method updates null elements of a DataFrame with the non-null value in the same location in another DataFrame. Let’s say we have two DataFrames, df_agents_a
and df_agents_b
, containing demographic information of eight real estate agents.
The difference is that the two DataFrames have missing values at different row and column indexes. This scenario could occur in the real world if varying parts of data were obtained from different sources and at different time points.
Get hands-on with 1200+ tech skills courses.