Is there any method to replace values with None in Pandas in Python?
You can use df.replace('pre', 'post') and can replace a value with another, but this can't be done if you want to replace with None value, which if you try, you get a strange result.
So here's an example:
df = DataFrame(['-',3,2,5,1,-5,-1,'-',9])
which returns a successful result.
which returns a following result:
0 - // this isn't replaced
7 -1 // this is changed to `-1`...
Why does such a strange result be returned?
Since I want to pour this data frame into MySQL database, I can't put NaN values into any element in my data frame and instead want to put None. Surely, you can first change '-' to NaN and then convert NaN to None, but I want to know why the dataframe acts in such a terrible way.