Skip to content

ENH: fill_value argument for shift #15486

Closed
@adbull

Description

@adbull

Feature Request

At the moment, the Series/DataFrame shift methods always fill with nans, which causes an upcast for boolean/integer types. In cases where there is an appropriate non-nan fill value, it would be useful to provide this value in shift, rather than having to correctly downcast the result. This would presumably also be more efficient than .shift().fillna() in those cases where no upcast is required.

Example Code

>>> pd.Series([True]).shift(fill_value=False)
0    False
dtype: bool

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions