Skip to content

Commit 89e5b22

Browse files
committed
DOC: Fix validation error RT01 in pandas/core (pandas-dev#25356)
Except errors in accessor.py, op.py and some errors in resample.py, frame.py
1 parent 3de7139 commit 89e5b22

File tree

5 files changed

+147
-1
lines changed

5 files changed

+147
-1
lines changed

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+
self: %(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

@@ -1016,6 +1025,11 @@ def argmax(self, axis=None, skipna=True):
10161025
Dummy argument for consistency with Series
10171026
skipna : bool, default True
10181027
1028+
Returns
1029+
-------
1030+
numpy.ndarray
1031+
Indices of the maximum values.
1032+
10191033
See Also
10201034
--------
10211035
numpy.ndarray.argmax
@@ -1116,6 +1130,10 @@ def __iter__(self):
11161130
These are each a scalar type, which is a Python scalar
11171131
(for str, int, float) or a pandas scalar
11181132
(for Timestamp/Timedelta/Interval/Period)
1133+
1134+
Returns
1135+
-------
1136+
iterator
11191137
"""
11201138
# We are explicity making element iterators.
11211139
if is_datetimelike(self._values):

pandas/core/frame.py

+14
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,10 @@ def to_gbq(self, destination_table, project_id=None, chunksize=None,
13881388
or string contents. This is useful for remote server
13891389
authentication (eg. Jupyter/IPython notebook on remote host).
13901390
1391+
Returns
1392+
-------
1393+
None
1394+
13911395
See Also
13921396
--------
13931397
pandas_gbq.to_gbq : This function in the pandas-gbq library.
@@ -3663,6 +3667,11 @@ def lookup(self, row_labels, col_labels):
36633667
col_labels : sequence
36643668
The column labels to use for lookup
36653669
3670+
Returns
3671+
-------
3672+
numpy.ndarray
3673+
Array of the values corresponding to each (row, col) pair.
3674+
36663675
Notes
36673676
-----
36683677
Akin to::
@@ -6051,6 +6060,11 @@ def unstack(self, level=-1, fill_value=None):
60516060
col_level : int or string, optional
60526061
If columns are a MultiIndex then use this level to melt.
60536062
6063+
Returns
6064+
-------
6065+
DataFrame
6066+
Unpivoted DataFrame.
6067+
60546068
See Also
60556069
--------
60566070
%(other)s

pandas/core/generic.py

+54-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+
boolean
1525+
Same single boolean value converted to bool type.
15211526
"""
15221527
v = self.squeeze()
15231528
if isinstance(v, (bool, np.bool_)):
@@ -1845,7 +1850,13 @@ def __hash__(self):
18451850
' hashed'.format(self.__class__.__name__))
18461851

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

18511862
# can we get a better explanation of this?
@@ -1854,6 +1865,11 @@ def keys(self):
18541865
18551866
This is index for Series, columns for DataFrame and major_axis for
18561867
Panel.
1868+
1869+
Returns
1870+
-------
1871+
Index
1872+
Info axis.
18571873
"""
18581874
return self._info_axis
18591875

@@ -1948,6 +1964,11 @@ def __array_wrap__(self, result, context=None):
19481964
def to_dense(self):
19491965
"""
19501966
Return dense representation of NDFrame (as opposed to sparse).
1967+
1968+
Returns
1969+
-------
1970+
self: %(klass)s
1971+
Dense %(klass)s.
19511972
"""
19521973
# compat
19531974
return self
@@ -2240,6 +2261,12 @@ def to_json(self, path_or_buf=None, orient=None, date_format=None,
22402261
22412262
.. versionadded:: 0.23.0
22422263
2264+
Returns
2265+
-------
2266+
None or str
2267+
If path_or_buf is None, returns the resulting json format as a
2268+
string. Otherwise returns None.
2269+
22432270
See Also
22442271
--------
22452272
read_json
@@ -2364,6 +2391,10 @@ def to_hdf(self, path_or_buf, key, **kwargs):
23642391
See the errors argument for :func:`open` for a full list
23652392
of options.
23662393
2394+
Returns
2395+
-------
2396+
None
2397+
23672398
See Also
23682399
--------
23692400
DataFrame.read_hdf : Read from HDF file.
@@ -2420,6 +2451,12 @@ def to_msgpack(self, path_or_buf=None, encoding='utf-8', **kwargs):
24202451
(default is False)
24212452
compress : type of compressor (zlib or blosc), default to None (no
24222453
compression)
2454+
2455+
Returns
2456+
-------
2457+
None or str
2458+
If path_or_buf is None, returns the resulting msgpack format as a
2459+
string. Otherwise returns None.
24232460
"""
24242461

24252462
from pandas.io import packers
@@ -2583,6 +2620,10 @@ def to_pickle(self, path, compression='infer',
25832620
.. [1] https://docs.python.org/3/library/pickle.html
25842621
.. versionadded:: 0.21.0
25852622
2623+
Returns
2624+
-------
2625+
None
2626+
25862627
See Also
25872628
--------
25882629
read_pickle : Load pickled pandas object (or any object) from file.
@@ -6171,13 +6212,23 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
61716212
def ffill(self, axis=None, inplace=False, limit=None, downcast=None):
61726213
"""
61736214
Synonym for :meth:`DataFrame.fillna` with ``method='ffill'``.
6215+
6216+
Returns
6217+
-------
6218+
%(klass)s
6219+
Object with missing values filled.
61746220
"""
61756221
return self.fillna(method='ffill', axis=axis, inplace=inplace,
61766222
limit=limit, downcast=downcast)
61776223

61786224
def bfill(self, axis=None, inplace=False, limit=None, downcast=None):
61796225
"""
61806226
Synonym for :meth:`DataFrame.fillna` with ``method='bfill'``.
6227+
6228+
Returns
6229+
-------
6230+
%(klass)s
6231+
Object with missing values filled.
61816232
"""
61826233
return self.fillna(method='bfill', axis=axis, inplace=inplace,
61836234
limit=limit, downcast=downcast)
@@ -9270,6 +9321,8 @@ def tz_convert(self, tz, axis=0, level=None, copy=True):
92709321
92719322
Returns
92729323
-------
9324+
%(klass)s
9325+
%(klass)s with time zone converted axis.
92739326
92749327
Raises
92759328
------

pandas/core/resample.py

+26
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,11 @@ def asfreq(self, fill_value=None):
780780
781781
.. versionadded:: 0.20.0
782782
783+
Returns
784+
-------
785+
DataFrame or Series
786+
Values at the specified freq.
787+
783788
See Also
784789
--------
785790
Series.asfreq
@@ -795,6 +800,11 @@ def std(self, ddof=1, *args, **kwargs):
795800
----------
796801
ddof : integer, default 1
797802
Degrees of freedom.
803+
804+
Returns
805+
-------
806+
DataFrame or Series
807+
Standard deviation of values within each group.
798808
"""
799809
nv.validate_resampler_func('std', args, kwargs)
800810
return self._downsample('std', ddof=ddof)
@@ -807,12 +817,23 @@ def var(self, ddof=1, *args, **kwargs):
807817
----------
808818
ddof : integer, default 1
809819
degrees of freedom
820+
821+
Returns
822+
-------
823+
DataFrame or Series
824+
Variance of values within each group.
810825
"""
811826
nv.validate_resampler_func('var', args, kwargs)
812827
return self._downsample('var', ddof=ddof)
813828

814829
@Appender(GroupBy.size.__doc__)
815830
def size(self):
831+
"""
832+
Returns
833+
-------
834+
Series
835+
Number of rows in each group.
836+
"""
816837
# It's a special case as higher level does return
817838
# a copy of 0-len objects. GH14962
818839
result = self._downsample('size')
@@ -830,6 +851,11 @@ def quantile(self, q=0.5, **kwargs):
830851
----------
831852
q : float or array-like, default 0.5 (50% quantile)
832853
854+
Returns
855+
-------
856+
DataFrame or Series
857+
Quantile of values within each group.
858+
833859
See Also
834860
--------
835861
Series.quantile

pandas/core/series.py

+35
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,11 @@ def from_array(cls, arr, index=None, name=None, dtype=None, copy=False,
319319
320320
.. deprecated :: 0.23.0
321321
Use pd.Series(..) constructor instead.
322+
323+
Returns
324+
-------
325+
Series
326+
Constructed Series.
322327
"""
323328
warnings.warn("'from_array' is deprecated and will be removed in a "
324329
"future version. Please use the pd.Series(..) "
@@ -486,6 +491,11 @@ def _formatting_values(self):
486491
def get_values(self):
487492
"""
488493
Same as values (but handles sparseness conversions); is a view.
494+
495+
Returns
496+
-------
497+
numpy.ndarray
498+
Data of the Series.
489499
"""
490500
return self._data.get_values()
491501

@@ -526,6 +536,11 @@ def compress(self, condition, *args, **kwargs):
526536
527537
.. deprecated:: 0.24.0
528538
539+
Returns
540+
-------
541+
Series
542+
Series without the slices for which condition is false.
543+
529544
See Also
530545
--------
531546
numpy.ndarray.compress
@@ -550,6 +565,11 @@ def nonzero(self):
550565
but it will always be a one-item tuple because series only have
551566
one dimension.
552567
568+
Returns
569+
-------
570+
numpy.ndarray
571+
Indices of elements that are non-zero.
572+
553573
See Also
554574
--------
555575
numpy.nonzero
@@ -1479,6 +1499,11 @@ def iteritems(self):
14791499
def keys(self):
14801500
"""
14811501
Return alias for index.
1502+
1503+
Returns
1504+
-------
1505+
Index
1506+
Index of the Series.
14821507
"""
14831508
return self.index
14841509

@@ -3943,6 +3968,11 @@ def reindex_axis(self, labels, axis=0, **kwargs):
39433968
39443969
.. deprecated:: 0.21.0
39453970
Use ``Series.reindex`` instead.
3971+
3972+
Returns
3973+
-------
3974+
Series
3975+
Reindexed Series.
39463976
"""
39473977
# for compatibility with higher dims
39483978
if axis != 0:
@@ -4406,6 +4436,11 @@ def valid(self, inplace=False, **kwargs):
44064436
44074437
.. deprecated:: 0.23.0
44084438
Use :meth:`Series.dropna` instead.
4439+
4440+
Returns
4441+
-------
4442+
Series
4443+
Series without null values.
44094444
"""
44104445
warnings.warn("Method .valid will be removed in a future version. "
44114446
"Use .dropna instead.", FutureWarning, stacklevel=2)

0 commit comments

Comments
 (0)