Skip to content

DEPR: Series.round and Series.clip on non-numeric and non-object dtypes #63559

@rhshadrach

Description

@rhshadrach

Ref: #63444

Prior to the PR linked to the above issue, Series.round would raise on only object dtype and be a no-op on other dtypes that did not support rounding. The behavior is also the same for Series.clip.

ser = pd.Series(pd.Categorical([1.234], categories=[1.234]))

print(ser.abs())
# TypeError: Object with dtype category cannot perform the numpy op absolute

print(ser.round())
# 0    1.234
# dtype: category
# Categories (1, float64): [1.234]

print(ser.clip())
# 0    1.234
# dtype: category
# Categories (1, float64): [1.234]

ser = pd.Series(["a"], dtype=str)

print(ser.abs())
# pyarrow.lib.ArrowNotImplementedError: Function 'abs_checked' has no kernel matching input types (large_string)

print(ser.round())
# 0    a
# dtype: str

print(ser.clip())
# 0    a
# dtype: str

I think we should deprecate Series.round and Series.clip from being a no-op. The corresponding DataFrame methods are to still be no-ops on such columns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeprecateFunctionality to remove in pandasNeeds DiscussionRequires discussion from core team before further actionSeriesSeries data structureTransformationse.g. cumsum, diff, rank

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions