I'm completely new to Python (and this website) and am currently trying to replace NA values in specific dataframe columns with their mode. I've tried various methods which are not working. Please help me spot what I'm doing incorrectly:
Note: All the columns I'm working with are float64 types. All my codes run but when I check the null amount with df[cols_mode].isnull().sum() in the columns, it remains the same.
Method 1:
cols_mode = ['race', 'goal', 'date', 'go_out', 'career_c']
df[cols_mode].apply(lambda x: x.fillna(x.mode, inplace=True))
I tried the Imputer method too but encountered the same result
Method 2:
for column in df[['race', 'goal', 'date', 'go_out', 'career_c']]:
mode = df[column].mode()
df[column] = d