diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index 7fc391d3ffb51..a6a6a03486800 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -751,7 +751,7 @@ def factorize( array([0, 0, 1]) >>> uniques ['a', 'c'] - Categories (3, object): ['a', 'b', 'c'] + Categories (3, str): [a, b, c] Notice that ``'b'`` is in ``uniques.categories``, despite not being present in ``cat.values``. @@ -764,7 +764,7 @@ def factorize( >>> codes array([0, 0, 1]) >>> uniques - Index(['a', 'c'], dtype='object') + Index(['a', 'c'], dtype='str') If NaN is in the values, and we want to include NaN in the uniques of the values, it can be achieved by setting ``use_na_sentinel=False``. diff --git a/pandas/core/base.py b/pandas/core/base.py index 6cc28d4e46634..a1a041f13878a 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -323,12 +323,12 @@ def transpose(self, *args, **kwargs) -> Self: 0 Ant 1 Bear 2 Cow - dtype: object + dtype: str >>> s.T 0 Ant 1 Bear 2 Cow - dtype: object + dtype: str For Index: @@ -383,7 +383,7 @@ def ndim(self) -> int: 0 Ant 1 Bear 2 Cow - dtype: object + dtype: str >>> s.ndim 1 @@ -452,9 +452,9 @@ def nbytes(self) -> int: 0 Ant 1 Bear 2 Cow - dtype: object + dtype: str >>> s.nbytes - 24 + 34 For Index: @@ -487,7 +487,7 @@ def size(self) -> int: 0 Ant 1 Bear 2 Cow - dtype: object + dtype: str >>> s.size 3 @@ -567,7 +567,7 @@ def array(self) -> ExtensionArray: >>> ser = pd.Series(pd.Categorical(["a", "b", "a"])) >>> ser.array ['a', 'b', 'a'] - Categories (2, object): ['a', 'b'] + Categories (2, str): [a, b] """ raise AbstractMethodError(self) @@ -1076,7 +1076,7 @@ def value_counts( >>> df.dtypes a category - b object + b str c category d category dtype: object @@ -1084,7 +1084,7 @@ def value_counts( >>> df.dtypes.value_counts() category 2 category 1 - object 1 + str 1 Name: count, dtype: int64 """ return algorithms.value_counts_internal( @@ -1386,7 +1386,7 @@ def factorize( ... ) >>> ser ['apple', 'bread', 'bread', 'cheese', 'milk'] - Categories (4, object): ['apple' < 'bread' < 'cheese' < 'milk'] + Categories (4, str): [apple < bread < cheese < milk] >>> ser.searchsorted('bread') np.int64(1)