Question: Let's say I have a dataframe of leads as such:

```
import pandas as pd

leads = {'Unique Identifier':['1','2','3','4','5','6','7','8'],
        'Name': ['brad','stacy','holly','mike','phil', 'chris','jane','glenn'],
        'Channel': [None,None,None,None,'facebook', 'facebook','google', 'facebook'],
        'Campaign': [None,None,None,None,'A', 'B','B', 'C'],
        'Gender': ['M','F','F','M','M', 'M','F','M'],
        'Signup Month':['Mar','Mar','Apr','May','May','May','Jun','Jun']
        }

leads_df = pd.DataFrame(leads)

leads_df

```

which looks like the following. It has missing data for Channel and Campaign for the first 4 leads.

[leads table](https://i.stack.imgur.com/zluPA.png)

I have a separate dataframe with the missing data:

```
missing = {'Unique Identifier':['1','2','3','4'],
        'Channel': ['google', 'email','facebook', 'google'],
        'Campaign': ['B', 'A','C', 'B']
        }

missing_df = pd.DataFrame(missing)

missing_df

```

[table with missing data](https://i.stack.imgur.com/tOZed.png)

Using the Unique Identifiers in both tables, how would I go about plugging in the missing data into the main leads table? For context there are about 6,000 leads with missing data.

Answer: 
You can merge the two dataframes together, update the columns using the results from the merge and then proceed to drop the merged columns.

```
data = leads_df.merge(missing_df, how='outer', on='Unique Identifier')
data['Channel'] = data['Channel_y'].fillna(data['Channel_x'])
data['Campaign'] = data['Campaign_y'].fillna(data['Campaign_x'])
data.drop(['Channel_x', 'Channel_y', 'Campaign_x', 'Campaign_y'], 1, inplace=True)

```

The result:

```
data
  Unique Identifier   Name Gender Signup Month   Channel Campaign
0                 1   brad      M          Mar    google        B
1                 2  stacy      F          Mar     email        A
2                 3  holly      F          Apr  facebook        C
3                 4   mike      M          May    google        B
4                 5   phil      M          May  facebook        A
5                 6  chris      M          May  facebook        B
6                 7   jane      F          Jun    google        B
7                 8  glenn      M          Jun  facebook        C

```
There is a pandas DataFrame method for this called [combine\_first](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.combine_first.html):

```
voltron = leads_df.combine_first(missing_df)

```