I have a pandas data frame column where I have float values and string type NA value. I need to replace these NAs with the mean using the following code.
trainTestJoin["col1"] = trainTestJoin.groupby("col2")["col1"].
transform(lambda x: x.fillna(x.median()))
I am getting
TypeError: could not convert string to float: NA
I tried to convert to before filling it.
trainTestJoin["LotFrontage"].astype(float)
But it gives the same issue. How to solve this issue?