Closed
Description
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]