Skip to content

rolling casts int to float unnecessarily #15599

Closed
@mwiebusch78

Description

@mwiebusch78

Take the following example:

>>> df = pd.DataFrame(list(range(5)))
>>> df
   0
0  0
1  1
2  2
3  3
4  4
>>> df.rolling(3, min_periods=1).sum()
     0
0  0.0
1  1.0
2  3.0
3  6.0
4  9.0

There is no need to cast the ints to floats in this case since no NaNs have to be substituted for missing values when min_periods=1. I think it would make sense to treat the case min_periods<=1 separately to prevent unnecessary type conversions like this one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Dtype ConversionsUnexpected or buggy dtype conversionsEnhancementMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolateNumeric OperationsArithmetic, Comparison, and Logical operationsReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions