Skip to content

DOC: make return type documentation of series methods consistent #35409 #36862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 10, 2020
23 changes: 13 additions & 10 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,8 @@ def as_ordered(self, inplace=False):

Returns
-------
Categorical
Ordered Categorical.
Categorical or None
Ordered Categorical or None if ``inplace=True``.
"""
inplace = validate_bool_kwarg(inplace, "inplace")
return self.set_ordered(True, inplace=inplace)
Expand All @@ -741,8 +741,8 @@ def as_unordered(self, inplace=False):

Returns
-------
Categorical
Unordered Categorical.
Categorical or None
Unordered Categorical or None if ``inplace=True``.
"""
inplace = validate_bool_kwarg(inplace, "inplace")
return self.set_ordered(False, inplace=inplace)
Expand Down Expand Up @@ -848,8 +848,7 @@ def rename_categories(self, new_categories, inplace=False):
Returns
-------
cat : Categorical or None
With ``inplace=False``, the new categorical is returned.
With ``inplace=True``, there is no return value.
Categorical with removed categories or None if ``inplace=True``.

Raises
------
Expand Down Expand Up @@ -917,7 +916,8 @@ def reorder_categories(self, new_categories, ordered=None, inplace=False):

Returns
-------
cat : Categorical with reordered categories or None if inplace.
cat : Categprocal or None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here. Otherwise, lgtm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Done.
I start working on other docstring fixes in the same way.

Copy link
Member

@ivanovmg ivanovmg Oct 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that CI Checks complains about missing dots at the end of return statement.

6818:RT05:pandas.DataFrame.interpolate:Return value description should finish with "."

There are several of such errors.

Copy link
Contributor Author

@junjunjunk junjunjunk Oct 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry for all the mistakes. Thank you for pointing that out. Done.

Categorical with removed categories or None if ``inplace=True``.

Raises
------
Expand Down Expand Up @@ -957,7 +957,8 @@ def add_categories(self, new_categories, inplace=False):

Returns
-------
cat : Categorical with new categories added or None if inplace.
cat : Categorical or None
Categorical with new categories added or None if ``inplace=True``.

Raises
------
Expand Down Expand Up @@ -1007,7 +1008,8 @@ def remove_categories(self, removals, inplace=False):

Returns
-------
cat : Categorical with removed categories or None if inplace.
cat : Categorical or None
Categorical with removed categories or None if ``inplace=True``.

Raises
------
Expand Down Expand Up @@ -1054,7 +1056,8 @@ def remove_unused_categories(self, inplace=False):

Returns
-------
cat : Categorical with unused categories dropped or None if inplace.
cat : Categorical or None
Categorical with unused categories dropped or None if ``inplace=True``.

See Also
--------
Expand Down
18 changes: 9 additions & 9 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ def set_axis(self, labels, axis: Axis = 0, inplace: bool = False):
Returns
-------
renamed : %(klass)s or None
An object of type %(klass)s if inplace=False, None otherwise.
An object of type %(klass)s or None if ``inplace=True``.

See Also
--------
Expand Down Expand Up @@ -1096,7 +1096,7 @@ def rename_axis(self, mapper=lib.no_default, **kwargs):
Returns
-------
Series, DataFrame, or None
The same type as the caller or None if `inplace` is True.
The same type as the caller or None if ``inplace=True``.

See Also
--------
Expand Down Expand Up @@ -6461,8 +6461,8 @@ def replace(

Returns
-------
{klass}
Object after replacement.
{klass} or None
Object after replacement or None if ``inplace=True``.

Raises
------
Expand Down Expand Up @@ -6896,9 +6896,9 @@ def interpolate(

Returns
-------
Series or DataFrame
Series or DataFrame or None
Returns the same object type as the caller, interpolated at
some or all ``NaN`` values.
some or all ``NaN`` values

See Also
--------
Expand Down Expand Up @@ -7494,9 +7494,9 @@ def clip(

Returns
-------
Series or DataFrame
Series or DataFrame or None
Same type as calling object with the values outside the
clip boundaries replaced.
clip boundaries replaced or None if ``inplace=True``.

See Also
--------
Expand Down Expand Up @@ -9050,7 +9050,7 @@ def where(

Returns
-------
Same type as caller
Same type as caller or None if ``inplace=True``.

See Also
--------
Expand Down
26 changes: 13 additions & 13 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ def reset_index(self, level=None, drop=False, name=None, inplace=False):

Returns
-------
Series or DataFrame
Series or DataFrame or None
When `drop` is False (the default), a DataFrame is returned.
The newly created columns will come first in the DataFrame,
followed by the original Series values.
Expand Down Expand Up @@ -1911,8 +1911,8 @@ def drop_duplicates(self, keep="first", inplace=False) -> Optional["Series"]:

Returns
-------
Series
Series with duplicates dropped.
Series or None
Series with duplicates dropped or None if ``inplace=True``.

See Also
--------
Expand Down Expand Up @@ -3129,8 +3129,8 @@ def sort_values(

Returns
-------
Series
Series ordered by values.
Series or None
Series ordered by values or None if ``inplace=True``.

See Also
--------
Expand Down Expand Up @@ -3375,8 +3375,8 @@ def sort_index(

Returns
-------
Series
The original Series sorted by the labels.
Series or None
The original Series sorted by the labels or None if ``inplace=True``.

See Also
--------
Expand Down Expand Up @@ -4304,8 +4304,8 @@ def rename(

Returns
-------
Series
Series with index labels or name altered.
Series or None
Series with index labels or name altered

See Also
--------
Expand Down Expand Up @@ -4418,8 +4418,8 @@ def drop(

Returns
-------
Series
Series with specified index labels removed.
Series or None
Series with specified index labels removed or None if ``inplace=True``.

Raises
------
Expand Down Expand Up @@ -4807,8 +4807,8 @@ def dropna(self, axis=0, inplace=False, how=None):

Returns
-------
Series
Series with NA entries dropped from it.
Series or None
Series with NA entries dropped from it or None if ``inplace=True``.

See Also
--------
Expand Down