Hopefully, you don't mind me posting a question here instead of the regular stack exchange forum. I'm learning ML basics and practising pandas.
assuming the data frame is called df, column name = column name
Suppose I want to replace some 'dirty' values in the column 'column name'. There are "not known" values in this column that mean nothing so i would like to replace them with the mode.
0 dog dtype: object
this code below replaces the "not known" values as NaN rather than the mode.
df.loc[df.index[df['columnname'] == "not known"].tolist(),'columnname'] = df['columnname'].mode()
what am i missing? or how should i fix the code?