Skip to content

Commit b09f44d

Browse files
paulpaulbehrisch
authored andcommitted
fix doctests for pandas/core/base.py
1 parent 68644ac commit b09f44d

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

pandas/core/algorithms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ def factorize(
751751
array([0, 0, 1])
752752
>>> uniques
753753
['a', 'c']
754-
Categories (3, object): ['a', 'b', 'c']
754+
Categories (3, str): [a, b, c]
755755
756756
Notice that ``'b'`` is in ``uniques.categories``, despite not being
757757
present in ``cat.values``.
@@ -764,7 +764,7 @@ def factorize(
764764
>>> codes
765765
array([0, 0, 1])
766766
>>> uniques
767-
Index(['a', 'c'], dtype='object')
767+
Index(['a', 'c'], dtype='str')
768768
769769
If NaN is in the values, and we want to include NaN in the uniques of the
770770
values, it can be achieved by setting ``use_na_sentinel=False``.

pandas/core/base.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,12 @@ def transpose(self, *args, **kwargs) -> Self:
323323
0 Ant
324324
1 Bear
325325
2 Cow
326-
dtype: object
326+
dtype: str
327327
>>> s.T
328328
0 Ant
329329
1 Bear
330330
2 Cow
331-
dtype: object
331+
dtype: str
332332
333333
For Index:
334334
@@ -383,7 +383,7 @@ def ndim(self) -> int:
383383
0 Ant
384384
1 Bear
385385
2 Cow
386-
dtype: object
386+
dtype: str
387387
>>> s.ndim
388388
1
389389
@@ -452,9 +452,9 @@ def nbytes(self) -> int:
452452
0 Ant
453453
1 Bear
454454
2 Cow
455-
dtype: object
455+
dtype: str
456456
>>> s.nbytes
457-
24
457+
34
458458
459459
For Index:
460460
@@ -487,7 +487,7 @@ def size(self) -> int:
487487
0 Ant
488488
1 Bear
489489
2 Cow
490-
dtype: object
490+
dtype: str
491491
>>> s.size
492492
3
493493
@@ -567,7 +567,7 @@ def array(self) -> ExtensionArray:
567567
>>> ser = pd.Series(pd.Categorical(["a", "b", "a"]))
568568
>>> ser.array
569569
['a', 'b', 'a']
570-
Categories (2, object): ['a', 'b']
570+
Categories (2, str): [a, b]
571571
"""
572572
raise AbstractMethodError(self)
573573

@@ -1076,15 +1076,15 @@ def value_counts(
10761076
10771077
>>> df.dtypes
10781078
a category
1079-
b object
1079+
b str
10801080
c category
10811081
d category
10821082
dtype: object
10831083
10841084
>>> df.dtypes.value_counts()
10851085
category 2
10861086
category 1
1087-
object 1
1087+
str 1
10881088
Name: count, dtype: int64
10891089
"""
10901090
return algorithms.value_counts_internal(
@@ -1386,7 +1386,7 @@ def factorize(
13861386
... )
13871387
>>> ser
13881388
['apple', 'bread', 'bread', 'cheese', 'milk']
1389-
Categories (4, object): ['apple' < 'bread' < 'cheese' < 'milk']
1389+
Categories (4, str): [apple < bread < cheese < milk]
13901390
13911391
>>> ser.searchsorted('bread')
13921392
np.int64(1)

0 commit comments

Comments
 (0)