Skip to content

DOC: Fix quotes position in pandas.core #24158

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

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 10 additions & 8 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ def _gotitem(self, key, ndim, subset=None):
raise AbstractMethodError(self)

def aggregate(self, func, *args, **kwargs):
"""
:param func:
:param args:
:param kwargs:
:return:
"""
raise AbstractMethodError(self)

agg = aggregate
Expand Down Expand Up @@ -1254,33 +1260,29 @@ def is_unique(self):

@property
def is_monotonic(self):
"""
Return boolean if values in the object are
"""Return boolean if values in the object are
monotonic_increasing

.. versionadded:: 0.19.0

Returns
-------
is_monotonic : boolean
"""
is_monotonic : boolean"""
from pandas import Index
return Index(self).is_monotonic

is_monotonic_increasing = is_monotonic

@property
def is_monotonic_decreasing(self):
"""
Return boolean if values in the object are
"""Return boolean if values in the object are
monotonic_decreasing

.. versionadded:: 0.19.0

Returns
-------
is_monotonic_decreasing : boolean
"""
is_monotonic_decreasing : boolean"""
from pandas import Index
return Index(self).is_monotonic_decreasing

Expand Down
42 changes: 14 additions & 28 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -6030,8 +6030,7 @@ def melt(self, id_vars=None, value_vars=None, var_name=None,
# Time series-related

def diff(self, periods=1, axis=0):
"""
First discrete difference of element.
"""First discrete difference of element.

Calculates the difference of a DataFrame element compared with another
element in the DataFrame (default is the element in the same column
Expand Down Expand Up @@ -6114,8 +6113,7 @@ def diff(self, periods=1, axis=0):
2 -1.0 -1.0 -7.0
3 -1.0 -2.0 -9.0
4 -1.0 -3.0 -11.0
5 NaN NaN NaN
"""
5 NaN NaN NaN"""
bm_axis = self._get_block_manager_axis(axis)
new_data = self._data.diff(n=periods, axis=bm_axis)
return self._constructor(new_data)
Expand Down Expand Up @@ -6880,8 +6878,7 @@ def _series_round(s, decimals):
# Statistical methods, etc.

def corr(self, method='pearson', min_periods=1):
"""
Compute pairwise correlation of columns, excluding NA/null values.
"""Compute pairwise correlation of columns, excluding NA/null values.

Parameters
----------
Expand Down Expand Up @@ -6911,8 +6908,7 @@ def corr(self, method='pearson', min_periods=1):
>>> df.corr(method=histogram_intersection)
dogs cats
dogs 1.0 0.3
cats 0.3 1.0
"""
cats 0.3 1.0"""
numeric_df = self._get_numeric_data()
cols = numeric_df.columns
idx = cols.copy()
Expand Down Expand Up @@ -6955,8 +6951,7 @@ def corr(self, method='pearson', min_periods=1):
return self._constructor(correl, index=idx, columns=cols)

def cov(self, min_periods=None):
"""
Compute pairwise covariance of columns, excluding NA/null values.
"""Compute pairwise covariance of columns, excluding NA/null values.

Compute the pairwise covariance among the series of a DataFrame.
The returned data frame is the `covariance matrix
Expand Down Expand Up @@ -7045,8 +7040,7 @@ def cov(self, min_periods=None):
a b c
a 0.316741 NaN -0.150812
b NaN 1.248003 0.191417
c -0.150812 0.191417 0.895202
"""
c -0.150812 0.191417 0.895202"""
numeric_df = self._get_numeric_data()
cols = numeric_df.columns
idx = cols.copy()
Expand All @@ -7066,8 +7060,7 @@ def cov(self, min_periods=None):
return self._constructor(baseCov, index=idx, columns=cols)

def corrwith(self, other, axis=0, drop=False):
"""
Compute pairwise correlation between rows or columns of two DataFrame
"""Compute pairwise correlation between rows or columns of two DataFrame
objects.

Parameters
Expand All @@ -7080,8 +7073,7 @@ def corrwith(self, other, axis=0, drop=False):

Returns
-------
correls : Series
"""
correls : Series"""
axis = self._get_axis_number(axis)
this = self._get_numeric_data()

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

def idxmin(self, axis=0, skipna=True):
"""
Return index of first occurrence of minimum over requested axis.
"""Return index of first occurrence of minimum over requested axis.
NA/null values are excluded.

Parameters
Expand All @@ -7431,17 +7422,15 @@ def idxmin(self, axis=0, skipna=True):

See Also
--------
Series.idxmin
"""
Series.idxmin"""
axis = self._get_axis_number(axis)
indices = nanops.nanargmin(self.values, axis=axis, skipna=skipna)
index = self._get_axis(axis)
result = [index[i] if i >= 0 else np.nan for i in indices]
return Series(result, index=self._get_agg_axis(axis))

def idxmax(self, axis=0, skipna=True):
"""
Return index of first occurrence of maximum over requested axis.
"""Return index of first occurrence of maximum over requested axis.
NA/null values are excluded.

Parameters
Expand All @@ -7467,8 +7456,7 @@ def idxmax(self, axis=0, skipna=True):

See Also
--------
Series.idxmax
"""
Series.idxmax"""
axis = self._get_axis_number(axis)
indices = nanops.nanargmax(self.values, axis=axis, skipna=skipna)
index = self._get_axis(axis)
Expand Down Expand Up @@ -7574,8 +7562,7 @@ def f(s):

def quantile(self, q=0.5, axis=0, numeric_only=True,
interpolation='linear'):
"""
Return values at the given quantile over requested axis.
"""Return values at the given quantile over requested axis.

Parameters
----------
Expand Down Expand Up @@ -7640,8 +7627,7 @@ def quantile(self, q=0.5, axis=0, numeric_only=True,
See Also
--------
pandas.core.window.Rolling.quantile
numpy.percentile
"""
numpy.percentile"""
self._check_percentile(q)

data = self._get_numeric_data() if numeric_only else self
Expand Down
18 changes: 6 additions & 12 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3338,8 +3338,7 @@ def _take(self, indices, axis=0, is_copy=True):
return result

def take(self, indices, axis=0, convert=None, is_copy=True, **kwargs):
"""
Return the elements in the given *positional* indices along an axis.
"""Return the elements in the given *positional* indices along an axis.

This means that we are not indexing according to actual values in
the index attribute of the object. We are indexing according to the
Expand Down Expand Up @@ -3419,8 +3418,7 @@ class max_speed
>>> df.take([-1, -2])
name class max_speed
1 monkey mammal NaN
3 lion mammal 80.5
"""
3 lion mammal 80.5"""
if convert is not None:
msg = ("The 'convert' parameter is deprecated "
"and will be removed in a future version.")
Expand Down Expand Up @@ -5903,8 +5901,7 @@ def infer_objects(self):

def fillna(self, value=None, method=None, axis=None, inplace=False,
limit=None, downcast=None):
"""
Fill NA/NaN values using the specified method
"""Fill NA/NaN values using the specified method

Parameters
----------
Expand Down Expand Up @@ -5994,8 +5991,7 @@ def fillna(self, value=None, method=None, axis=None, inplace=False,
0 0.0 2.0 2.0 0
1 3.0 4.0 NaN 1
2 NaN 1.0 NaN 5
3 NaN 3.0 NaN 4
"""
3 NaN 3.0 NaN 4"""
inplace = validate_bool_kwarg(inplace, 'inplace')
value, method = validate_fillna_kwargs(value, method)

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

def tshift(self, periods=1, freq=None, axis=0):
"""
Shift the time index, using the index's frequency if available.
"""Shift the time index, using the index's frequency if available.

Parameters
----------
Expand All @@ -8933,8 +8928,7 @@ def tshift(self, periods=1, freq=None, axis=0):

Returns
-------
shifted : NDFrame
"""
shifted : NDFrame"""

index = self._get_axis(axis)
if freq is None:
Expand Down
17 changes: 14 additions & 3 deletions pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,9 @@ def true_and_notna(x, *args, **kwargs):
return filtered

def nunique(self, dropna=True):
""" Returns number of unique elements in the group """
"""
Returns number of unique elements in the group
"""
ids, _, _ = self.grouper.group_info

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

def value_counts(self, normalize=False, sort=True, ascending=False,
bins=None, dropna=True):

"""
:param normalize:
:param sort:
:param ascending:
:param bins:
:param dropna:
:return:
"""
from pandas.core.reshape.tile import cut
from pandas.core.reshape.merge import _get_join_indexers

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

def count(self):
""" Compute count of group, excluding missing values """
"""
Compute count of group, excluding missing values
"""
from pandas.core.dtypes.missing import _isna_ndarraylike as _isna

data, _ = self._get_data_to_aggregate()
Expand Down
27 changes: 26 additions & 1 deletion pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class providing the base-class of operations.
dtype: int64
""")

_pipe_template = """\
_pipe_template = """
Apply a function `func` with arguments to this %(klass)s object and return
the function's result.

Expand Down Expand Up @@ -716,6 +716,12 @@ def _iterate_slices(self):
yield self._selection_name, self._selected_obj

def transform(self, func, *args, **kwargs):
"""
:param func:
:param args:
:param kwargs:
:return:
"""
raise AbstractMethodError(self)

def _cumcount_array(self, ascending=True):
Expand Down Expand Up @@ -1306,6 +1312,25 @@ def last(x):
numeric_only=False)
cls.last = groupby_function('last', 'last', last_compat,
numeric_only=False)
cls.sum.__doc__ = """
sum
"""
cls.prod.__doc__ = """
prod
"""
cls.min.__doc__ = """
min
"""
cls.max.__doc__ = """
max
"""
cls.first.__doc__= """
first
"""
cls.last.__doc__="""
last
"""


@Substitution(name='groupby')
@Appender(_doc_template)
Expand Down
18 changes: 6 additions & 12 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1503,8 +1503,7 @@ def mode(self, dropna=True):
return algorithms.mode(self, dropna=dropna)

def unique(self):
"""
Return unique values of Series object.
"""Return unique values of Series object.

Uniques are returned in order of appearance. Hash table-based unique,
therefore does NOT sort.
Expand Down Expand Up @@ -1545,8 +1544,7 @@ def unique(self):
>>> pd.Series(pd.Categorical(list('baabc'), categories=list('abc'),
... ordered=True)).unique()
[b, a, c]
Categories (3, object): [a < b < c]
"""
Categories (3, object): [a < b < c]"""
result = super(Series, self).unique()

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

def nlargest(self, n=5, keep='first'):
"""
Return the largest `n` elements.
"""Return the largest `n` elements.

Parameters
----------
Expand Down Expand Up @@ -2994,13 +2991,11 @@ def nlargest(self, n=5, keep='first'):
Malta 434000
Maldives 434000
Brunei 434000
dtype: int64
"""
dtype: int64"""
return algorithms.SelectNSeries(self, n=n, keep=keep).nlargest()

def nsmallest(self, n=5, keep='first'):
"""
Return the smallest `n` elements.
"""Return the smallest `n` elements.

Parameters
----------
Expand Down Expand Up @@ -3089,8 +3084,7 @@ def nsmallest(self, n=5, keep='first'):
Nauru 11300
Tuvalu 11300
Anguilla 11300
dtype: int64
"""
dtype: int64"""
return algorithms.SelectNSeries(self, n=n, keep=keep).nsmallest()

def swaplevel(self, i=-2, j=-1, copy=True):
Expand Down
Loading