-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: df.apply handles np.timedelta64 as timestamp, should be timedelta #7778
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
actually this is a sympton of a more insidius issue. try I think it needs a tiny tweek (and test cases of course!). interested in a pull-request? |
Thanks for the fast response! I'll give it a go, but as a newbie this may be over my head to do in a time-efficient manner. Guess I'll start reading through http://pandas.pydata.org/developers.html ... I'll reply to this thread when I have some progress on the patch. Thanks again. |
If you have questions along the way don't hesitate to ask, we don't bite |
@stharrold turns out this was a bit non-trivial (and needed extra testing). fixed in #7779
|
@jreback Wow, that's quite a patch! Thank you! I'm glad I could help with the bug report. |
@stharrold thanks....found a couple of other odd conversions at the same time |
@stharrold thanks for the report! |
I think there may be a bug with the row-wise handling of
numpy.timedelta64
data types when usingDataFrame.apply
. As a check, the problem does not appear when usingDataFrame.applymap
. The problem may be related to #4532, but I'm unsure. I've included an example below.This is only a minor problem for my use-case, which is cross-checking timestamps from a counter/timer card. I can easily work around the issue with
DataFrame.itertuples
etc.Thank you for your time and for making such a useful package!
Example
Version
Import and check versions.
Create test data
Using subset of original raw data as example.
Compute datetimes from elapsed timedeltas, then create differential timedeltas from datetimes. All elements are either type
numpy.datetime64
ornumpy.timedelta64
.Expected behavior
With element-wise handling using
DataFrame.applymap
, all elements are correctly identified as datetimes (timestamps) or timedeltas.Bug
With row-wise handling using
DataFrame.apply
, all elements are typepandas.tslib.Timestamp
. I expected 'differential_timedeltas' to be typenumpy.timedelta64
or another type of timedelta, not a type of datetime (timestamp).The text was updated successfully, but these errors were encountered: