I have a dataframe (df) in Python with a few features but I'm going to work with Age and Age_Mean columns.
In Age column, there are several null values. I would like to replace those null values with the same index from Age_Mean column.
Here is the code I used:
for i in df:
if df['Age'].isnull().iloc[i] == True:
df['Age'].iloc[i] == df['Age_Mean'].iloc[i]
This is my error message:
KeyError: 'the label [Age] is not in the [index]'
Please let me know what is wrong with this code.
KeyError: 'the label [Age] is not in the [index]'df['Age'].fillna(df['Age_Mean'])?