Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/core/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand All @@ -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``.
Expand Down
20 changes: 10 additions & 10 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -383,7 +383,7 @@ def ndim(self) -> int:
0 Ant
1 Bear
2 Cow
dtype: object
dtype: str
>>> s.ndim
1

Expand Down Expand Up @@ -452,9 +452,9 @@ def nbytes(self) -> int:
0 Ant
1 Bear
2 Cow
dtype: object
dtype: str
>>> s.nbytes
24
34

For Index:

Expand Down Expand Up @@ -487,7 +487,7 @@ def size(self) -> int:
0 Ant
1 Bear
2 Cow
dtype: object
dtype: str
>>> s.size
3

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -1076,15 +1076,15 @@ def value_counts(

>>> df.dtypes
a category
b object
b str
c category
d category
dtype: object

>>> df.dtypes.value_counts()
category 2
category 1
object 1
str 1
Name: count, dtype: int64
"""
return algorithms.value_counts_internal(
Expand Down Expand Up @@ -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)
Expand Down
Loading