Skip to content

Commit 5d451b6

Browse files
rhshadrachyehoshuadimarsky
authored andcommitted
DOC: Fix assorted doc warnings (pandas-dev#47080)
1 parent 1948adf commit 5d451b6

File tree

5 files changed

+26
-23
lines changed

5 files changed

+26
-23
lines changed

doc/source/conf.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
#
1010
# All configuration values have a default; values that are commented out
1111
# serve to show the default.
12-
1312
from datetime import datetime
1413
import importlib
1514
import inspect
1615
import logging
1716
import os
1817
import sys
18+
import warnings
1919

2020
import jinja2
2121
from numpydoc.docscrape import NumpyDocString
@@ -640,7 +640,10 @@ def linkcode_resolve(domain, info):
640640
obj = submod
641641
for part in fullname.split("."):
642642
try:
643-
obj = getattr(obj, part)
643+
with warnings.catch_warnings():
644+
# Accessing deprecated objects will generate noisy warnings
645+
warnings.simplefilter("ignore", FutureWarning)
646+
obj = getattr(obj, part)
644647
except AttributeError:
645648
return None
646649

pandas/core/arrays/sparse/array.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ def astype(self, dtype: AstypeArg | None = None, copy: bool = True):
12531253
IntIndex
12541254
Indices: array([2, 3], dtype=int32)
12551255
1256-
>>> arr.astype(np.dtype('int32'))
1256+
>>> arr.astype(SparseDtype(np.dtype('int32')))
12571257
[0, 0, 1, 2]
12581258
Fill: 0
12591259
IntIndex
@@ -1262,19 +1262,19 @@ def astype(self, dtype: AstypeArg | None = None, copy: bool = True):
12621262
Using a NumPy dtype with a different kind (e.g. float) will coerce
12631263
just ``self.sp_values``.
12641264
1265-
>>> arr.astype(np.dtype('float64'))
1265+
>>> arr.astype(SparseDtype(np.dtype('float64')))
12661266
... # doctest: +NORMALIZE_WHITESPACE
1267-
[0.0, 0.0, 1.0, 2.0]
1268-
Fill: 0.0
1267+
[nan, nan, 1.0, 2.0]
1268+
Fill: nan
12691269
IntIndex
12701270
Indices: array([2, 3], dtype=int32)
12711271
1272-
Use a SparseDtype if you wish to be change the fill value as well.
1272+
Using a SparseDtype, you can also change the fill value as well.
12731273
1274-
>>> arr.astype(SparseDtype("float64", fill_value=np.nan))
1274+
>>> arr.astype(SparseDtype("float64", fill_value=0.0))
12751275
... # doctest: +NORMALIZE_WHITESPACE
1276-
[nan, nan, 1.0, 2.0]
1277-
Fill: nan
1276+
[0.0, 0.0, 1.0, 2.0]
1277+
Fill: 0.0
12781278
IntIndex
12791279
Indices: array([2, 3], dtype=int32)
12801280
"""

pandas/core/generic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8109,9 +8109,9 @@ def resample(
81098109
Freq: 30S, dtype: float64
81108110
81118111
Upsample the series into 30 second bins and fill the ``NaN``
8112-
values using the ``pad`` method.
8112+
values using the ``ffill`` method.
81138113
8114-
>>> series.resample('30S').pad()[0:5]
8114+
>>> series.resample('30S').ffill()[0:5]
81158115
2000-01-01 00:00:00 0
81168116
2000-01-01 00:00:30 0
81178117
2000-01-01 00:01:00 1

pandas/core/groupby/groupby.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ class providing the base-class of operations.
415415
... 'two', 'two'],
416416
... 'C' : [1, 5, 5, 2, 5, 5],
417417
... 'D' : [2.0, 5., 8., 1., 2., 9.]})
418-
>>> grouped = df.groupby('A')
418+
>>> grouped = df.groupby('A')[['C', 'D']]
419419
>>> grouped.transform(lambda x: (x - x.mean()) / x.std())
420420
C D
421421
0 -1.154701 -0.577350
@@ -428,20 +428,20 @@ class providing the base-class of operations.
428428
Broadcast result of the transformation
429429
430430
>>> grouped.transform(lambda x: x.max() - x.min())
431-
C D
432-
0 4 6.0
433-
1 3 8.0
434-
2 4 6.0
435-
3 3 8.0
436-
4 4 6.0
437-
5 3 8.0
431+
C D
432+
0 4.0 6.0
433+
1 3.0 8.0
434+
2 4.0 6.0
435+
3 3.0 8.0
436+
4 4.0 6.0
437+
5 3.0 8.0
438438
439439
.. versionchanged:: 1.3.0
440440
441441
The resulting dtype will reflect the return value of the passed ``func``,
442442
for example:
443443
444-
>>> grouped[['C', 'D']].transform(lambda x: x.astype(int).max())
444+
>>> grouped.transform(lambda x: x.astype(int).max())
445445
C D
446446
0 5 8
447447
1 5 9

pandas/core/indexes/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5514,10 +5514,10 @@ def equals(self, other: Any) -> bool:
55145514
55155515
The dtype is *not* compared
55165516
5517-
>>> int64_idx = pd.Int64Index([1, 2, 3])
5517+
>>> int64_idx = pd.Index([1, 2, 3], dtype='int64')
55185518
>>> int64_idx
55195519
Int64Index([1, 2, 3], dtype='int64')
5520-
>>> uint64_idx = pd.UInt64Index([1, 2, 3])
5520+
>>> uint64_idx = pd.Index([1, 2, 3], dtype='uint64')
55215521
>>> uint64_idx
55225522
UInt64Index([1, 2, 3], dtype='uint64')
55235523
>>> int64_idx.equals(uint64_idx)

0 commit comments

Comments
 (0)