From bf28be37fa7b1fb67f190095c9da44065b88e5ba Mon Sep 17 00:00:00 2001 From: Marc Calingo Date: Tue, 29 Oct 2019 02:18:32 -0700 Subject: [PATCH 1/3] Fix SS06 formatting errors Errors resolved: pandas.DataFrame.filter pandas.DataFrame.first pandas.DataFrame.idxmax pandas.DataFrame.idxmin pandas.DataFrame.last pandas.DataFrame.reindex pandas.DataFrame.pivot_table pandas.DataFrame.reorder_levels pandas.DataFrame.unstack pandas.DataFrame.melt --- pandas/core/frame.py | 20 +++++++++++--------- pandas/core/generic.py | 14 ++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index d7043a8cda7b2..ef0ea6c3316ed 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -5251,8 +5251,7 @@ def swaplevel(self, i=-2, j=-1, axis=0): def reorder_levels(self, order, axis=0): """ - Rearrange index levels using input order. May not drop or - duplicate levels. + Rearrange index levels using input order. May not drop or duplicate levels. Parameters ---------- @@ -5854,9 +5853,10 @@ def pivot(self, index=None, columns=None, values=None): _shared_docs[ "pivot_table" ] = """ - Create a spreadsheet-style pivot table as a DataFrame. The levels in - the pivot table will be stored in MultiIndex objects (hierarchical - indexes) on the index and columns of the result DataFrame. + Create a spreadsheet-style pivot table as a DataFrame. + + The levels in the pivot table will be stored in MultiIndex objects + (hierarchical indexes) on the index and columns of the result DataFrame. Parameters ----------%s @@ -6249,8 +6249,9 @@ def explode(self, column: Union[str, Tuple]) -> "DataFrame": def unstack(self, level=-1, fill_value=None): """ - Pivot a level of the (necessarily hierarchical) index labels, returning - a DataFrame having a new level of column labels whose inner-most level + Pivot a level of the (necessarily hierarchical) index labels. + + Returns a DataFrame having a new level of column labels whose inner-most level consists of the pivoted index labels. If the index is not a MultiIndex, the output will be a Series @@ -6312,8 +6313,7 @@ def unstack(self, level=-1, fill_value=None): _shared_docs[ "melt" ] = """ - Unpivot a DataFrame from wide format to long format, optionally - leaving identifier variables set. + Unpivot a DataFrame from wide to long format, optionally leaving identifiers set. This function is useful to massage a DataFrame into a format where one or more columns are identifier variables (`id_vars`), while all other @@ -7908,6 +7908,7 @@ def nunique(self, axis=0, dropna=True): def idxmin(self, axis=0, skipna=True): """ Return index of first occurrence of minimum over requested axis. + NA/null values are excluded. Parameters @@ -7945,6 +7946,7 @@ def idxmin(self, axis=0, skipna=True): def idxmax(self, axis=0, skipna=True): """ Return index of first occurrence of maximum over requested axis. + NA/null values are excluded. Parameters diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 81742b5337e47..61642d6388f84 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -4353,8 +4353,9 @@ def sort_index( def reindex(self, *args, **kwargs): """ - Conform %(klass)s to new index with optional filling logic, placing - NA/NaN in locations having no value in the previous index. A new object + Conform %(klass)s to new index with optional filling logic. + + Places NA/NaN in locations having no value in the previous index. A new object is produced unless the new index is equivalent to the current one and ``copy=False``. @@ -4669,8 +4670,7 @@ def _reindex_with_indexers( def filter(self, items=None, like=None, regex=None, axis=None): """ - Subset rows or columns of dataframe according to labels in - the specified index. + Subsets the dataframe rows or columns according to the specified index labels. Note that this routine does not filter a dataframe on its contents. The filter is applied to the labels of the index. @@ -8497,8 +8497,7 @@ def resample( def first(self, offset): """ - Convenience method for subsetting initial periods of time series data - based on a date offset. + Method to subset initial periods of time series data based on a date offset. Parameters ---------- @@ -8560,8 +8559,7 @@ def first(self, offset): def last(self, offset): """ - Convenience method for subsetting final periods of time series data - based on a date offset. + Method to subset final periods of time series data based on a date offset. Parameters ---------- From f089d692c2aaeb6fe8ab994158d4c2b77cbdbb57 Mon Sep 17 00:00:00 2001 From: Marc Calingo Date: Tue, 29 Oct 2019 02:34:23 -0700 Subject: [PATCH 2/3] Remove trailing whitespaces in docstring --- pandas/core/frame.py | 6 +++--- pandas/core/generic.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index ef0ea6c3316ed..5a248838810e9 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -5854,8 +5854,8 @@ def pivot(self, index=None, columns=None, values=None): "pivot_table" ] = """ Create a spreadsheet-style pivot table as a DataFrame. - - The levels in the pivot table will be stored in MultiIndex objects + + The levels in the pivot table will be stored in MultiIndex objects (hierarchical indexes) on the index and columns of the result DataFrame. Parameters @@ -6250,7 +6250,7 @@ def explode(self, column: Union[str, Tuple]) -> "DataFrame": def unstack(self, level=-1, fill_value=None): """ Pivot a level of the (necessarily hierarchical) index labels. - + Returns a DataFrame having a new level of column labels whose inner-most level consists of the pivoted index labels. diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 61642d6388f84..36d0a1c564ca3 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -4354,7 +4354,7 @@ def sort_index( def reindex(self, *args, **kwargs): """ Conform %(klass)s to new index with optional filling logic. - + Places NA/NaN in locations having no value in the previous index. A new object is produced unless the new index is equivalent to the current one and ``copy=False``. From 2834de41c4fb18ab265e2ceb95ac6b157bfa7830 Mon Sep 17 00:00:00 2001 From: Marc Calingo Date: Tue, 29 Oct 2019 08:36:18 -0700 Subject: [PATCH 3/3] Use inital infinitive verb in docstring --- 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 36d0a1c564ca3..e15332a5277b9 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -4670,7 +4670,7 @@ def _reindex_with_indexers( def filter(self, items=None, like=None, regex=None, axis=None): """ - Subsets the dataframe rows or columns according to the specified index labels. + Subset the dataframe rows or columns according to the specified index labels. Note that this routine does not filter a dataframe on its contents. The filter is applied to the labels of the index.