How to make two dataframe fill missing values with each other in pandas

there are two sets of data that make two dataframe, with the same row and column tags want to know how to get two dataframe to fill the missing values with each other.

Feb.27,2021

import pandas as pd

data1 = [{'a': '1', 'b': ''}, {'a': '', 'b': '2'}]
data2 = [{'a': '', 'b': '3'}, {'a': '4', 'b': ''}]

df1 = pd.DataFrame(data1)
df2 = pd.DataFrame(data2)

for i, row in df1.iterrows():
    for key in row.keys():
        if not row[key]:
            row[key] = df2.loc[i][key]

print df1
Menu