From 27b5ac53bc210b8678ebaf3bb81bdf908e7f2bdb Mon Sep 17 00:00:00 2001 From: Joaq Date: Thu, 31 Oct 2019 00:41:09 +0800 Subject: [PATCH 1/4] Fix summary docstrings Summary docstrings formatted to one line and split to extended summary for longer summaries. pandas.DataFrame pandas.DataFrame.transform pandas.DataFrame.corrwith pandas.DataFrame.describe pandas.DataFrame.kurt pandas.DataFrame.kurtosis pandas.DataFrame.skew pandas.DataFrame.align pandas.DataFrame.drop_duplicates pandas.DataFrame.duplicated --- pandas/core/frame.py | 17 ++++++++++------- pandas/core/generic.py | 23 +++++++++++++---------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index f2606ce1b0d61..8550feff65e00 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -310,6 +310,8 @@ class DataFrame(NDFrame): """ + Two-dimensional size-mutable, potentially heterogeneous tabular data structure. + Two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Arithmetic operations align on both row and column labels. Can be thought of as a dict-like @@ -4798,8 +4800,9 @@ def dropna(self, axis=0, how="any", thresh=None, subset=None, inplace=False): def drop_duplicates(self, subset=None, keep="first", inplace=False): """ - Return DataFrame with duplicate rows removed, optionally only - considering certain columns. Indexes, including time indexes + Return DataFrame with duplicate rows removed. + + Considering certain columns is optional. Indexes, including time indexes are ignored. Parameters @@ -4834,8 +4837,7 @@ def drop_duplicates(self, subset=None, keep="first", inplace=False): def duplicated(self, subset=None, keep="first"): """ - Return boolean Series denoting duplicate rows, optionally only - considering certain columns. + Return boolean Series denoting duplicate rows, optionally only considering certain columns. Parameters ---------- @@ -7536,9 +7538,10 @@ def cov(self, min_periods=None): def corrwith(self, other, axis=0, drop=False, method="pearson"): """ - Compute pairwise correlation between rows or columns of DataFrame - with rows or columns of Series or DataFrame. DataFrames are first - aligned along both axes before computing the correlations. + Compute pairwise correlation between rows or columns of DataFrame with rows or columns of Series or DataFrame. + + DataFrames are first aligned along both axes before computing the + correlations. Parameters ---------- diff --git a/pandas/core/generic.py b/pandas/core/generic.py index e15332a5277b9..21d8bbe6a4a70 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -5156,8 +5156,9 @@ def pipe(self, func, *args, **kwargs): _shared_docs[ "transform" ] = """ - Call ``func`` on self producing a %(klass)s with transformed values - and that has the same axis length as self. + Call ``func`` on self producing a %(klass)s with transformed values. + + Produced %(klass)s will have same axis length as self. Parameters ---------- @@ -8741,8 +8742,7 @@ def ranker(data): _shared_docs[ "align" ] = """ - Align two objects on their axes with the - specified join method for each axis Index. + Align two objects on their axes with the specified join method for each axis Index. Parameters ---------- @@ -9965,9 +9965,11 @@ def abs(self): def describe(self, percentiles=None, include=None, exclude=None): """ - Generate descriptive statistics that summarize the central tendency, - dispersion and shape of a dataset's distribution, excluding - ``NaN`` values. + Generate descriptive statistics. + + Descriptive statistics include those that summarize the central + tendency, dispersion and shape of a + dataset's distribution, excluding ``NaN`` values. Analyzes both numeric and object series, as well as ``DataFrame`` column sets of mixed data types. The output @@ -10649,7 +10651,7 @@ def compound(self, axis=None, skipna=None, level=None): name, name2, axis_descr, - "Return unbiased skew over requested axis\nNormalized by N-1.", + "Return unbiased skew over requested axis.\n\nNormalized by N-1.", nanops.nanskew, ) cls.kurt = _make_stat_function( @@ -10658,8 +10660,9 @@ def compound(self, axis=None, skipna=None, level=None): name, name2, axis_descr, - "Return unbiased kurtosis over requested axis using Fisher's " - "definition of\nkurtosis (kurtosis of normal == 0.0). Normalized " + "Return unbiased kurtosis over requested axis.\n\n" + "Kurtosis obtained using Fisher's definition of\n" + "kurtosis (kurtosis of normal == 0.0). Normalized " "by N-1.", nanops.nankurt, ) From aabdb30495e435f1e8624e4032854b1561795105 Mon Sep 17 00:00:00 2001 From: Joaq Date: Thu, 31 Oct 2019 00:45:10 +0800 Subject: [PATCH 2/4] Fix redundancies --- pandas/core/frame.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 8550feff65e00..20c30bcf28243 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -310,12 +310,11 @@ class DataFrame(NDFrame): """ - Two-dimensional size-mutable, potentially heterogeneous tabular data structure. + Two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). . - Two-dimensional size-mutable, potentially heterogeneous tabular data - structure with labeled axes (rows and columns). Arithmetic operations - align on both row and column labels. Can be thought of as a dict-like - container for Series objects. The primary pandas data structure. + Arithmetic operations align on both row and column labels. Can be + thought of as a dict-like container for Series objects. The primary + pandas data structure. Parameters ---------- From a2f7455f2b5c024e80f190d3eb4db28661e8fb10 Mon Sep 17 00:00:00 2001 From: Joaq Date: Thu, 31 Oct 2019 00:54:30 +0800 Subject: [PATCH 3/4] Fix PEP-8 errors --- pandas/core/frame.py | 13 +++++++++---- pandas/core/generic.py | 6 ++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 20c30bcf28243..40efc4c65476a 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -310,8 +310,9 @@ class DataFrame(NDFrame): """ - Two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). . + Two-dimensional, size-mutable, potentially heterogeneous tabular data. + Data structure also contains labeled axes (rows and columns). Arithmetic operations align on both row and column labels. Can be thought of as a dict-like container for Series objects. The primary pandas data structure. @@ -4836,7 +4837,9 @@ def drop_duplicates(self, subset=None, keep="first", inplace=False): def duplicated(self, subset=None, keep="first"): """ - Return boolean Series denoting duplicate rows, optionally only considering certain columns. + Return boolean Series denoting duplicate rows. + + Considering certain columns is optional. Parameters ---------- @@ -7537,9 +7540,11 @@ def cov(self, min_periods=None): def corrwith(self, other, axis=0, drop=False, method="pearson"): """ - Compute pairwise correlation between rows or columns of DataFrame with rows or columns of Series or DataFrame. + Compute pairwise correlation. - DataFrames are first aligned along both axes before computing the + Pairwise correlation is computed between rows or columns of + DataFrame with rows or columns of Series or DataFrame. DataFrames + are first aligned along both axes before computing the correlations. Parameters diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 21d8bbe6a4a70..d5d7b38700084 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -5157,7 +5157,7 @@ def pipe(self, func, *args, **kwargs): "transform" ] = """ Call ``func`` on self producing a %(klass)s with transformed values. - + Produced %(klass)s will have same axis length as self. Parameters @@ -8742,7 +8742,9 @@ def ranker(data): _shared_docs[ "align" ] = """ - Align two objects on their axes with the specified join method for each axis Index. + Align two objects on their axes with the specified join method. + + Join method is specified for each axis Index. Parameters ---------- From f848117b79a7c3bf8c4a53944ed7004bb40871d7 Mon Sep 17 00:00:00 2001 From: Joaq Date: Thu, 31 Oct 2019 00:56:46 +0800 Subject: [PATCH 4/4] Whitespace error --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index d5d7b38700084..f88c26c7bc782 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -8743,7 +8743,7 @@ def ranker(data): "align" ] = """ Align two objects on their axes with the specified join method. - + Join method is specified for each axis Index. Parameters