I used .replace() to replace the value -99 to 0 on my dataset. However, it only replaced the value -99 for the columns that were all strings meaning that the columns that contained strings still have -99 within them. I would like to replace -99 with the string ‘unknown’ for the columns that contain strings.
You should just use the replace method 2 times, one like you did to replace numeric values, the second to replace string values like this :
df.replace(-99, 0, inplace=True) df.replace('-99', 'unknown', inplace=True)