Skip to content

Commit a7e412c

Browse files
paulPaul Behrisch
authored andcommitted
fix doctests for pandas/core/base.py
1 parent 6a6a1ba commit a7e412c

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
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 & 11 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,9 +567,8 @@ 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
"""
572-
raise AbstractMethodError(self)
573572

574573
def to_numpy(
575574
self,
@@ -1076,15 +1075,15 @@ def value_counts(
10761075
10771076
>>> df.dtypes
10781077
a category
1079-
b object
1078+
b str
10801079
c category
10811080
d category
10821081
dtype: object
10831082
10841083
>>> df.dtypes.value_counts()
10851084
category 2
10861085
category 1
1087-
object 1
1086+
str 1
10881087
Name: count, dtype: int64
10891088
"""
10901089
return algorithms.value_counts_internal(
@@ -1386,7 +1385,7 @@ def factorize(
13861385
... )
13871386
>>> ser
13881387
['apple', 'bread', 'bread', 'cheese', 'milk']
1389-
Categories (4, object): ['apple' < 'bread' < 'cheese' < 'milk']
1388+
Categories (4, str): [apple < bread < cheese < milk]
13901389
13911390
>>> ser.searchsorted('bread')
13921391
np.int64(1)

0 commit comments

Comments
 (0)