When creating a Pandas DataFrame with None values, they are converted to NaN:
> df = pd.DataFrame({'a': [0, None, 2]})
> df
a
0 0.0
1 NaN
2 2.0
Same thing if I set a value to None by index:
> df = pd.DataFrame({'a': [0, 1, 2]})
> df["a"].iloc[1] = None
> df
a
0 0.0
1 NaN
2 2.0
However, if I do a replace, weird things start happening:
> df = pd.DataFrame({'a': [0, 1, 2, 3]})
> df["a"].replace(1, "foo")
a
0 0
1 'foo'
2 2
3 3
> df["a"].replace(2, None)
a
0 0
1 1
2 1
3 3
What is going on here?
df["a"].replace({1:None})