Combining Data with .combine_first()
Welcome to **Day 121**. Today we learn the "Smart Patch" method.
The Scenario
You have a `main_df` with some missing emails. You also have a `backup_df` that has some of those emails. You want to "Fill in the blanks" without overwriting the good data you already have.
The Solution: .combine_first()
This is essentially `COALESCE` for entire tables.
# Fills holes in main_df with data from backup_df
final_df = main_df.combine_first(backup_df)
How it works
It looks at the Index. If a value is `NaN` in the first table, it looks at the same row/column in the second table. If it's not `NaN` there, it patches it in.
Use Case: Synchronization
This is very common when you are merging data from two different systems (e.g., Salesforce and Shopify) and neither one is "Perfect."
Your Task for Today
Create two small DataFrames with different `NaN` values and use `.combine_first` to merge them into one complete set.
*Day 122: Vectorized Operations (Speed Secrets).*