Skip to content

Commit e4d49e3

Browse files
committed
fix issue pandas-dev#24071
1 parent 08395af commit e4d49e3

File tree

8 files changed

+81
-69
lines changed

8 files changed

+81
-69
lines changed

pandas/core/base.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ def _gotitem(self, key, ndim, subset=None):
291291
raise AbstractMethodError(self)
292292

293293
def aggregate(self, func, *args, **kwargs):
294+
"""
295+
:param func:
296+
:param args:
297+
:param kwargs:
298+
:return:
299+
"""
294300
raise AbstractMethodError(self)
295301

296302
agg = aggregate
@@ -1254,33 +1260,29 @@ def is_unique(self):
12541260

12551261
@property
12561262
def is_monotonic(self):
1257-
"""
1258-
Return boolean if values in the object are
1263+
"""Return boolean if values in the object are
12591264
monotonic_increasing
12601265
12611266
.. versionadded:: 0.19.0
12621267
12631268
Returns
12641269
-------
1265-
is_monotonic : boolean
1266-
"""
1270+
is_monotonic : boolean"""
12671271
from pandas import Index
12681272
return Index(self).is_monotonic
12691273

12701274
is_monotonic_increasing = is_monotonic
12711275

12721276
@property
12731277
def is_monotonic_decreasing(self):
1274-
"""
1275-
Return boolean if values in the object are
1278+
"""Return boolean if values in the object are
12761279
monotonic_decreasing
12771280
12781281
.. versionadded:: 0.19.0
12791282
12801283
Returns
12811284
-------
1282-
is_monotonic_decreasing : boolean
1283-
"""
1285+
is_monotonic_decreasing : boolean"""
12841286
from pandas import Index
12851287
return Index(self).is_monotonic_decreasing
12861288

pandas/core/frame.py

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6030,8 +6030,7 @@ def melt(self, id_vars=None, value_vars=None, var_name=None,
60306030
# Time series-related
60316031

60326032
def diff(self, periods=1, axis=0):
6033-
"""
6034-
First discrete difference of element.
6033+
"""First discrete difference of element.
60356034
60366035
Calculates the difference of a DataFrame element compared with another
60376036
element in the DataFrame (default is the element in the same column
@@ -6114,8 +6113,7 @@ def diff(self, periods=1, axis=0):
61146113
2 -1.0 -1.0 -7.0
61156114
3 -1.0 -2.0 -9.0
61166115
4 -1.0 -3.0 -11.0
6117-
5 NaN NaN NaN
6118-
"""
6116+
5 NaN NaN NaN"""
61196117
bm_axis = self._get_block_manager_axis(axis)
61206118
new_data = self._data.diff(n=periods, axis=bm_axis)
61216119
return self._constructor(new_data)
@@ -6880,8 +6878,7 @@ def _series_round(s, decimals):
68806878
# Statistical methods, etc.
68816879

68826880
def corr(self, method='pearson', min_periods=1):
6883-
"""
6884-
Compute pairwise correlation of columns, excluding NA/null values.
6881+
"""Compute pairwise correlation of columns, excluding NA/null values.
68856882
68866883
Parameters
68876884
----------
@@ -6911,8 +6908,7 @@ def corr(self, method='pearson', min_periods=1):
69116908
>>> df.corr(method=histogram_intersection)
69126909
dogs cats
69136910
dogs 1.0 0.3
6914-
cats 0.3 1.0
6915-
"""
6911+
cats 0.3 1.0"""
69166912
numeric_df = self._get_numeric_data()
69176913
cols = numeric_df.columns
69186914
idx = cols.copy()
@@ -6955,8 +6951,7 @@ def corr(self, method='pearson', min_periods=1):
69556951
return self._constructor(correl, index=idx, columns=cols)
69566952

69576953
def cov(self, min_periods=None):
6958-
"""
6959-
Compute pairwise covariance of columns, excluding NA/null values.
6954+
"""Compute pairwise covariance of columns, excluding NA/null values.
69606955
69616956
Compute the pairwise covariance among the series of a DataFrame.
69626957
The returned data frame is the `covariance matrix
@@ -7045,8 +7040,7 @@ def cov(self, min_periods=None):
70457040
a b c
70467041
a 0.316741 NaN -0.150812
70477042
b NaN 1.248003 0.191417
7048-
c -0.150812 0.191417 0.895202
7049-
"""
7043+
c -0.150812 0.191417 0.895202"""
70507044
numeric_df = self._get_numeric_data()
70517045
cols = numeric_df.columns
70527046
idx = cols.copy()
@@ -7066,8 +7060,7 @@ def cov(self, min_periods=None):
70667060
return self._constructor(baseCov, index=idx, columns=cols)
70677061

70687062
def corrwith(self, other, axis=0, drop=False):
7069-
"""
7070-
Compute pairwise correlation between rows or columns of two DataFrame
7063+
"""Compute pairwise correlation between rows or columns of two DataFrame
70717064
objects.
70727065
70737066
Parameters
@@ -7080,8 +7073,7 @@ def corrwith(self, other, axis=0, drop=False):
70807073
70817074
Returns
70827075
-------
7083-
correls : Series
7084-
"""
7076+
correls : Series"""
70857077
axis = self._get_axis_number(axis)
70867078
this = self._get_numeric_data()
70877079

@@ -7404,8 +7396,7 @@ def nunique(self, axis=0, dropna=True):
74047396
return self.apply(Series.nunique, axis=axis, dropna=dropna)
74057397

74067398
def idxmin(self, axis=0, skipna=True):
7407-
"""
7408-
Return index of first occurrence of minimum over requested axis.
7399+
"""Return index of first occurrence of minimum over requested axis.
74097400
NA/null values are excluded.
74107401
74117402
Parameters
@@ -7431,17 +7422,15 @@ def idxmin(self, axis=0, skipna=True):
74317422
74327423
See Also
74337424
--------
7434-
Series.idxmin
7435-
"""
7425+
Series.idxmin"""
74367426
axis = self._get_axis_number(axis)
74377427
indices = nanops.nanargmin(self.values, axis=axis, skipna=skipna)
74387428
index = self._get_axis(axis)
74397429
result = [index[i] if i >= 0 else np.nan for i in indices]
74407430
return Series(result, index=self._get_agg_axis(axis))
74417431

74427432
def idxmax(self, axis=0, skipna=True):
7443-
"""
7444-
Return index of first occurrence of maximum over requested axis.
7433+
"""Return index of first occurrence of maximum over requested axis.
74457434
NA/null values are excluded.
74467435
74477436
Parameters
@@ -7467,8 +7456,7 @@ def idxmax(self, axis=0, skipna=True):
74677456
74687457
See Also
74697458
--------
7470-
Series.idxmax
7471-
"""
7459+
Series.idxmax"""
74727460
axis = self._get_axis_number(axis)
74737461
indices = nanops.nanargmax(self.values, axis=axis, skipna=skipna)
74747462
index = self._get_axis(axis)
@@ -7574,8 +7562,7 @@ def f(s):
75747562

75757563
def quantile(self, q=0.5, axis=0, numeric_only=True,
75767564
interpolation='linear'):
7577-
"""
7578-
Return values at the given quantile over requested axis.
7565+
"""Return values at the given quantile over requested axis.
75797566
75807567
Parameters
75817568
----------
@@ -7640,8 +7627,7 @@ def quantile(self, q=0.5, axis=0, numeric_only=True,
76407627
See Also
76417628
--------
76427629
pandas.core.window.Rolling.quantile
7643-
numpy.percentile
7644-
"""
7630+
numpy.percentile"""
76457631
self._check_percentile(q)
76467632

76477633
data = self._get_numeric_data() if numeric_only else self

pandas/core/generic.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3338,8 +3338,7 @@ def _take(self, indices, axis=0, is_copy=True):
33383338
return result
33393339

33403340
def take(self, indices, axis=0, convert=None, is_copy=True, **kwargs):
3341-
"""
3342-
Return the elements in the given *positional* indices along an axis.
3341+
"""Return the elements in the given *positional* indices along an axis.
33433342
33443343
This means that we are not indexing according to actual values in
33453344
the index attribute of the object. We are indexing according to the
@@ -3419,8 +3418,7 @@ class max_speed
34193418
>>> df.take([-1, -2])
34203419
name class max_speed
34213420
1 monkey mammal NaN
3422-
3 lion mammal 80.5
3423-
"""
3421+
3 lion mammal 80.5"""
34243422
if convert is not None:
34253423
msg = ("The 'convert' parameter is deprecated "
34263424
"and will be removed in a future version.")
@@ -5903,8 +5901,7 @@ def infer_objects(self):
59035901

59045902
def fillna(self, value=None, method=None, axis=None, inplace=False,
59055903
limit=None, downcast=None):
5906-
"""
5907-
Fill NA/NaN values using the specified method
5904+
"""Fill NA/NaN values using the specified method
59085905
59095906
Parameters
59105907
----------
@@ -5994,8 +5991,7 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
59945991
0 0.0 2.0 2.0 0
59955992
1 3.0 4.0 NaN 1
59965993
2 NaN 1.0 NaN 5
5997-
3 NaN 3.0 NaN 4
5998-
"""
5994+
3 NaN 3.0 NaN 4"""
59995995
inplace = validate_bool_kwarg(inplace, 'inplace')
60005996
value, method = validate_fillna_kwargs(value, method)
60015997

@@ -8913,8 +8909,7 @@ def slice_shift(self, periods=1, axis=0):
89138909
return new_obj.__finalize__(self)
89148910

89158911
def tshift(self, periods=1, freq=None, axis=0):
8916-
"""
8917-
Shift the time index, using the index's frequency if available.
8912+
"""Shift the time index, using the index's frequency if available.
89188913
89198914
Parameters
89208915
----------
@@ -8933,8 +8928,7 @@ def tshift(self, periods=1, freq=None, axis=0):
89338928
89348929
Returns
89358930
-------
8936-
shifted : NDFrame
8937-
"""
8931+
shifted : NDFrame"""
89388932

89398933
index = self._get_axis(axis)
89408934
if freq is None:

pandas/core/groupby/generic.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,9 @@ def true_and_notna(x, *args, **kwargs):
10201020
return filtered
10211021

10221022
def nunique(self, dropna=True):
1023-
""" Returns number of unique elements in the group """
1023+
"""
1024+
Returns number of unique elements in the group
1025+
"""
10241026
ids, _, _ = self.grouper.group_info
10251027

10261028
val = self.obj.get_values()
@@ -1083,7 +1085,14 @@ def describe(self, **kwargs):
10831085

10841086
def value_counts(self, normalize=False, sort=True, ascending=False,
10851087
bins=None, dropna=True):
1086-
1088+
"""
1089+
:param normalize:
1090+
:param sort:
1091+
:param ascending:
1092+
:param bins:
1093+
:param dropna:
1094+
:return:
1095+
"""
10871096
from pandas.core.reshape.tile import cut
10881097
from pandas.core.reshape.merge import _get_join_indexers
10891098

@@ -1490,7 +1499,9 @@ def _fill(self, direction, limit=None):
14901499
return concat((self._wrap_transformed_output(output), res), axis=1)
14911500

14921501
def count(self):
1493-
""" Compute count of group, excluding missing values """
1502+
"""
1503+
Compute count of group, excluding missing values
1504+
"""
14941505
from pandas.core.dtypes.missing import _isna_ndarraylike as _isna
14951506

14961507
data, _ = self._get_data_to_aggregate()

pandas/core/groupby/groupby.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class providing the base-class of operations.
167167
dtype: int64
168168
""")
169169

170-
_pipe_template = """\
170+
_pipe_template = """
171171
Apply a function `func` with arguments to this %(klass)s object and return
172172
the function's result.
173173
@@ -716,6 +716,12 @@ def _iterate_slices(self):
716716
yield self._selection_name, self._selected_obj
717717

718718
def transform(self, func, *args, **kwargs):
719+
"""
720+
:param func:
721+
:param args:
722+
:param kwargs:
723+
:return:
724+
"""
719725
raise AbstractMethodError(self)
720726

721727
def _cumcount_array(self, ascending=True):
@@ -1306,6 +1312,25 @@ def last(x):
13061312
numeric_only=False)
13071313
cls.last = groupby_function('last', 'last', last_compat,
13081314
numeric_only=False)
1315+
cls.sum.__doc__ = """
1316+
sum
1317+
"""
1318+
cls.prod.__doc__ = """
1319+
prod
1320+
"""
1321+
cls.min.__doc__ = """
1322+
min
1323+
"""
1324+
cls.max.__doc__ = """
1325+
max
1326+
"""
1327+
cls.first.__doc__= """
1328+
first
1329+
"""
1330+
cls.last.__doc__="""
1331+
last
1332+
"""
1333+
13091334

13101335
@Substitution(name='groupby')
13111336
@Appender(_doc_template)

pandas/core/series.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,8 +1503,7 @@ def mode(self, dropna=True):
15031503
return algorithms.mode(self, dropna=dropna)
15041504

15051505
def unique(self):
1506-
"""
1507-
Return unique values of Series object.
1506+
"""Return unique values of Series object.
15081507
15091508
Uniques are returned in order of appearance. Hash table-based unique,
15101509
therefore does NOT sort.
@@ -1545,8 +1544,7 @@ def unique(self):
15451544
>>> pd.Series(pd.Categorical(list('baabc'), categories=list('abc'),
15461545
... ordered=True)).unique()
15471546
[b, a, c]
1548-
Categories (3, object): [a < b < c]
1549-
"""
1547+
Categories (3, object): [a < b < c]"""
15501548
result = super(Series, self).unique()
15511549

15521550
if is_datetime64tz_dtype(self.dtype):
@@ -2903,8 +2901,7 @@ def argsort(self, axis=0, kind='quicksort', order=None):
29032901
dtype='int64').__finalize__(self)
29042902

29052903
def nlargest(self, n=5, keep='first'):
2906-
"""
2907-
Return the largest `n` elements.
2904+
"""Return the largest `n` elements.
29082905
29092906
Parameters
29102907
----------
@@ -2994,13 +2991,11 @@ def nlargest(self, n=5, keep='first'):
29942991
Malta 434000
29952992
Maldives 434000
29962993
Brunei 434000
2997-
dtype: int64
2998-
"""
2994+
dtype: int64"""
29992995
return algorithms.SelectNSeries(self, n=n, keep=keep).nlargest()
30002996

30012997
def nsmallest(self, n=5, keep='first'):
3002-
"""
3003-
Return the smallest `n` elements.
2998+
"""Return the smallest `n` elements.
30042999
30053000
Parameters
30063001
----------
@@ -3089,8 +3084,7 @@ def nsmallest(self, n=5, keep='first'):
30893084
Nauru 11300
30903085
Tuvalu 11300
30913086
Anguilla 11300
3092-
dtype: int64
3093-
"""
3087+
dtype: int64"""
30943088
return algorithms.SelectNSeries(self, n=n, keep=keep).nsmallest()
30953089

30963090
def swaplevel(self, i=-2, j=-1, copy=True):

0 commit comments

Comments
 (0)