Skip to content

Commit 0df2f0d

Browse files
authored
DOC: Remove RT03 docstring errors for selected methods (#57797)
* Add return information on pop method. * Add return information on reindex method. * Add return information to reorder_levels method. * Add return information for to_numpy method. * Add return information to to_orc method. * Do not ignore fixed methods in code checks * Resolve docstring validation errors. * Fix errors in docstring * Fix link label * Fix label link
1 parent 0cc12bc commit 0df2f0d

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

ci/code_checks.sh

-6
Original file line numberDiff line numberDiff line change
@@ -623,18 +623,12 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
623623
pandas.DataFrame.mean\
624624
pandas.DataFrame.median\
625625
pandas.DataFrame.min\
626-
pandas.DataFrame.pop\
627626
pandas.DataFrame.prod\
628627
pandas.DataFrame.product\
629-
pandas.DataFrame.reindex\
630-
pandas.DataFrame.reorder_levels\
631628
pandas.DataFrame.sem\
632629
pandas.DataFrame.skew\
633630
pandas.DataFrame.std\
634631
pandas.DataFrame.sum\
635-
pandas.DataFrame.swapaxes\
636-
pandas.DataFrame.to_numpy\
637-
pandas.DataFrame.to_orc\
638632
pandas.DataFrame.to_parquet\
639633
pandas.DataFrame.unstack\
640634
pandas.DataFrame.value_counts\

pandas/core/frame.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -1883,6 +1883,7 @@ def to_numpy(
18831883
Returns
18841884
-------
18851885
numpy.ndarray
1886+
The NumPy array representing the values in the DataFrame.
18861887
18871888
See Also
18881889
--------
@@ -2930,7 +2931,7 @@ def to_orc(
29302931
engine_kwargs: dict[str, Any] | None = None,
29312932
) -> bytes | None:
29322933
"""
2933-
Write a DataFrame to the ORC format.
2934+
Write a DataFrame to the Optimized Row Columnar (ORC) format.
29342935
29352936
.. versionadded:: 1.5.0
29362937
@@ -2957,7 +2958,8 @@ def to_orc(
29572958
29582959
Returns
29592960
-------
2960-
bytes if no path argument is provided else None
2961+
bytes if no ``path`` argument is provided else None
2962+
Bytes object with DataFrame data if ``path`` is not specified else None.
29612963
29622964
Raises
29632965
------
@@ -2977,6 +2979,8 @@ def to_orc(
29772979
29782980
Notes
29792981
-----
2982+
* Find more information on ORC
2983+
`here <https://en.wikipedia.org/wiki/Apache_ORC>`__.
29802984
* Before using this function you should read the :ref:`user guide about
29812985
ORC <io.orc>` and :ref:`install optional dependencies <install.warn_orc>`.
29822986
* This function requires `pyarrow <https://arrow.apache.org/docs/python/>`_
@@ -5473,7 +5477,7 @@ def rename(
54735477

54745478
def pop(self, item: Hashable) -> Series:
54755479
"""
5476-
Return item and drop from frame. Raise KeyError if not found.
5480+
Return item and drop it from DataFrame. Raise KeyError if not found.
54775481
54785482
Parameters
54795483
----------
@@ -5483,6 +5487,7 @@ def pop(self, item: Hashable) -> Series:
54835487
Returns
54845488
-------
54855489
Series
5490+
Series representing the item that is dropped.
54865491
54875492
Examples
54885493
--------
@@ -7612,7 +7617,9 @@ def swaplevel(self, i: Axis = -2, j: Axis = -1, axis: Axis = 0) -> DataFrame:
76127617

76137618
def reorder_levels(self, order: Sequence[int | str], axis: Axis = 0) -> DataFrame:
76147619
"""
7615-
Rearrange index levels using input order. May not drop or duplicate levels.
7620+
Rearrange index or column levels using input ``order``.
7621+
7622+
May not drop or duplicate levels.
76167623
76177624
Parameters
76187625
----------
@@ -7625,6 +7632,7 @@ def reorder_levels(self, order: Sequence[int | str], axis: Axis = 0) -> DataFram
76257632
Returns
76267633
-------
76277634
DataFrame
7635+
DataFrame with indices or columns with reordered levels.
76287636
76297637
Examples
76307638
--------

pandas/core/generic.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ def _get_index_resolvers(self) -> dict[Hashable, Series | MultiIndex]:
583583
@final
584584
def _get_cleaned_column_resolvers(self) -> dict[Hashable, Series]:
585585
"""
586-
Return the special character free column resolvers of a dataframe.
586+
Return the special character free column resolvers of a DataFrame.
587587
588588
Column names with special characters are 'cleaned up' so that they can
589589
be referred to by backtick quoting.
@@ -5077,7 +5077,8 @@ def reindex(
50775077
50785078
Returns
50795079
-------
5080-
{klass} with changed index.
5080+
{klass}
5081+
{klass} with changed index.
50815082
50825083
See Also
50835084
--------
@@ -5095,7 +5096,7 @@ def reindex(
50955096
We *highly* recommend using keyword arguments to clarify your
50965097
intent.
50975098
5098-
Create a dataframe with some fictional data.
5099+
Create a DataFrame with some fictional data.
50995100
51005101
>>> index = ["Firefox", "Chrome", "Safari", "IE10", "Konqueror"]
51015102
>>> columns = ["http_status", "response_time"]
@@ -5112,9 +5113,9 @@ def reindex(
51125113
IE10 404 0.08
51135114
Konqueror 301 1.00
51145115
5115-
Create a new index and reindex the dataframe. By default
5116+
Create a new index and reindex the DataFrame. By default
51165117
values in the new index that do not have corresponding
5117-
records in the dataframe are assigned ``NaN``.
5118+
records in the DataFrame are assigned ``NaN``.
51185119
51195120
>>> new_index = ["Safari", "Iceweasel", "Comodo Dragon", "IE10", "Chrome"]
51205121
>>> df.reindex(new_index)
@@ -5167,7 +5168,7 @@ def reindex(
51675168
Konqueror 301 NaN
51685169
51695170
To further illustrate the filling functionality in
5170-
``reindex``, we will create a dataframe with a
5171+
``reindex``, we will create a DataFrame with a
51715172
monotonically increasing index (for example, a sequence
51725173
of dates).
51735174
@@ -5184,7 +5185,7 @@ def reindex(
51845185
2010-01-05 89.0
51855186
2010-01-06 88.0
51865187
5187-
Suppose we decide to expand the dataframe to cover a wider
5188+
Suppose we decide to expand the DataFrame to cover a wider
51885189
date range.
51895190
51905191
>>> date_index2 = pd.date_range("12/29/2009", periods=10, freq="D")
@@ -5222,12 +5223,12 @@ def reindex(
52225223
2010-01-06 88.0
52235224
2010-01-07 NaN
52245225
5225-
Please note that the ``NaN`` value present in the original dataframe
5226+
Please note that the ``NaN`` value present in the original DataFrame
52265227
(at index value 2010-01-03) will not be filled by any of the
52275228
value propagation schemes. This is because filling while reindexing
5228-
does not look at dataframe values, but only compares the original and
5229+
does not look at DataFrame values, but only compares the original and
52295230
desired indexes. If you do want to fill in the ``NaN`` values present
5230-
in the original dataframe, use the ``fillna()`` method.
5231+
in the original DataFrame, use the ``fillna()`` method.
52315232
52325233
See the :ref:`user guide <basics.reindexing>` for more.
52335234
"""
@@ -8373,7 +8374,7 @@ def clip(
83738374
See Also
83748375
--------
83758376
Series.clip : Trim values at input threshold in series.
8376-
DataFrame.clip : Trim values at input threshold in dataframe.
8377+
DataFrame.clip : Trim values at input threshold in DataFrame.
83778378
numpy.clip : Clip (limit) the values in an array.
83788379
83798380
Examples
@@ -10909,7 +10910,7 @@ def describe(
1090910910
among those with the highest count.
1091010911
1091110912
For mixed data types provided via a ``DataFrame``, the default is to
10912-
return only an analysis of numeric columns. If the dataframe consists
10913+
return only an analysis of numeric columns. If the DataFrame consists
1091310914
only of object and categorical data without any numeric columns, the
1091410915
default is to return an analysis of both the object and categorical
1091510916
columns. If ``include='all'`` is provided as an option, the result
@@ -12052,7 +12053,7 @@ def last_valid_index(self) -> Hashable:
1205212053
1205312054
**DataFrames**
1205412055
12055-
Create a dataframe from a dictionary.
12056+
Create a DataFrame from a dictionary.
1205612057
1205712058
>>> df = pd.DataFrame({'col1': [True, True], 'col2': [True, False]})
1205812059
>>> df

0 commit comments

Comments
 (0)