Skip to content

BUG: std with array_manager and NaT results #51446

Closed
@rhshadrach

Description

@rhshadrach

When a reduction results in NaT, the array manager reduction assumes the output dtype is the same as the input dtype. This is not correct for std (and from what I can tell, only std is incorrect).

df = pd.DataFrame({'a': ['2022-01-01', '2022-01-02', pd.NaT, '2022-01-03']})
df['a'] = pd.to_datetime(df['a'])

result = df.std(skipna=True)
print(result)
# a   1 days
# dtype: timedelta64[ns]

result2 = df.std(skipna=False)
print(result2)
# a   NaT
# dtype: datetime64[ns]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions