Skip to content

DOC: Fix assorted doc warnings #47080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2022
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
7 changes: 5 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.

from datetime import datetime
import importlib
import inspect
import logging
import os
import sys
import warnings

import jinja2
from numpydoc.docscrape import NumpyDocString
Expand Down Expand Up @@ -640,7 +640,10 @@ def linkcode_resolve(domain, info):
obj = submod
for part in fullname.split("."):
try:
obj = getattr(obj, part)
with warnings.catch_warnings():
# Accessing deprecated objects will generate noisy warnings
warnings.simplefilter("ignore", FutureWarning)
obj = getattr(obj, part)
except AttributeError:
return None

Expand Down
16 changes: 8 additions & 8 deletions pandas/core/arrays/sparse/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ def astype(self, dtype: AstypeArg | None = None, copy: bool = True):
IntIndex
Indices: array([2, 3], dtype=int32)

>>> arr.astype(np.dtype('int32'))
>>> arr.astype(SparseDtype(np.dtype('int32')))
[0, 0, 1, 2]
Fill: 0
IntIndex
Expand All @@ -1262,19 +1262,19 @@ def astype(self, dtype: AstypeArg | None = None, copy: bool = True):
Using a NumPy dtype with a different kind (e.g. float) will coerce
just ``self.sp_values``.

>>> arr.astype(np.dtype('float64'))
>>> arr.astype(SparseDtype(np.dtype('float64')))
... # doctest: +NORMALIZE_WHITESPACE
[0.0, 0.0, 1.0, 2.0]
Fill: 0.0
[nan, nan, 1.0, 2.0]
Fill: nan
IntIndex
Indices: array([2, 3], dtype=int32)

Use a SparseDtype if you wish to be change the fill value as well.
Using a SparseDtype, you can also change the fill value as well.

>>> arr.astype(SparseDtype("float64", fill_value=np.nan))
>>> arr.astype(SparseDtype("float64", fill_value=0.0))
... # doctest: +NORMALIZE_WHITESPACE
[nan, nan, 1.0, 2.0]
Fill: nan
[0.0, 0.0, 1.0, 2.0]
Fill: 0.0
IntIndex
Indices: array([2, 3], dtype=int32)
"""
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8109,9 +8109,9 @@ def resample(
Freq: 30S, dtype: float64

Upsample the series into 30 second bins and fill the ``NaN``
values using the ``pad`` method.
values using the ``ffill`` method.

>>> series.resample('30S').pad()[0:5]
>>> series.resample('30S').ffill()[0:5]
2000-01-01 00:00:00 0
2000-01-01 00:00:30 0
2000-01-01 00:01:00 1
Expand Down
18 changes: 9 additions & 9 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class providing the base-class of operations.
... 'two', 'two'],
... 'C' : [1, 5, 5, 2, 5, 5],
... 'D' : [2.0, 5., 8., 1., 2., 9.]})
>>> grouped = df.groupby('A')
>>> grouped = df.groupby('A')[['C', 'D']]
>>> grouped.transform(lambda x: (x - x.mean()) / x.std())
C D
0 -1.154701 -0.577350
Expand All @@ -428,20 +428,20 @@ class providing the base-class of operations.
Broadcast result of the transformation

>>> grouped.transform(lambda x: x.max() - x.min())
C D
0 4 6.0
1 3 8.0
2 4 6.0
3 3 8.0
4 4 6.0
5 3 8.0
C D
0 4.0 6.0
1 3.0 8.0
2 4.0 6.0
3 3.0 8.0
4 4.0 6.0
5 3.0 8.0

.. versionchanged:: 1.3.0

The resulting dtype will reflect the return value of the passed ``func``,
for example:

>>> grouped[['C', 'D']].transform(lambda x: x.astype(int).max())
>>> grouped.transform(lambda x: x.astype(int).max())
C D
0 5 8
1 5 9
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5514,10 +5514,10 @@ def equals(self, other: Any) -> bool:

The dtype is *not* compared

>>> int64_idx = pd.Int64Index([1, 2, 3])
>>> int64_idx = pd.Index([1, 2, 3], dtype='int64')
>>> int64_idx
Int64Index([1, 2, 3], dtype='int64')
>>> uint64_idx = pd.UInt64Index([1, 2, 3])
>>> uint64_idx = pd.Index([1, 2, 3], dtype='uint64')
>>> uint64_idx
UInt64Index([1, 2, 3], dtype='uint64')
>>> int64_idx.equals(uint64_idx)
Expand Down