Skip to content

Series of unsigned dtype can't have diff() without upcast #4899

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

Open
alvorithm opened this issue Sep 20, 2013 · 5 comments
Open

Series of unsigned dtype can't have diff() without upcast #4899

alvorithm opened this issue Sep 20, 2013 · 5 comments
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Numeric Operations Arithmetic, Comparison, and Logical operations

Comments

@alvorithm
Copy link

This is not a Pandas issue but a numpy one.
see also #5230
However, it is highly confusing and it could be appropriate to fix in Pandas by promoting uint(2^x) dtypes to int(2^(x+1)) in Series.diff().

@jreback
Copy link
Contributor

jreback commented Sep 20, 2013

yep....can be fixed

In [93]: Series(np.array([3,2,0], dtype=np.uint32))
Out[93]: 
0    3
1    2
2    0
dtype: uint32

In [94]: Series(np.array([3,2,0], dtype=np.uint32)).diff()
Out[94]: 
0           NaN
1    4294967295
2    4294967294
dtype: float64

In [95]: Series(np.array([3,2,0], dtype=np.uint16)).diff()
Out[95]: 
0      NaN
1    65535
2    65534
dtype: float64

@jtratner
Copy link
Contributor

The problem with upcasting is what you do with something like this:

Series(np.array([2 ** 63 + 10, 2 ** 63 + 5, 5], dtype='uint64')).diff()

@jreback
Copy link
Contributor

jreback commented Sep 21, 2013

yep...that should really be object even before the diff....

@OmerJog
Copy link

OmerJog commented Sep 2, 2019

was this fixed?

@TomAugspurger
Copy link
Contributor

No, it's still open.

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 Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

No branches or pull requests

6 participants