Skip to content

Commit d6b7d5c

Browse files
authored
DOC: Add notes to nullable types documentation about pd.NA column type (#58163)
1 parent d969dd8 commit d6b7d5c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

doc/source/user_guide/boolean.rst

+13
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ If you would prefer to keep the ``NA`` values you can manually fill them with ``
3737
3838
s[mask.fillna(True)]
3939
40+
If you create a column of ``NA`` values (for example to fill them later)
41+
with ``df['new_col'] = pd.NA``, the ``dtype`` would be set to ``object`` in the
42+
new column. The performance on this column will be worse than with
43+
the appropriate type. It's better to use
44+
``df['new_col'] = pd.Series(pd.NA, dtype="boolean")``
45+
(or another ``dtype`` that supports ``NA``).
46+
47+
.. ipython:: python
48+
49+
df = pd.DataFrame()
50+
df['objects'] = pd.NA
51+
df.dtypes
52+
4053
.. _boolean.kleene:
4154

4255
Kleene logical operations

doc/source/user_guide/integer_na.rst

+13
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ with the dtype.
8484
In the future, we may provide an option for :class:`Series` to infer a
8585
nullable-integer dtype.
8686

87+
If you create a column of ``NA`` values (for example to fill them later)
88+
with ``df['new_col'] = pd.NA``, the ``dtype`` would be set to ``object`` in the
89+
new column. The performance on this column will be worse than with
90+
the appropriate type. It's better to use
91+
``df['new_col'] = pd.Series(pd.NA, dtype="Int64")``
92+
(or another ``dtype`` that supports ``NA``).
93+
94+
.. ipython:: python
95+
96+
df = pd.DataFrame()
97+
df['objects'] = pd.NA
98+
df.dtypes
99+
87100
Operations
88101
----------
89102

0 commit comments

Comments
 (0)