Skip to content

Commit 26b24f2

Browse files
committed
Some more errors from online Doctests cleared
1 parent 9877034 commit 26b24f2

File tree

17 files changed

+55
-56
lines changed

17 files changed

+55
-56
lines changed

pandas/core/algorithms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def unique(values):
346346
array([2, 1, 3])
347347
348348
>>> pd.unique(pd.Series([2] + [1] * 5))
349-
array([2, 1], dtype=int64)
349+
array([2, 1])
350350
351351
>>> pd.unique(pd.Series([pd.Timestamp("20160101"), pd.Timestamp("20160101")]))
352352
array(['2016-01-01T00:00:00.000000000'], dtype='datetime64[ns]')
@@ -714,7 +714,7 @@ def factorize(
714714
715715
>>> codes, uniques = pd.factorize(values, use_na_sentinel=False)
716716
>>> codes
717-
array([0, 1, 0, 2], dtype=int64)
717+
array([0, 1, 0, 2])
718718
>>> uniques
719719
array([ 1., 2., nan])
720720
"""

pandas/core/arrays/categorical.py

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,7 @@ def argsort(self, ascending=True, kind="quicksort", **kwargs):
18311831
Examples
18321832
--------
18331833
>>> pd.Categorical(['b', 'b', 'a', 'c']).argsort()
1834-
array([2, 0, 1, 3], dtype=int64)
1834+
array([2, 0, 1, 3])
18351835
18361836
>>> cat = pd.Categorical(['b', 'b', 'a', 'c'],
18371837
... categories=['c', 'b', 'a'],
@@ -2227,29 +2227,28 @@ def _validate_listlike(self, value):
22272227

22282228
def _reverse_indexer(self) -> dict[Hashable, npt.NDArray[np.intp]]:
22292229
"""
2230-
Compute the inverse of a categorical, returning
2231-
a dict of categories -> indexers.
2232-
2233-
*This is an internal function*
2234-
2235-
Returns
2236-
-------
2237-
Dict[Hashable, np.ndarray[np.intp]]
2238-
dict of categories -> indexers
2239-
2240-
Examples
2241-
--------
2242-
>>> c = pd.Categorical(list('aabca'))
2243-
>>> c
2244-
['a', 'a', 'b', 'c', 'a']
2245-
Categories (3, object): ['a', 'b', 'c']
2246-
>>> c.categories
2247-
Index(['a', 'b', 'c'], dtype='object')
2248-
>>> c.codes
2249-
array([0, 0, 1, 2, 0], dtype=int8)
2250-
>>> c._reverse_indexer()
2251-
{'a': array([0, 1, 4], dtype=int64), 'b':
2252-
array([2], dtype=int64), 'c': array([3], dtype=int64)}
2230+
Compute the inverse of a categorical, returning
2231+
a dict of categories -> indexers.
2232+
2233+
*This is an internal function*
2234+
2235+
Returns
2236+
-------
2237+
Dict[Hashable, np.ndarray[np.intp]]
2238+
dict of categories -> indexers
2239+
2240+
Examples
2241+
--------
2242+
>>> c = pd.Categorical(list('aabca'))
2243+
>>> c
2244+
['a', 'a', 'b', 'c', 'a']
2245+
Categories (3, object): ['a', 'b', 'c']
2246+
>>> c.categories
2247+
Index(['a', 'b', 'c'], dtype='object')
2248+
>>> c.codes
2249+
array([0, 0, 1, 2, 0], dtype=int8)
2250+
>>> c._reverse_indexer()
2251+
{'a': array([0, 1, 4]), 'b': array([2]), 'c': array([3])}
22532252
22542253
"""
22552254
categories = self.categories

pandas/core/arrays/masked.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def to_numpy(
377377
>>> pd.array([True, False], dtype="boolean").to_numpy(dtype="bool")
378378
array([ True, False])
379379
>>> pd.array([1, 2], dtype="Int64").to_numpy("int64")
380-
array([1, 2], dtype=int64)
380+
array([1, 2])
381381
382382
However, requesting such dtype will raise a ValueError if
383383
missing values are present and the default missing value :attr:`NA`

pandas/core/arrays/sparse/array.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ class SparseArray(OpsMixin, PandasObject, ExtensionArray):
356356
[0, 0, 1, 2]
357357
Fill: 0
358358
IntIndex
359-
Indices: array([2, 3])
359+
Indices: array([2, 3], dtype=int32)
360360
"""
361361

362362
_subtyp = "sparse_array" # register ABCSparseArray
@@ -639,7 +639,7 @@ def sp_values(self) -> np.ndarray:
639639
--------
640640
>>> s = SparseArray([0, 0, 1, 0, 2], fill_value=0)
641641
>>> s.sp_values
642-
array([1, 2], dtype=int64)
642+
array([1, 2])
643643
"""
644644
return self._sparse_values
645645

@@ -1277,7 +1277,7 @@ def astype(self, dtype: AstypeArg | None = None, copy: bool = True):
12771277
[0, 0, 1, 2]
12781278
Fill: 0
12791279
IntIndex
1280-
Indices: array([2, 3])
1280+
Indices: array([2, 3], dtype=int32)
12811281
12821282
>>> arr.astype(SparseDtype(np.dtype('int32')))
12831283
[0, 0, 1, 2]
@@ -1355,7 +1355,7 @@ def map(self: SparseArrayT, mapper) -> SparseArrayT:
13551355
[10, 11, 12]
13561356
Fill: 10
13571357
IntIndex
1358-
Indices: array([1, 2])
1358+
Indices: array([1, 2], dtype=int32)
13591359
13601360
>>> arr.map({0: 10, 1: 11, 2: 12})
13611361
[10, 11, 12]

pandas/core/arrays/sparse/dtype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def _subtype_with_str(self):
373373
Returns
374374
-------
375375
>>> SparseDtype(int, 1)._subtype_with_str
376-
dtype('int32')
376+
dtype('int64')
377377
378378
>>> SparseDtype(object, 1)._subtype_with_str
379379
dtype('O')

pandas/core/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,10 +1213,10 @@ def factorize(
12131213
array([0, 3])
12141214
12151215
>>> ser.searchsorted([1, 3], side='left')
1216-
array([0, 2], dtype=int64)
1216+
array([0, 2])
12171217
12181218
>>> ser.searchsorted([1, 3], side='right')
1219-
array([1, 3], dtype=int64)
1219+
array([1, 3])
12201220
12211221
>>> ser = pd.Series(pd.to_datetime(['3/11/2000', '3/12/2000', '3/13/2000']))
12221222
>>> ser

pandas/core/construction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def extract_array(
439439
To extract all the way down to the ndarray, pass ``extract_numpy=True``.
440440
441441
>>> extract_array(pd.Series([1, 2, 3]), extract_numpy=True)
442-
array([1, 2, 3], dtype=int64)
442+
array([1, 2, 3])
443443
"""
444444
if isinstance(obj, (ABCIndex, ABCSeries)):
445445
if isinstance(obj, ABCRangeIndex):

pandas/core/dtypes/cast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ def infer_dtype_from_array(
884884
Examples
885885
--------
886886
>>> np.asarray([1, '1'])
887-
array(['1', '1'], dtype='<U11')
887+
array(['1', '1'], dtype='<U21')
888888
889889
>>> infer_dtype_from_array([1, '1'])
890890
(dtype('O'), [1, '1'])

pandas/core/dtypes/dtypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ class DatetimeTZDtype(PandasExtensionDtype):
669669
datetime64[ns, UTC]
670670
671671
>>> pd.DatetimeTZDtype(tz='dateutil/US/Central')
672-
datetime64[ns, tzfile('US/Central')]
672+
datetime64[ns, tzfile('/usr/share/zoneinfo/US/Central')]
673673
"""
674674

675675
type: type[Timestamp] = Timestamp

pandas/core/groupby/grouper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class Grouper:
203203
2000-10-02 00:12:00 18
204204
2000-10-02 00:19:00 21
205205
2000-10-02 00:26:00 24
206-
Freq: 7T, dtype: int32
206+
Freq: 7T, dtype: int64
207207
208208
>>> ts.groupby(pd.Grouper(freq='17min')).sum()
209209
2000-10-01 23:14:00 0

0 commit comments

Comments
 (0)