Skip to content

BUG: GroupBy.std floating point error #51332

@jbrockmendel

Description

@jbrockmendel
values = pd.timedelta_range("1 Day", periods=10_000).asi8
ser = pd.Series(values)
gb = ser.groupby(list(range(5)) * 2000)

result = gb.std()
expected = pd.Series([gb.get_group(i).std() for i in gb.groups])

>>> result - expected
0    192.0
1    192.0
2    192.0
3    192.0
4    192.0
dtype: float64

In the groupby std method we cast from ints to floats, which I don't think we do in the relevant Series code (in nanops). This is my best guess for the culprit in this mismatch.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions