From 2ca9ae7c9aef4083ed0a50f711398a7d7b2eeb0d Mon Sep 17 00:00:00 2001 From: Filip Razek Date: Wed, 24 Jan 2024 12:11:47 +0100 Subject: [PATCH] doc: Add notes to nullable types documentation about pd.NA column type --- doc/source/user_guide/boolean.rst | 10 ++++++++++ doc/source/user_guide/integer_na.rst | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/doc/source/user_guide/boolean.rst b/doc/source/user_guide/boolean.rst index 3c361d4de17e5..1998fb82ffd40 100644 --- a/doc/source/user_guide/boolean.rst +++ b/doc/source/user_guide/boolean.rst @@ -37,6 +37,16 @@ If you would prefer to keep the ``NA`` values you can manually fill them with `` s[mask.fillna(True)] +Note that when creating a new column with only :attr:`pandas.NA` values, +its dtype will be ``"object"``, since the value is also used for +:ref:`nullable integers `. + +.. ipython:: python + + df = pd.DataFrame() + df['objects'] = pd.NA + df.dtypes + .. _boolean.kleene: Kleene logical operations diff --git a/doc/source/user_guide/integer_na.rst b/doc/source/user_guide/integer_na.rst index 1a727cd78af09..fdff02d20facd 100644 --- a/doc/source/user_guide/integer_na.rst +++ b/doc/source/user_guide/integer_na.rst @@ -84,6 +84,16 @@ with the dtype. In the future, we may provide an option for :class:`Series` to infer a nullable-integer dtype. +Note that when creating a new column with only :attr:`pandas.NA` values, +its dtype will be ``"object"``, since the value is also used for +:ref:`booleans `. + +.. ipython:: python + + df = pd.DataFrame() + df['objects'] = pd.NA + df.dtypes + Operations ----------