Skip to content

Series.diff incorrect values with uint64 #5230

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
john-granieri opened this issue Oct 15, 2013 · 3 comments
Closed

Series.diff incorrect values with uint64 #5230

john-granieri opened this issue Oct 15, 2013 · 3 comments
Labels
Dtype Conversions Unexpected or buggy dtype conversions Duplicate Report Duplicate issue or pull request

Comments

@john-granieri
Copy link

Series.diff appears to get things off with unsigned ints

s=pd.Series([1, 2, 3, 4, 5, 6], dtype='uint')  
print s
print s.shift(-1)
print s.diff(-1)  # this result is wrong, some conversion issues
print s.map(int)
print s.map(int).diff(-1) # this result is right

0    1
1    2
2    3
3    4
4    5
5    6
dtype: uint64
0     2
1     3
2     4
3     5
4     6
5   NaN
dtype: float64
0    1.844674e+19
1    1.844674e+19
2    1.844674e+19
3    1.844674e+19
4    1.844674e+19
5             NaN
dtype: float64
0    1
1    2
2    3
3    4
4    5
5    6
dtype: int64
0    -1
1    -1
2    -1
3    -1
4    -1
5   NaN
dtype: float64

(this appears to have worked correctly in an older version of pandas 0.8 and doesn't in most recent 0.12)

@jreback
Copy link
Contributor

jreback commented Oct 15, 2013

see #4899

uint64 are pretty tricky (this is actually a numpy bug)
use object dtype or better yet int65

@john-granieri
Copy link
Author

Thanks for the help, the object dtype does work. (we do try to avoid uint64 where we can (uint as well as it is upcast in many places)).

@jreback
Copy link
Contributor

jreback commented Oct 15, 2013

gr8....will be worked on in 0.14....ould welcome contributions! this is a pretty tricky issue actually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

2 participants