Skip to content

Commit 22b1ef6

Browse files
committed
DOC: make return type documentation of series methods consistent pandas-dev#35409
1 parent 40b2aa5 commit 22b1ef6

File tree

3 files changed

+36
-33
lines changed

3 files changed

+36
-33
lines changed

pandas/core/arrays/categorical.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,8 @@ def as_ordered(self, inplace=False):
723723
724724
Returns
725725
-------
726-
Categorical
727-
Ordered Categorical.
726+
Categorical or None
727+
Ordered Categorical or None if ``inplace=True``.
728728
"""
729729
inplace = validate_bool_kwarg(inplace, "inplace")
730730
return self.set_ordered(True, inplace=inplace)
@@ -741,8 +741,8 @@ def as_unordered(self, inplace=False):
741741
742742
Returns
743743
-------
744-
Categorical
745-
Unordered Categorical.
744+
Categorical or None
745+
Unordered Categorical or None if ``inplace=True``.
746746
"""
747747
inplace = validate_bool_kwarg(inplace, "inplace")
748748
return self.set_ordered(False, inplace=inplace)
@@ -848,8 +848,7 @@ def rename_categories(self, new_categories, inplace=False):
848848
Returns
849849
-------
850850
cat : Categorical or None
851-
With ``inplace=False``, the new categorical is returned.
852-
With ``inplace=True``, there is no return value.
851+
Categorical with removed categories or None if ``inplace=True``.
853852
854853
Raises
855854
------
@@ -917,7 +916,8 @@ def reorder_categories(self, new_categories, ordered=None, inplace=False):
917916
918917
Returns
919918
-------
920-
cat : Categorical with reordered categories or None if inplace.
919+
cat : Categprocal or None
920+
Categorical with removed categories or None if ``inplace=True``.
921921
922922
Raises
923923
------
@@ -957,7 +957,8 @@ def add_categories(self, new_categories, inplace=False):
957957
958958
Returns
959959
-------
960-
cat : Categorical with new categories added or None if inplace.
960+
cat : Categorical or None
961+
Categorical with new categories added or None if ``inplace=True``.
961962
962963
Raises
963964
------
@@ -1007,7 +1008,8 @@ def remove_categories(self, removals, inplace=False):
10071008
10081009
Returns
10091010
-------
1010-
cat : Categorical with removed categories or None if inplace.
1011+
cat : Categorical or None
1012+
Categorical with removed categories or None if ``inplace=True``.
10111013
10121014
Raises
10131015
------
@@ -1054,7 +1056,8 @@ def remove_unused_categories(self, inplace=False):
10541056
10551057
Returns
10561058
-------
1057-
cat : Categorical with unused categories dropped or None if inplace.
1059+
cat : Categorical or None
1060+
Categorical with unused categories dropped or None if ``inplace=True``.
10581061
10591062
See Also
10601063
--------

pandas/core/generic.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ def set_axis(self, labels, axis: Axis = 0, inplace: bool = False):
649649
Returns
650650
-------
651651
renamed : %(klass)s or None
652-
An object of type %(klass)s if inplace=False, None otherwise.
652+
An object of type %(klass)s or None if ``inplace=True``.
653653
654654
See Also
655655
--------
@@ -1096,7 +1096,7 @@ def rename_axis(self, mapper=lib.no_default, **kwargs):
10961096
Returns
10971097
-------
10981098
Series, DataFrame, or None
1099-
The same type as the caller or None if `inplace` is True.
1099+
The same type as the caller or None if ``inplace=True``.
11001100
11011101
See Also
11021102
--------
@@ -6461,8 +6461,8 @@ def replace(
64616461
64626462
Returns
64636463
-------
6464-
{klass}
6465-
Object after replacement.
6464+
{klass} or None
6465+
Object after replacement or None if ``inplace=True``.
64666466
64676467
Raises
64686468
------
@@ -6896,9 +6896,9 @@ def interpolate(
68966896
68976897
Returns
68986898
-------
6899-
Series or DataFrame
6899+
Series or DataFrame or None
69006900
Returns the same object type as the caller, interpolated at
6901-
some or all ``NaN`` values.
6901+
some or all ``NaN`` values
69026902
69036903
See Also
69046904
--------
@@ -7494,9 +7494,9 @@ def clip(
74947494
74957495
Returns
74967496
-------
7497-
Series or DataFrame
7497+
Series or DataFrame or None
74987498
Same type as calling object with the values outside the
7499-
clip boundaries replaced.
7499+
clip boundaries replaced or None if ``inplace=True``.
75007500
75017501
See Also
75027502
--------
@@ -9048,9 +9048,9 @@ def where(
90489048
try_cast : bool, default False
90499049
Try to cast the result back to the input type (if possible).
90509050
9051-
Returns
9051+
Returns or None
90529052
-------
9053-
Same type as caller
9053+
Same type as caller or None if ``inplace=True``.
90549054
90559055
See Also
90569056
--------

pandas/core/series.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ def reset_index(self, level=None, drop=False, name=None, inplace=False):
11921192
11931193
Returns
11941194
-------
1195-
Series or DataFrame
1195+
Series or DataFrame or None
11961196
When `drop` is False (the default), a DataFrame is returned.
11971197
The newly created columns will come first in the DataFrame,
11981198
followed by the original Series values.
@@ -1911,8 +1911,8 @@ def drop_duplicates(self, keep="first", inplace=False) -> Optional["Series"]:
19111911
19121912
Returns
19131913
-------
1914-
Series
1915-
Series with duplicates dropped.
1914+
Series or None
1915+
Series with duplicates dropped or None if ``inplace=True``.
19161916
19171917
See Also
19181918
--------
@@ -3129,8 +3129,8 @@ def sort_values(
31293129
31303130
Returns
31313131
-------
3132-
Series
3133-
Series ordered by values.
3132+
Series or None
3133+
Series ordered by values or None if ``inplace=True``.
31343134
31353135
See Also
31363136
--------
@@ -3375,8 +3375,8 @@ def sort_index(
33753375
33763376
Returns
33773377
-------
3378-
Series
3379-
The original Series sorted by the labels.
3378+
Series or None
3379+
The original Series sorted by the labels or None if ``inplace=True``.
33803380
33813381
See Also
33823382
--------
@@ -4304,8 +4304,8 @@ def rename(
43044304
43054305
Returns
43064306
-------
4307-
Series
4308-
Series with index labels or name altered.
4307+
Series or None
4308+
Series with index labels or name altered
43094309
43104310
See Also
43114311
--------
@@ -4418,8 +4418,8 @@ def drop(
44184418
44194419
Returns
44204420
-------
4421-
Series
4422-
Series with specified index labels removed.
4421+
Series or None
4422+
Series with specified index labels removed or None if ``inplace=True``.
44234423
44244424
Raises
44254425
------
@@ -4807,8 +4807,8 @@ def dropna(self, axis=0, inplace=False, how=None):
48074807
48084808
Returns
48094809
-------
4810-
Series
4811-
Series with NA entries dropped from it.
4810+
Series or None
4811+
Series with NA entries dropped from it or None if ``inplace=True``.
48124812
48134813
See Also
48144814
--------

0 commit comments

Comments
 (0)