Skip to content

Commit 7bd7fab

Browse files
ihsansecerWillAyd
authored andcommitted
DOC: Fix validation error type RT01 and check in CI (#25356) (#26234)
1 parent 0f220d4 commit 7bd7fab

24 files changed

+427
-12
lines changed

ci/code_checks.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ fi
261261
### DOCSTRINGS ###
262262
if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
263263

264-
MSG='Validate docstrings (GL03, GL06, GL07, GL09, SS04, SS05, PR03, PR04, PR05, PR10, EX04, RT04, RT05, SA05)' ; echo $MSG
265-
$BASE_DIR/scripts/validate_docstrings.py --format=azure --errors=GL03,GL06,GL07,GL09,SS04,SS05,PR03,PR04,PR05,PR10,EX04,RT04,RT05,SA05
264+
MSG='Validate docstrings (GL03, GL06, GL07, GL09, SS04, SS05, PR03, PR04, PR05, PR10, EX04, RT01, RT04, RT05, SA05)' ; echo $MSG
265+
$BASE_DIR/scripts/validate_docstrings.py --format=azure --errors=GL03,GL06,GL07,GL09,SS04,SS05,PR03,PR04,PR05,PR10,EX04,RT01,RT04,RT05,SA05
266266
RET=$(($RET + $?)) ; echo $MSG "DONE"
267267

268268
fi

pandas/core/accessor.py

+5
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ def decorator(accessor):
205205
Name under which the accessor should be registered. A warning is issued
206206
if this name conflicts with a preexisting attribute.
207207
208+
Returns
209+
-------
210+
callable
211+
A class decorator.
212+
208213
See Also
209214
--------
210215
%(others)s

pandas/core/arrays/categorical.py

+14
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,10 @@ def from_codes(cls, codes, categories=None, ordered=None, dtype=None):
619619
When `dtype` is provided, neither `categories` nor `ordered`
620620
should be provided.
621621
622+
Returns
623+
-------
624+
Categorical
625+
622626
Examples
623627
--------
624628
>>> dtype = pd.CategoricalDtype(['a', 'b'], ordered=True)
@@ -756,6 +760,11 @@ def as_ordered(self, inplace=False):
756760
inplace : bool, default False
757761
Whether or not to set the ordered attribute in-place or return
758762
a copy of this categorical with ordered set to True.
763+
764+
Returns
765+
-------
766+
Categorical
767+
Ordered Categorical.
759768
"""
760769
inplace = validate_bool_kwarg(inplace, 'inplace')
761770
return self.set_ordered(True, inplace=inplace)
@@ -769,6 +778,11 @@ def as_unordered(self, inplace=False):
769778
inplace : bool, default False
770779
Whether or not to set the ordered attribute in-place or return
771780
a copy of this categorical with ordered set to False.
781+
782+
Returns
783+
-------
784+
Categorical
785+
Unordered Categorical.
772786
"""
773787
inplace = validate_bool_kwarg(inplace, 'inplace')
774788
return self.set_ordered(False, inplace=inplace)

pandas/core/arrays/interval.py

+8
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ def _from_factorized(cls, values, original):
239239
240240
.. versionadded:: 0.23.0
241241
242+
Returns
243+
-------
244+
%(klass)s
245+
242246
See Also
243247
--------
244248
interval_range : Function to create a fixed frequency IntervalIndex.
@@ -383,6 +387,10 @@ def from_arrays(cls, left, right, closed='right', copy=False, dtype=None):
383387
384388
..versionadded:: 0.23.0
385389
390+
Returns
391+
-------
392+
%(klass)s
393+
386394
See Also
387395
--------
388396
interval_range : Function to create a fixed frequency IntervalIndex.

pandas/core/base.py

+18
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,10 @@ class IndexOpsMixin:
656656
def transpose(self, *args, **kwargs):
657657
"""
658658
Return the transpose, which is by definition self.
659+
660+
Returns
661+
-------
662+
%(klass)s
659663
"""
660664
nv.validate_transpose(args, kwargs)
661665
return self
@@ -696,6 +700,11 @@ def ndim(self):
696700
def item(self):
697701
"""
698702
Return the first element of the underlying data as a python scalar.
703+
704+
Returns
705+
-------
706+
scalar
707+
The first element of %(klass)s.
699708
"""
700709
return self.values.item()
701710

@@ -1022,6 +1031,11 @@ def argmax(self, axis=None, skipna=True):
10221031
Dummy argument for consistency with Series
10231032
skipna : bool, default True
10241033
1034+
Returns
1035+
-------
1036+
numpy.ndarray
1037+
Indices of the maximum values.
1038+
10251039
See Also
10261040
--------
10271041
numpy.ndarray.argmax
@@ -1122,6 +1136,10 @@ def __iter__(self):
11221136
These are each a scalar type, which is a Python scalar
11231137
(for str, int, float) or a pandas scalar
11241138
(for Timestamp/Timedelta/Interval/Period)
1139+
1140+
Returns
1141+
-------
1142+
iterator
11251143
"""
11261144
# We are explicity making element iterators.
11271145
if is_datetimelike(self._values):

pandas/core/dtypes/dtypes.py

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ def register_extension_dtype(cls):
2727
This enables operations like ``.astype(name)`` for the name
2828
of the ExtensionDtype.
2929
30+
Returns
31+
-------
32+
callable
33+
A class decorator.
34+
3035
Examples
3136
--------
3237
>>> from pandas.api.extensions import register_extension_dtype

pandas/core/dtypes/inference.py

+4
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,10 @@ def is_hashable(obj):
435435
Distinguish between these and other types by trying the call to hash() and
436436
seeing if they raise TypeError.
437437
438+
Returns
439+
-------
440+
bool
441+
438442
Examples
439443
--------
440444
>>> a = ([],)

pandas/core/frame.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -839,12 +839,12 @@ def itertuples(self, index=True, name="Pandas"):
839839
The name of the returned namedtuples or None to return regular
840840
tuples.
841841
842-
Yields
842+
Returns
843843
-------
844-
collections.namedtuple
845-
Yields a namedtuple for each row in the DataFrame with the first
846-
field possibly being the index and following fields being the
847-
column values.
844+
iterator
845+
An object to iterate over namedtuples for each row in the
846+
DataFrame with the first field possibly being the index and
847+
following fields being the column values.
848848
849849
See Also
850850
--------
@@ -3651,6 +3651,10 @@ def lookup(self, row_labels, col_labels):
36513651
col_labels : sequence
36523652
The column labels to use for lookup
36533653
3654+
Returns
3655+
-------
3656+
numpy.ndarray
3657+
36543658
Notes
36553659
-----
36563660
Akin to::
@@ -6053,6 +6057,11 @@ def unstack(self, level=-1, fill_value=None):
60536057
col_level : int or string, optional
60546058
If columns are a MultiIndex then use this level to melt.
60556059
6060+
Returns
6061+
-------
6062+
DataFrame
6063+
Unpivoted DataFrame.
6064+
60566065
See Also
60576066
--------
60586067
%(other)s

pandas/core/generic.py

+47-1
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,11 @@ def bool(self):
15181518
This must be a boolean scalar value, either True or False. Raise a
15191519
ValueError if the PandasObject does not have exactly 1 element, or that
15201520
element is not boolean
1521+
1522+
Returns
1523+
-------
1524+
bool
1525+
Same single boolean value converted to bool type.
15211526
"""
15221527
v = self.squeeze()
15231528
if isinstance(v, (bool, np.bool_)):
@@ -1845,14 +1850,26 @@ def __hash__(self):
18451850
' hashed'.format(self.__class__.__name__))
18461851

18471852
def __iter__(self):
1848-
"""Iterate over info axis"""
1853+
"""
1854+
Iterate over info axis.
1855+
1856+
Returns
1857+
-------
1858+
iterator
1859+
Info axis as iterator.
1860+
"""
18491861
return iter(self._info_axis)
18501862

18511863
# can we get a better explanation of this?
18521864
def keys(self):
18531865
"""Get the 'info axis' (see Indexing for more)
18541866
18551867
This is index for Series, columns for DataFrame.
1868+
1869+
Returns
1870+
-------
1871+
Index
1872+
Info axis.
18561873
"""
18571874
return self._info_axis
18581875

@@ -1946,6 +1963,11 @@ def __array_wrap__(self, result, context=None):
19461963
def to_dense(self):
19471964
"""
19481965
Return dense representation of NDFrame (as opposed to sparse).
1966+
1967+
Returns
1968+
-------
1969+
%(klass)s
1970+
Dense %(klass)s.
19491971
"""
19501972
# compat
19511973
return self
@@ -2238,6 +2260,12 @@ def to_json(self, path_or_buf=None, orient=None, date_format=None,
22382260
22392261
.. versionadded:: 0.23.0
22402262
2263+
Returns
2264+
-------
2265+
None or str
2266+
If path_or_buf is None, returns the resulting json format as a
2267+
string. Otherwise returns None.
2268+
22412269
See Also
22422270
--------
22432271
read_json
@@ -2418,6 +2446,12 @@ def to_msgpack(self, path_or_buf=None, encoding='utf-8', **kwargs):
24182446
(default is False)
24192447
compress : type of compressor (zlib or blosc), default to None (no
24202448
compression)
2449+
2450+
Returns
2451+
-------
2452+
None or str
2453+
If path_or_buf is None, returns the resulting msgpack format as a
2454+
string. Otherwise returns None.
24212455
"""
24222456

24232457
from pandas.io import packers
@@ -6167,13 +6201,23 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
61676201
def ffill(self, axis=None, inplace=False, limit=None, downcast=None):
61686202
"""
61696203
Synonym for :meth:`DataFrame.fillna` with ``method='ffill'``.
6204+
6205+
Returns
6206+
-------
6207+
%(klass)s
6208+
Object with missing values filled.
61706209
"""
61716210
return self.fillna(method='ffill', axis=axis, inplace=inplace,
61726211
limit=limit, downcast=downcast)
61736212

61746213
def bfill(self, axis=None, inplace=False, limit=None, downcast=None):
61756214
"""
61766215
Synonym for :meth:`DataFrame.fillna` with ``method='bfill'``.
6216+
6217+
Returns
6218+
-------
6219+
%(klass)s
6220+
Object with missing values filled.
61776221
"""
61786222
return self.fillna(method='bfill', axis=axis, inplace=inplace,
61796223
limit=limit, downcast=downcast)
@@ -9313,6 +9357,8 @@ def tz_convert(self, tz, axis=0, level=None, copy=True):
93139357
93149358
Returns
93159359
-------
9360+
%(klass)s
9361+
Object with time zone converted axis.
93169362
93179363
Raises
93189364
------

pandas/core/groupby/generic.py

+21-2
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,11 @@ def true_and_notna(x, *args, **kwargs):
999999
def nunique(self, dropna=True):
10001000
"""
10011001
Return number of unique elements in the group.
1002+
1003+
Returns
1004+
-------
1005+
Series
1006+
Number of unique values within each group.
10021007
"""
10031008
ids, _, _ = self.grouper.group_info
10041009

@@ -1181,7 +1186,14 @@ def value_counts(self, normalize=False, sort=True, ascending=False,
11811186
return Series(out, index=mi, name=self._selection_name)
11821187

11831188
def count(self):
1184-
""" Compute count of group, excluding missing values """
1189+
"""
1190+
Compute count of group, excluding missing values.
1191+
1192+
Returns
1193+
-------
1194+
Series
1195+
Count of values within each group.
1196+
"""
11851197
ids, _, ngroups = self.grouper.group_info
11861198
val = self.obj.get_values()
11871199

@@ -1479,7 +1491,14 @@ def _fill(self, direction, limit=None):
14791491
return concat((self._wrap_transformed_output(output), res), axis=1)
14801492

14811493
def count(self):
1482-
""" Compute count of group, excluding missing values """
1494+
"""
1495+
Compute count of group, excluding missing values.
1496+
1497+
Returns
1498+
-------
1499+
DataFrame
1500+
Count of values within each group.
1501+
"""
14831502
from pandas.core.dtypes.missing import _isna_ndarraylike as _isna
14841503

14851504
data, _ = self._get_data_to_aggregate()

0 commit comments

Comments
 (0)