Skip to content

Commit b023837

Browse files
author
drollolo
committed
DOC: Partial fix SA04 errors in docstrings #28792
1 parent 19624de commit b023837

File tree

10 files changed

+69
-51
lines changed

10 files changed

+69
-51
lines changed

pandas/core/accessor.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ def decorator(accessor):
282282
@doc(
283283
_register_accessor,
284284
klass="DataFrame",
285-
others="register_series_accessor, register_index_accessor",
285+
others=("register_series_accessor : Register a custom accessor on Series objects.\n"
286+
"register_index_accessor : Register a custom accessor on Index objects."),
286287
)
287288
def register_dataframe_accessor(name):
288289
from pandas import DataFrame
@@ -293,7 +294,12 @@ def register_dataframe_accessor(name):
293294
@doc(
294295
_register_accessor,
295296
klass="Series",
296-
others="register_dataframe_accessor, register_index_accessor",
297+
others="""
298+
register_dataframe_accessor : Register a custom accessor on
299+
DataFrame objects.
300+
register_index_accessor : Register a custom accessor on
301+
Index objects.
302+
""",
297303
)
298304
def register_series_accessor(name):
299305
from pandas import Series
@@ -304,7 +310,8 @@ def register_series_accessor(name):
304310
@doc(
305311
_register_accessor,
306312
klass="Index",
307-
others="register_dataframe_accessor, register_series_accessor",
313+
others="""register_dataframe_accessor : Register a custom accessor on DataFrame objects.
314+
register_series_accessor : Register a custom accessor on Series objects.""",
308315
)
309316
def register_index_accessor(name):
310317
from pandas import Index

pandas/core/arrays/categorical.py

+36-36
Original file line numberDiff line numberDiff line change
@@ -416,12 +416,12 @@ def categories(self):
416416
417417
See Also
418418
--------
419-
rename_categories
420-
reorder_categories
421-
add_categories
422-
remove_categories
423-
remove_unused_categories
424-
set_categories
419+
rename_categories : Rename categories.
420+
reorder_categories : Reorder categories.
421+
add_categories : Add new categories.
422+
remove_categories : Remove the specified categories.
423+
remove_unused_categories : Remove categories which are not used.
424+
set_categories : Set the categories to the specified categories.
425425
"""
426426
return self.dtype.categories
427427

@@ -834,11 +834,11 @@ def set_categories(self, new_categories, ordered=None, rename=False, inplace=Fal
834834
835835
See Also
836836
--------
837-
rename_categories
838-
reorder_categories
839-
add_categories
840-
remove_categories
841-
remove_unused_categories
837+
rename_categories : Rename categories.
838+
reorder_categories : Reorder categories.
839+
add_categories : Add new categories.
840+
remove_categories : Remove the specified categories.
841+
remove_unused_categories : Remove categories which are not used.
842842
"""
843843
inplace = validate_bool_kwarg(inplace, "inplace")
844844
if ordered is None:
@@ -905,11 +905,11 @@ def rename_categories(self, new_categories, inplace=False):
905905
906906
See Also
907907
--------
908-
reorder_categories
909-
add_categories
910-
remove_categories
911-
remove_unused_categories
912-
set_categories
908+
reorder_categories : Reorder categories.
909+
add_categories : Add new categories.
910+
remove_categories : Remove the specified categories.
911+
remove_unused_categories : Remove categories which are not used.
912+
set_categories : Set the categories to the specified categories.
913913
914914
Examples
915915
--------
@@ -973,11 +973,11 @@ def reorder_categories(self, new_categories, ordered=None, inplace=False):
973973
974974
See Also
975975
--------
976-
rename_categories
977-
add_categories
978-
remove_categories
979-
remove_unused_categories
980-
set_categories
976+
rename_categories : Rename categories.
977+
add_categories : Add new categories.
978+
remove_categories : Remove the specified categories.
979+
remove_unused_categories : Remove categories which are not used.
980+
set_categories : Set the categories to the specified categories.
981981
"""
982982
inplace = validate_bool_kwarg(inplace, "inplace")
983983
if set(self.dtype.categories) != set(new_categories):
@@ -1013,11 +1013,11 @@ def add_categories(self, new_categories, inplace=False):
10131013
10141014
See Also
10151015
--------
1016-
rename_categories
1017-
reorder_categories
1018-
remove_categories
1019-
remove_unused_categories
1020-
set_categories
1016+
rename_categories : Rename categories.
1017+
reorder_categories : Reorder categories.
1018+
remove_categories : Remove the specified categories.
1019+
remove_unused_categories : Remove categories which are not used.
1020+
set_categories : Set the categories to the specified categories.
10211021
"""
10221022
inplace = validate_bool_kwarg(inplace, "inplace")
10231023
if not is_list_like(new_categories):
@@ -1062,11 +1062,11 @@ def remove_categories(self, removals, inplace=False):
10621062
10631063
See Also
10641064
--------
1065-
rename_categories
1066-
reorder_categories
1067-
add_categories
1068-
remove_unused_categories
1069-
set_categories
1065+
rename_categories : Rename categories.
1066+
reorder_categories : Reorder categories.
1067+
add_categories : Add new categories.
1068+
remove_unused_categories : Remove categories which are not used.
1069+
set_categories : Set the categories to the specified categories.
10701070
"""
10711071
inplace = validate_bool_kwarg(inplace, "inplace")
10721072
if not is_list_like(removals):
@@ -1104,11 +1104,11 @@ def remove_unused_categories(self, inplace=False):
11041104
11051105
See Also
11061106
--------
1107-
rename_categories
1108-
reorder_categories
1109-
add_categories
1110-
remove_categories
1111-
set_categories
1107+
rename_categories : Rename categories.
1108+
reorder_categories : Reorder categories.
1109+
add_categories : Add new categories.
1110+
remove_categories : Remove the specified categories.
1111+
set_categories : Set the categories to the specified categories.
11121112
"""
11131113
inplace = validate_bool_kwarg(inplace, "inplace")
11141114
cat = self if inplace else self.copy()

pandas/core/dtypes/dtypes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class CategoricalDtype(PandasExtensionDtype, ExtensionDtype):
194194
195195
See Also
196196
--------
197-
Categorical
197+
Categorical : Represent a categorical variable in classic R / S-plus fashion.
198198
199199
Notes
200200
-----

pandas/core/indexes/multi.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,8 @@ def to_frame(self, index=True, name=None):
15661566
15671567
See Also
15681568
--------
1569-
DataFrame
1569+
DataFrame : Two-dimensional, size-mutable, potentially heterogeneous
1570+
tabular data.
15701571
"""
15711572
from pandas import DataFrame
15721573

pandas/core/ops/docstrings.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@ def _make_flex_doc(op_name, typ):
3333
desc=op_desc["desc"],
3434
op_name=op_name,
3535
equiv=equiv,
36-
reverse=op_desc["reverse"],
3736
series_returns=op_desc["series_returns"],
3837
)
38+
if op_desc["reverse"]:
39+
doc_see_also = _see_also_reverse_SERIES.format(
40+
reverse=op_desc["reverse"],
41+
see_also_desc=op_desc["see_also_desc"],
42+
)
43+
doc_no_examples = doc_no_examples + doc_see_also
3944
if op_desc["series_examples"]:
4045
doc = doc_no_examples + op_desc["series_examples"]
4146
else:
@@ -352,6 +357,8 @@ def _make_flex_doc(op_name, typ):
352357
if reverse_op is not None:
353358
_op_descriptions[reverse_op] = _op_descriptions[key].copy()
354359
_op_descriptions[reverse_op]["reverse"] = key
360+
_op_descriptions[key]["see_also_desc"] = f"Reversed {_op_descriptions[key]['desc']}"
361+
_op_descriptions[reverse_op]["see_also_desc"] = f"Usual {_op_descriptions[key]['desc']}"
355362

356363
_flex_doc_SERIES = """
357364
Return {desc} of series and other, element-wise (binary operator `{op_name}`).
@@ -374,10 +381,12 @@ def _make_flex_doc(op_name, typ):
374381
Returns
375382
-------
376383
{series_returns}
384+
"""
377385

386+
_see_also_reverse_SERIES = """
378387
See Also
379388
--------
380-
Series.{reverse}
389+
Series.{reverse} : {see_also_desc}.
381390
"""
382391

383392
_arith_doc_FRAME = """

pandas/core/window/rolling.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1885,8 +1885,8 @@ def _validate_freq(self):
18851885
"""
18861886
See Also
18871887
--------
1888-
Series.rolling
1889-
DataFrame.rolling
1888+
pandas.Series.rolling : Series rolling.
1889+
pandas.DataFrame.rolling : DataFrame rolling.
18901890
"""
18911891
)
18921892

pandas/io/html.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ def read_html(
10361036
10371037
See Also
10381038
--------
1039-
read_csv
1039+
read_csv : Read a comma-separated values (csv) file into DataFrame.
10401040
10411041
Notes
10421042
-----

pandas/io/sql.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def read_sql_query(
313313
See Also
314314
--------
315315
read_sql_table : Read SQL database table into a DataFrame.
316-
read_sql
316+
read_sql : Read SQL query or database table into a DataFrame.
317317
318318
Notes
319319
-----

pandas/plotting/_misc.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def table(ax, data, rowLabels=None, colLabels=None, **kwargs):
2929

3030
def register():
3131
"""
32-
Register Pandas Formatters and Converters with matplotlib.
32+
Register pandas Formatters and Converters with matplotlib.
3333
3434
This function modifies the global ``matplotlib.units.registry``
3535
dictionary. Pandas adds custom converters for
@@ -43,7 +43,7 @@ def register():
4343
4444
See Also
4545
--------
46-
deregister_matplotlib_converters
46+
deregister_matplotlib_converters : Remove pandas’ formatters and converters.
4747
"""
4848
plot_backend = _get_plot_backend("matplotlib")
4949
plot_backend.register()
@@ -62,7 +62,8 @@ def deregister():
6262
6363
See Also
6464
--------
65-
register_matplotlib_converters
65+
register_matplotlib_converters : Register pandas Formatters and Converters
66+
with matplotlib.
6667
"""
6768
plot_backend = _get_plot_backend("matplotlib")
6869
plot_backend.deregister()

pandas/tseries/frequencies.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def to_offset(freq) -> Optional[DateOffset]:
9191
9292
See Also
9393
--------
94-
DateOffset
94+
DateOffset : Standard kind of date increment used for a date range.
9595
9696
Examples
9797
--------

0 commit comments

Comments
 (0)