Skip to content
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

DOC: Updated resample.py and groupby.py to fix SA04 Errors #37219

Merged
merged 9 commits into from
Oct 29, 2020
3 changes: 2 additions & 1 deletion pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,8 @@ cdef class _Timedelta(timedelta):

See Also
--------
Timestamp.isoformat
Timestamp.isoformat : Function is used to convert the given
Timestamp object into the ISO format.

Notes
-----
Expand Down
10 changes: 5 additions & 5 deletions pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ def _from_factorized(cls, values, original):

See Also
--------
factorize
ExtensionArray.factorize
factorize : Top-level factorize method that dispatches here.
ExtensionArray.factorize : Encode the extension array as an enumerated type.
"""
raise AbstractMethodError(cls)

Expand Down Expand Up @@ -501,7 +501,7 @@ def _values_for_argsort(self) -> np.ndarray:

See Also
--------
ExtensionArray.argsort
ExtensionArray.argsort : Return the indices that would sort this array.
"""
# Note: this is used in `ExtensionArray.argsort`.
return np.array(self)
Expand Down Expand Up @@ -968,8 +968,8 @@ def take(

See Also
--------
numpy.take
api.extensions.take
numpy.take : Take elements from an array along an axis.
api.extensions.take : Take elements from an array.

Notes
-----
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/boolean.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def _values_for_argsort(self) -> np.ndarray:

See Also
--------
ExtensionArray.argsort
ExtensionArray.argsort : Return the indices that would sort this array.
"""
data = self._data.copy()
data[self._mask] = -1
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2061,7 +2061,7 @@ def unique(self):
--------
pandas.unique
CategoricalIndex.unique
Series.unique
Series.unique : Return unique values of Series object.

Examples
--------
Expand Down
6 changes: 4 additions & 2 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1259,8 +1259,10 @@ def isocalendar(self):

See Also
--------
Timestamp.isocalendar
datetime.date.isocalendar
Timestamp.isocalendar : Function return a 3-tuple containing ISO year,
week number, and weekday for the given Timestamp object.
datetime.date.isocalendar : Return a named tuple object with
three components: year, week and weekday.

Examples
--------
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def _values_for_argsort(self) -> np.ndarray:

See Also
--------
ExtensionArray.argsort
ExtensionArray.argsort : Return the indices that would sort this array.
"""
data = self._data.copy()
if self._mask.any():
Expand Down
5 changes: 3 additions & 2 deletions pandas/core/dtypes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ class ExtensionDtype:

See Also
--------
extensions.register_extension_dtype
extensions.ExtensionArray
extensions.register_extension_dtype: Register an ExtensionType
with pandas as class decorator.
extensions.ExtensionArray: Abstract base class for custom 1-D array types.

Notes
-----
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ def shape(self) -> Tuple[int, int]:

See Also
--------
ndarray.shape
ndarray.shape : Tuple of array dimensions.

Examples
--------
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def attrs(self) -> Dict[Optional[Hashable], Any]:

See Also
--------
DataFrame.flags
DataFrame.flags : Global flags applying to this object.
"""
if self._attrs is None:
self._attrs = {}
Expand All @@ -281,8 +281,8 @@ def flags(self) -> Flags:

See Also
--------
Flags
DataFrame.attrs
Flags : Flags that apply to pandas objects.
DataFrame.attrs : Global metadata applying to this dataset.

Notes
-----
Expand Down
43 changes: 25 additions & 18 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ class providing the base-class of operations.
_common_see_also = """
See Also
--------
Series.%(name)s
DataFrame.%(name)s
Series.%(name)s : Apply a function %(name)s to a Series.
DataFrame.%(name)s : Apply a function %(name)s
to each row or column of a DataFrame.
"""

_apply_docs = dict(
Expand Down Expand Up @@ -318,9 +319,12 @@ class providing the base-class of operations.

See Also
--------
%(klass)s.groupby.apply
%(klass)s.groupby.aggregate
%(klass)s.transform
%(klass)s.groupby.apply : Apply function func group-wise
and combine the results together.
%(klass)s.groupby.aggregate : Aggregate using one or more
operations over the specified axis.
%(klass)s.transform : Transforms the Series on each group
based on the given function.

Notes
-----
Expand Down Expand Up @@ -427,9 +431,12 @@ class providing the base-class of operations.

See Also
--------
{klass}.groupby.apply
{klass}.groupby.transform
{klass}.aggregate
{klass}.groupby.apply : Apply function func group-wise
and combine the results together.
{klass}.groupby.transform : Aggregate using one or more
operations over the specified axis.
{klass}.aggregate : Transforms the Series on each group
based on the given function.

Notes
-----
Expand Down Expand Up @@ -1856,8 +1863,8 @@ def _fill(self, direction, limit=None):

See Also
--------
pad
backfill
pad : Returns Series with minimum number of char in object.
backfill : Backward fill the missing values in the dataset.
"""
# Need int value for Cython
if limit is None:
Expand Down Expand Up @@ -1891,10 +1898,10 @@ def pad(self, limit=None):

See Also
--------
Series.pad
DataFrame.pad
Series.fillna
DataFrame.fillna
Series.pad: Returns Series with minimum number of char in object.
DataFrame.pad: Object with missing values filled or None if inplace=True.
Series.fillna: Fill NaN values of a Series.
DataFrame.fillna: Fill NaN values of a DataFrame.
"""
return self._fill("ffill", limit=limit)

Expand All @@ -1917,10 +1924,10 @@ def backfill(self, limit=None):

See Also
--------
Series.backfill
DataFrame.backfill
Series.fillna
DataFrame.fillna
Series.backfill : Backward fill the missing values in the dataset.
DataFrame.backfill: Backward fill the missing values in the dataset.
Series.fillna: Fill NaN values of a Series.
DataFrame.fillna: Fill NaN values of a DataFrame.
"""
return self._fill("bfill", limit=limit)

Expand Down
9 changes: 6 additions & 3 deletions pandas/core/indexes/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,10 @@ def isocalendar(self):

See Also
--------
Timestamp.isocalendar
datetime.date.isocalendar
Timestamp.isocalendar : Function return a 3-tuple containing ISO year,
week number, and weekday for the given Timestamp object.
datetime.date.isocalendar : Return a named tuple object with
three components: year, week and weekday.

Examples
--------
Expand Down Expand Up @@ -326,7 +328,8 @@ def to_pytimedelta(self) -> np.ndarray:

See Also
--------
datetime.timedelta
datetime.timedelta : A duration expressing the difference
between two date, time, or datetime.

Examples
--------
Expand Down
14 changes: 8 additions & 6 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ def ravel(self, order="C"):

See Also
--------
numpy.ndarray.ravel
numpy.ndarray.ravel : Return a flattened array.
"""
warnings.warn(
"Index.ravel returning ndarray is deprecated; in a future version "
Expand Down Expand Up @@ -709,7 +709,8 @@ def astype(self, dtype, copy=True):

See Also
--------
numpy.ndarray.take
numpy.ndarray.take: Return an array formed from the
elements of a at the given indices.
"""

@Appender(_index_shared_docs["take"] % _index_doc_kwargs)
Expand Down Expand Up @@ -2309,8 +2310,8 @@ def unique(self, level=None):

See Also
--------
unique
Series.unique
unique : Numpy array of unique values in that column.
Series.unique : Return unique values of Series object.
"""
if level is not None:
self._validate_index_level(level)
Expand Down Expand Up @@ -3953,7 +3954,7 @@ def _values(self) -> Union[ExtensionArray, np.ndarray]:

See Also
--------
values
values : Values
"""
return self._data

Expand Down Expand Up @@ -4244,7 +4245,8 @@ def putmask(self, mask, value):

See Also
--------
numpy.ndarray.putmask
numpy.ndarray.putmask : Changes elements of an array
based on conditional and input values.
"""
values = self.values.copy()
try:
Expand Down
28 changes: 18 additions & 10 deletions pandas/core/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __iter__(self):

See Also
--------
GroupBy.__iter__
GroupBy.__iter__ : Generator yielding sequence for each group.
"""
self._set_binner()
return super().__iter__()
Expand Down Expand Up @@ -235,9 +235,12 @@ def pipe(self, func, *args, **kwargs):
"""
See Also
--------
DataFrame.groupby.aggregate
DataFrame.resample.transform
DataFrame.aggregate
DataFrame.groupby.aggregate : Aggregate using callable, string, dict,
or list of string/callables.
DataFrame.resample.transform : Transforms the Series on each group
based on the given function.
DataFrame.aggregate: Aggregate using one or more
operations over the specified axis.
"""
)

Expand Down Expand Up @@ -454,8 +457,8 @@ def pad(self, limit=None):

See Also
--------
Series.fillna
DataFrame.fillna
Series.fillna: Fill NA/NaN values using the specified method.
DataFrame.fillna: Fill NA/NaN values using the specified method.
"""
return self._upsample("pad", limit=limit)

Expand Down Expand Up @@ -829,8 +832,8 @@ def asfreq(self, fill_value=None):

See Also
--------
Series.asfreq
DataFrame.asfreq
Series.asfreq: Convert TimeSeries to specified frequency.
DataFrame.asfreq: Convert TimeSeries to specified frequency.
"""
return self._upsample("asfreq", fill_value=fill_value)

Expand Down Expand Up @@ -916,8 +919,13 @@ def quantile(self, q=0.5, **kwargs):
See Also
--------
Series.quantile
Return a series, where the index is q and the values are the quantiles.
DataFrame.quantile
Return a DataFrame, where the columns are the columns of self,
and the values are the quantiles.
DataFrameGroupBy.quantile
Return a DataFrame, where the coulmns are groupby columns,
and the values are its quantiles.
"""
return self._downsample("quantile", q=q, **kwargs)

Expand Down Expand Up @@ -1073,7 +1081,7 @@ def _upsample(self, method, limit=None, fill_value=None):

See Also
--------
.fillna
.fillna: Fill NA/NaN values using the specified method.

"""
self._set_binner()
Expand Down Expand Up @@ -1209,7 +1217,7 @@ def _upsample(self, method, limit=None, fill_value=None):

See Also
--------
.fillna
.fillna: Fill NA/NaN values using the specified method.

"""
# we may need to actually resample as if we are timestamps
Expand Down
9 changes: 5 additions & 4 deletions pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,8 @@ def applymap(self, func: Callable, subset=None, **kwargs) -> "Styler":

See Also
--------
Styler.where
Styler.where: Updates the HTML representation with a style which is
selected in accordance with the return value of a function.
"""
self._todo.append(
(lambda instance: getattr(instance, "_applymap"), (func, subset), kwargs)
Expand Down Expand Up @@ -870,7 +871,7 @@ def where(

See Also
--------
Styler.applymap
Styler.applymap: Updates the HTML representation with the result.
"""
if other is None:
other = ""
Expand Down Expand Up @@ -930,7 +931,7 @@ def export(self) -> List[Tuple[Callable, Tuple, Dict]]:

See Also
--------
Styler.use
Styler.use: Set the styles on the current Styler.
"""
return self._todo

Expand All @@ -951,7 +952,7 @@ def use(self, styles: List[Tuple[Callable, Tuple, Dict]]) -> "Styler":

See Also
--------
Styler.export
Styler.export : Export the styles to applied to the current Styler.
"""
self._todo.extend(styles)
return self
Expand Down