I have a pandas data frame (df1) with a column that has some 'NaN' values that I want to replace with the values that I have in another data frame (df2).
This is a part of the data frame (df1) with NaN that has to be mapped:
reporting_date_id filing_date_id
19910930 NaN
19920930 NaN
This is the dataframe (df2) that I want to use to map, it's a bit tricky cause they have the same column name
reporting_date_id filing_date_id
19910930 19911118
19920930 19921116
19930930 19931122
I was trying to do it in this way but it doesn't seems to work
for n in range(len(df1)):
if df1['filing_date_id'].isna().loc[n]==True:
fix_date=df2[df2['reporting_date_id']==df1['reporting_date_id'].loc[n]]['filing_date_id']
df1['filing_date_id'].loc[n]=fix_date