Skip to content

FIX DataFrame diff with timedelta #7280

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

Closed
wants to merge 1 commit into from
Closed

Conversation

hayd
Copy link
Contributor

@hayd hayd commented May 29, 2014

fixes #4533

need to fix test in numpy 1.6...

@hayd hayd added this to the 0.14.1 milestone May 29, 2014
@jreback
Copy link
Contributor

jreback commented May 29, 2014

hmm seems a bit special casey

@hayd
Copy link
Contributor Author

hayd commented May 29, 2014

true, perhaps better to change the dtype of arr_out / view, but couldn't get that to work...

@jreback
Copy link
Contributor

jreback commented May 29, 2014

I think you need to set the dtype of out_arr in the if block (e.g. if its float/int/datetime64/timedelta64) as it needs to be i8 (then you take a view before you return it, so need to remember to do that)

e.g. return out_arr.view('timedelta64[ns]')

@jreback
Copy link
Contributor

jreback commented Jun 19, 2014

@hayd ?

1 similar comment
@jreback
Copy link
Contributor

jreback commented Jun 22, 2014

@hayd ?

@jreback jreback modified the milestones: 0.15.0, 0.14.1, 0.15.1 Jul 1, 2014
@jreback
Copy link
Contributor

jreback commented Jul 21, 2014

@hayd ?

@hayd hayd self-assigned this Jul 21, 2014
@hayd
Copy link
Contributor Author

hayd commented Jul 21, 2014

@jreback Did you think this was too special casey? (will change the view dtype and see if this passes).

@jreback
Copy link
Contributor

jreback commented Jul 21, 2014

@hayd it might be, but not sure how can avoid this, timedelta is ITSELF special casey (integer and datelike at the same time)

@hayd
Copy link
Contributor Author

hayd commented Jul 21, 2014

@jreback ok cool, in general it's good to be uncomfortable/point out/whine about special casey-ness. :)

@@ -813,7 +813,8 @@ def diff(arr, n, axis=0):
na_indexer[axis] = slice(None, n) if n >= 0 else slice(n, None)
out_arr[tuple(na_indexer)] = na

if arr.ndim == 2 and arr.dtype.name in _diff_special:
if (arr.ndim == 2 and arr.dtype.name in _diff_special
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I would do this slightly differently. I would define the dtype of out_arr (as the same as the input type), except for datetime64[ns], then I think you can use this as is.

@jreback
Copy link
Contributor

jreback commented Sep 9, 2014

closing this as picking it up in #8184

@jreback jreback closed this Sep 9, 2014
@hayd
Copy link
Contributor Author

hayd commented Sep 9, 2014

thanks @jreback, sorry for dropping the ball on a few PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Reshaping Concat, Merge/Join, Stack/Unstack, Explode Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: diff on a DataFrame with a datelike broken
2 participants