-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Return from to_timedelta is forced to dtype timedelta64[ns]. #9040
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
Conversation
Could you please add a note about the bug fix to what's new for 0.15.2? Depending on timing I think we could still get this into 0.15.2. |
I indicated in a comment that the change needs to happen here: https://github.com/pydata/pandas/blob/master/pandas/tseries/tdi.py#L184 |
@jreback It is not obvious to me how to best do the change in tdi.py as you mentioned. This is both my first look at pandas code and first pull request, so apologies if I am fumbling. Anyways, the docstring in
But it currently returns with a dtype of
|
@ahjulstad Thanks for taking a look at this. Can you reproduce this only using |
In 0.15.1:
After my change:
|
OK, this does look like the right fix to me. I don't see how it fits in It would be great if you add this |
see the change here: jreback@e38e94f The constructor code is buggy here, not I always try to avoid using astype because if could be hiding subtle bugs. (In this case it DOES work though). |
This last test fails, though. Floating point arithmetic won't give accurate results, but I was surprised it was so much off:
The test is:
|
I would create another issue for the floating point. Their is some internal rounding that is necessary to avoid precision issues. It may be that for say h,min its too strict. |
Floating point issue raised in issue #9048. As for the astype, I have no strong opinions, of course; I just thought that since all the other main if-branches in What is really the difference between |
those dtypes are exactly the same (m8 is just a short name) |
ok this is fine. pls add a release note. and squash. ping me when green. |
OK. Please clarify what you mean with squash (git is somewhat new to me). Shall I rebase from pydata/pandas/master, and squash all my commits to a single commit with the interactive rebase functionality? Thanks for helping. From: jreback [mailto:[email protected]] ok this is fine. pls add a release note. and squash. ping me when green. — The information contained in this message may be CONFIDENTIAL and is |
@TomAugspurger but since origin (ahjulstad/pandas) has the old rework-fix-9011 branch, how can I make it accept my squashed version (that I have created locally?) I did the rebase from upstream directly, without pulling 'through' origin.
|
forces a replacement of the commits to the new ones |
a22d210
to
10e5ba8
Compare
@jreback Done. |
Return from to_timedelta is forced to dtype timedelta64[ns].
@ahjulstad thanks! |
This is a revised change, fixing the issue I experienced (issue #9011). The proper change seems to be setting the dtype to
'timedelta64[ns]'
, as was already done for the other cases in theto_timedelta
routine.I have also added more tests, and moved them to the
test_timedeltas
function (next to the other tests of the functionality of the constructor method). I have not looked too much at #8886, it is difficult for me to understand the issue.