-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: IndexError with pandas.DataFrame.cumsum where dtype=timedelta64[ns] #57956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
original_list = func(y)
|
The problem exists in result = func(y)
result[mask] = iNaT Essentially, what this is doing is performing To fix this, you have to pass |
@phofl @mroeschke any comment on this based on #41720. I found result is 1D while mask is an array. Thus I tried
but ended up in error at
|
take |
Thanks @Aloqeely for helping me understand this. |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
A cumulative sum along the columns of a
DataFrame
withtimedelta64[ns]
types results in anIndexError
. Cumulative min and max work correctly, and product correctly results in aTypeError
, since it's not supported for timedelta.Cumulative sums work correctly for
Series
withtimedelta64[ns]
type, so this seems to be a bug inDataFrame
.This is perhaps related to #41720?
Expected Behavior
pandas.DataFrame.cumsum
on aDataFrame
withtimedelta64[ns]
columns should not erroneously raiseIndexError
and instead compute the cumulative sum, with the same effect asdf.apply(lambda s: s.cumsum())
.Installed Versions
Installed Versions
The text was updated successfully, but these errors were encountered: