Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
BUG: df.apply handles np.timedelta64 as timestamp, should be timedelta #7778
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? |
jreback
added Bug Dtypes Timeseries Timedelta
labels
Jul 17, 2014
jreback
added this to the
0.15.0
milestone
Jul 17, 2014
stharrold
commented
Jul 17, 2014
|
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 |
jreback
referenced
this issue
Jul 17, 2014
Merged
BUG: unwanted conversions of timedelta dtypes when in a mixed datetimelike frame (GH7778) #7779
|
@stharrold turns out this was a bit non-trivial (and needed extra testing). fixed in #7779
|
stharrold
commented
Jul 18, 2014
|
@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 |
jreback
closed this
in #7779
Jul 18, 2014
|
@stharrold thanks for the report! |
stharrold commentedJul 17, 2014
I think there may be a bug with the row-wise handling of
numpy.timedelta64data 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.itertuplesetc.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.datetime64ornumpy.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.timedelta64or another type of timedelta, not a type of datetime (timestamp).