From 686d2d7ec81760c0327b0e2897466912e1ba4c13 Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Sun, 10 Mar 2024 15:09:15 +0100 Subject: [PATCH 01/10] Add return information on pop method. --- pandas/core/frame.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 88fa1148c0dfc..3127202651f55 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -5473,7 +5473,7 @@ def rename( def pop(self, item: Hashable) -> Series: """ - Return item and drop from frame. Raise KeyError if not found. + Return item and drop it from DataFrame. Raise KeyError if not found. Parameters ---------- @@ -5483,6 +5483,7 @@ def pop(self, item: Hashable) -> Series: Returns ------- Series + Series representing the item that is dropped. Examples -------- From ec79f9cff7ff15640bf6fbe76605fa0d5041bad7 Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Sun, 10 Mar 2024 15:29:51 +0100 Subject: [PATCH 02/10] Add return information on reindex method. --- pandas/core/generic.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 5119e799e6de1..bf10a36ea7dda 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -583,7 +583,7 @@ def _get_index_resolvers(self) -> dict[Hashable, Series | MultiIndex]: @final def _get_cleaned_column_resolvers(self) -> dict[Hashable, Series]: """ - Return the special character free column resolvers of a dataframe. + Return the special character free column resolvers of a DataFrame. Column names with special characters are 'cleaned up' so that they can be referred to by backtick quoting. @@ -5077,7 +5077,8 @@ def reindex( Returns ------- - {klass} with changed index. + {klass} + {klass} with changed index. See Also -------- @@ -5095,7 +5096,7 @@ def reindex( We *highly* recommend using keyword arguments to clarify your intent. - Create a dataframe with some fictional data. + Create a DataFrame with some fictional data. >>> index = ["Firefox", "Chrome", "Safari", "IE10", "Konqueror"] >>> columns = ["http_status", "response_time"] @@ -5112,9 +5113,9 @@ def reindex( IE10 404 0.08 Konqueror 301 1.00 - Create a new index and reindex the dataframe. By default + Create a new index and reindex the DataFrame. By default values in the new index that do not have corresponding - records in the dataframe are assigned ``NaN``. + records in the DataFrame are assigned ``NaN``. >>> new_index = ["Safari", "Iceweasel", "Comodo Dragon", "IE10", "Chrome"] >>> df.reindex(new_index) @@ -5167,7 +5168,7 @@ def reindex( Konqueror 301 NaN To further illustrate the filling functionality in - ``reindex``, we will create a dataframe with a + ``reindex``, we will create a DataFrame with a monotonically increasing index (for example, a sequence of dates). @@ -5184,7 +5185,7 @@ def reindex( 2010-01-05 89.0 2010-01-06 88.0 - Suppose we decide to expand the dataframe to cover a wider + Suppose we decide to expand the DataFrame to cover a wider date range. >>> date_index2 = pd.date_range("12/29/2009", periods=10, freq="D") @@ -5222,12 +5223,12 @@ def reindex( 2010-01-06 88.0 2010-01-07 NaN - Please note that the ``NaN`` value present in the original dataframe + Please note that the ``NaN`` value present in the original DataFrame (at index value 2010-01-03) will not be filled by any of the value propagation schemes. This is because filling while reindexing - does not look at dataframe values, but only compares the original and + does not look at DataFrame values, but only compares the original and desired indexes. If you do want to fill in the ``NaN`` values present - in the original dataframe, use the ``fillna()`` method. + in the original DataFrame, use the ``fillna()`` method. See the :ref:`user guide ` for more. """ @@ -8373,7 +8374,7 @@ def clip( See Also -------- Series.clip : Trim values at input threshold in series. - DataFrame.clip : Trim values at input threshold in dataframe. + DataFrame.clip : Trim values at input threshold in DataFrame. numpy.clip : Clip (limit) the values in an array. Examples @@ -10909,7 +10910,7 @@ def describe( among those with the highest count. For mixed data types provided via a ``DataFrame``, the default is to - return only an analysis of numeric columns. If the dataframe consists + return only an analysis of numeric columns. If the DataFrame consists only of object and categorical data without any numeric columns, the default is to return an analysis of both the object and categorical columns. If ``include='all'`` is provided as an option, the result @@ -12052,7 +12053,7 @@ def last_valid_index(self) -> Hashable: **DataFrames** -Create a dataframe from a dictionary. +Create a DataFrame from a dictionary. >>> df = pd.DataFrame({'col1': [True, True], 'col2': [True, False]}) >>> df From 3c81b66e9eeccaa8d9432fb3761031a287052153 Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Sun, 10 Mar 2024 15:38:02 +0100 Subject: [PATCH 03/10] Add return information to reorder_levels method. --- pandas/core/frame.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 3127202651f55..d0eb4ebd36270 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -7613,7 +7613,8 @@ def swaplevel(self, i: Axis = -2, j: Axis = -1, axis: Axis = 0) -> DataFrame: def reorder_levels(self, order: Sequence[int | str], axis: Axis = 0) -> DataFrame: """ - Rearrange index levels using input order. May not drop or duplicate levels. + Rearrange index or column levels using input ``order``. + May not drop or duplicate levels. Parameters ---------- @@ -7626,6 +7627,7 @@ def reorder_levels(self, order: Sequence[int | str], axis: Axis = 0) -> DataFram Returns ------- DataFrame + DataFrame with indices or columns with reordered levels. Examples -------- From 2e1ceee11393d86ebac0383a2b48084bc342ac7e Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Sun, 10 Mar 2024 15:45:56 +0100 Subject: [PATCH 04/10] Add return information for to_numpy method. --- pandas/core/frame.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index d0eb4ebd36270..0983f3f00c127 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1883,6 +1883,7 @@ def to_numpy( Returns ------- numpy.ndarray + The NumPy array representing the values in the DataFrame. See Also -------- From 33389dfa011abde4035436b50f78e7576758e9c3 Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Sun, 10 Mar 2024 15:57:28 +0100 Subject: [PATCH 05/10] Add return information to to_orc method. --- pandas/core/frame.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 0983f3f00c127..858bff569b7a7 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2931,7 +2931,8 @@ def to_orc( engine_kwargs: dict[str, Any] | None = None, ) -> bytes | None: """ - Write a DataFrame to the ORC format. + Write a DataFrame to the `Optimized Row Columnar (ORC) + https://en.wikipedia.org/wiki/Apache_ORC>` format. .. versionadded:: 1.5.0 @@ -2958,7 +2959,8 @@ def to_orc( Returns ------- - bytes if no path argument is provided else None + bytes if no ``path`` argument is provided else None + Bytes object with DataFrame data if ``path`` is not specified else None. Raises ------ From d6063052566a8f3d9016cf8312632d8f968242ee Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Sun, 10 Mar 2024 16:00:34 +0100 Subject: [PATCH 06/10] Do not ignore fixed methods in code checks --- ci/code_checks.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index c4e43b88a0097..c994975c1a08e 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -623,18 +623,12 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.DataFrame.mean\ pandas.DataFrame.median\ pandas.DataFrame.min\ - pandas.DataFrame.pop\ pandas.DataFrame.prod\ pandas.DataFrame.product\ - pandas.DataFrame.reindex\ - pandas.DataFrame.reorder_levels\ pandas.DataFrame.sem\ pandas.DataFrame.skew\ pandas.DataFrame.std\ pandas.DataFrame.sum\ - pandas.DataFrame.swapaxes\ - pandas.DataFrame.to_numpy\ - pandas.DataFrame.to_orc\ pandas.DataFrame.to_parquet\ pandas.DataFrame.unstack\ pandas.DataFrame.value_counts\ From ea6516ce7f525a08b46c6bbb08f7275e87998383 Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Sun, 10 Mar 2024 18:54:25 +0100 Subject: [PATCH 07/10] Resolve docstring validation errors. --- pandas/core/frame.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 858bff569b7a7..d5ddb7b35bd3f 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2931,8 +2931,7 @@ def to_orc( engine_kwargs: dict[str, Any] | None = None, ) -> bytes | None: """ - Write a DataFrame to the `Optimized Row Columnar (ORC) - https://en.wikipedia.org/wiki/Apache_ORC>` format. + Write a DataFrame to the `Optimized Row Columnar (ORC) format. .. versionadded:: 1.5.0 @@ -2980,6 +2979,7 @@ def to_orc( Notes ----- + * Find more information on ORC `here ` * Before using this function you should read the :ref:`user guide about ORC ` and :ref:`install optional dependencies `. * This function requires `pyarrow `_ @@ -7617,6 +7617,7 @@ def swaplevel(self, i: Axis = -2, j: Axis = -1, axis: Axis = 0) -> DataFrame: def reorder_levels(self, order: Sequence[int | str], axis: Axis = 0) -> DataFrame: """ Rearrange index or column levels using input ``order``. + May not drop or duplicate levels. Parameters From d3997652442205045c4374eb20332c814751788d Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Sun, 10 Mar 2024 19:03:32 +0100 Subject: [PATCH 08/10] Fix errors in docstring --- pandas/core/frame.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index d5ddb7b35bd3f..80bca1787660a 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2931,7 +2931,7 @@ def to_orc( engine_kwargs: dict[str, Any] | None = None, ) -> bytes | None: """ - Write a DataFrame to the `Optimized Row Columnar (ORC) format. + Write a DataFrame to the Optimized Row Columnar (ORC) format. .. versionadded:: 1.5.0 @@ -2979,7 +2979,8 @@ def to_orc( Notes ----- - * Find more information on ORC `here ` + * Find more information on ORC + :ref:`here `. * Before using this function you should read the :ref:`user guide about ORC ` and :ref:`install optional dependencies `. * This function requires `pyarrow `_ From 2f23299fd25f4cfc9233cd1749c428bb6e4ce0cc Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Sun, 10 Mar 2024 19:44:45 +0100 Subject: [PATCH 09/10] Fix link label --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 80bca1787660a..c4d8bad6759e4 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2980,7 +2980,7 @@ def to_orc( Notes ----- * Find more information on ORC - :ref:`here `. + :ref:`here `__. * Before using this function you should read the :ref:`user guide about ORC ` and :ref:`install optional dependencies `. * This function requires `pyarrow `_ From a35376bac1f30b081cfdecb09fb5e143290251ad Mon Sep 17 00:00:00 2001 From: Jonas Bergner Date: Sun, 10 Mar 2024 19:45:53 +0100 Subject: [PATCH 10/10] Fix label link --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index c4d8bad6759e4..2a6daf4bab937 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2980,7 +2980,7 @@ def to_orc( Notes ----- * Find more information on ORC - :ref:`here `__. + `here `__. * Before using this function you should read the :ref:`user guide about ORC ` and :ref:`install optional dependencies `. * This function requires `pyarrow `_