From e4145d45b1604aae226cb2d3b420250911f11dc9 Mon Sep 17 00:00:00 2001 From: Zhengbo Wang <77875500+luke396@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:51:00 +0800 Subject: [PATCH 1/4] Add doc and codes --- doc/source/user_guide/categorical.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/source/user_guide/categorical.rst b/doc/source/user_guide/categorical.rst index 8fb991dca02db..b5640c5d83e6c 100644 --- a/doc/source/user_guide/categorical.rst +++ b/doc/source/user_guide/categorical.rst @@ -263,6 +263,18 @@ All instances of ``CategoricalDtype`` compare equal to the string ``'category'`` c1 == "category" +But notice that the ``categories_dtype`` should be considered, especially when comparing with +two empty ``CategoricalDtype`` instances: + +.. ipython:: python + import numpy as np + + c2 = pd.Categorical(np.full(2, np.nan, dtype=object)) + c3 = pd.Categorical(np.full(2, np.nan, dtype=float)) + + # Unequal, since their categories_dtype are different + c2.dtype == c3.dtype + Description ----------- From b4dd2b3968c2b116da403737989b68b7295fcdb0 Mon Sep 17 00:00:00 2001 From: Zhengbo Wang <77875500+luke396@users.noreply.github.com> Date: Tue, 6 Feb 2024 13:15:50 +0800 Subject: [PATCH 2/4] Update doc --- doc/source/user_guide/categorical.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/source/user_guide/categorical.rst b/doc/source/user_guide/categorical.rst index b5640c5d83e6c..3dc1812fd9ec4 100644 --- a/doc/source/user_guide/categorical.rst +++ b/doc/source/user_guide/categorical.rst @@ -269,10 +269,12 @@ two empty ``CategoricalDtype`` instances: .. ipython:: python import numpy as np - c2 = pd.Categorical(np.full(2, np.nan, dtype=object)) - c3 = pd.Categorical(np.full(2, np.nan, dtype=float)) + c2 = pd.Categorical(np.array([], dtype=object)) + c3 = pd.Categorical(np.array([], dtype=float)) # Unequal, since their categories_dtype are different + # c2.dtype = CategoricalDtype(categories=[], ordered=False, categories_dtype=object) + # c3.dtype = CategoricalDtype(categories=[], ordered=False, categories_dtype=float64) c2.dtype == c3.dtype Description From 69e79f7324167f6a07041d0c5486f10bcf1186fa Mon Sep 17 00:00:00 2001 From: Zhengbo Wang <77875500+luke396@users.noreply.github.com> Date: Sun, 11 Feb 2024 17:28:47 +0800 Subject: [PATCH 3/4] Update doc --- doc/source/reference/indexing.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/source/reference/indexing.rst b/doc/source/reference/indexing.rst index fa6105761df0a..659fe31affb3c 100644 --- a/doc/source/reference/indexing.rst +++ b/doc/source/reference/indexing.rst @@ -41,6 +41,7 @@ Properties Index.empty Index.T Index.memory_usage + Index.array Modifying and computations ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -110,6 +111,7 @@ Conversion Index.to_list Index.to_series Index.to_frame + Index.to_numpy Index.view Sorting From ad193ab39438a008b6809ef368818477eabeea22 Mon Sep 17 00:00:00 2001 From: Zhengbo Wang <77875500+luke396@users.noreply.github.com> Date: Sun, 11 Feb 2024 17:41:49 +0800 Subject: [PATCH 4/4] Remove careless --- doc/source/user_guide/categorical.rst | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/doc/source/user_guide/categorical.rst b/doc/source/user_guide/categorical.rst index 3dc1812fd9ec4..8fb991dca02db 100644 --- a/doc/source/user_guide/categorical.rst +++ b/doc/source/user_guide/categorical.rst @@ -263,20 +263,6 @@ All instances of ``CategoricalDtype`` compare equal to the string ``'category'`` c1 == "category" -But notice that the ``categories_dtype`` should be considered, especially when comparing with -two empty ``CategoricalDtype`` instances: - -.. ipython:: python - import numpy as np - - c2 = pd.Categorical(np.array([], dtype=object)) - c3 = pd.Categorical(np.array([], dtype=float)) - - # Unequal, since their categories_dtype are different - # c2.dtype = CategoricalDtype(categories=[], ordered=False, categories_dtype=object) - # c3.dtype = CategoricalDtype(categories=[], ordered=False, categories_dtype=float64) - c2.dtype == c3.dtype - Description -----------