4.3 Inserting missing data

You can insert missing values by simply assigning to containers. The actual missing value used will be chosen based on the dtype.

For example, numeric containers will always use NaN regardless of the missing value type chosen:

In [1]: s = pd.Series([1, 2, 3])

In [2]: s.loc[0] = None

In [3]: s
Out[3]: 
0    NaN
1    2.0
2    3.0
dtype: float64

Likewise, datetime containers will always use NaT.

For object containers, pandas will use the value given:

In [4]: s = pd.Series(["a", "b", "c"])

In [5]: s.loc[0] = None

In [6]: s.loc[1] = np.nan

In [7]: s
Out[7]: 
0    None
1     NaN
2       c
dtype: object