Replace '-' but not negative numbers in pandas

Solution 1:

The problem should have been addressed at the time of loading the file into the DataFrame (by providing the na_values parameter to read_csv() or whatever function you used).

At this point, use operation replace(): it replaces whole words, not individual characters.

df = df.replace("-", np.nan)