Skip to content
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

Reverse operators on integer-NA series and numpy scalars resulting in object dtype #22024

Closed
jorisvandenbossche opened this issue Jul 23, 2018 · 5 comments
Labels
ExtensionArray Extending pandas with custom dtypes or arrays.
Milestone

Comments

@jorisvandenbossche
Copy link
Member

This is not necessarily a bug, but at least some unexpected results:

In [83]: s = pd.Series([1, 2, 3], dtype='Int64')

In [84]: s + s[0]
Out[84]: 
0    2
1    3
2    4
dtype: Int64

In [85]: s[0] + s
Out[85]: 
0    2
1    3
2    4
dtype: object

In the above s[0] is a numpy scalar, if you do a radd with a normal int, you do not get object:

In [86]: 1 + s
Out[86]: 
0    2
1    3
2    4
dtype: Int64

In [87]: type(s[0])
Out[87]: numpy.int64
@jorisvandenbossche jorisvandenbossche added the ExtensionArray Extending pandas with custom dtypes or arrays. label Jul 23, 2018
@jorisvandenbossche jorisvandenbossche added this to the 0.24.0 milestone Jul 23, 2018
@peterpanmj
Copy link
Contributor

I would like to work on a PR.

@jreback
Copy link
Contributor

jreback commented Aug 8, 2018

go for it!

peterpanmj added a commit to peterpanmj/pandas that referenced this issue Aug 10, 2018
peterpanmj added a commit to peterpanmj/pandas that referenced this issue Aug 20, 2018
peterpanmj added a commit to peterpanmj/pandas that referenced this issue Aug 20, 2018
peterpanmj added a commit to peterpanmj/pandas that referenced this issue Sep 29, 2018
@peterpanmj
Copy link
Contributor

peterpanmj commented Nov 9, 2018

The issue is resolved by some other PR. In current master it behaves just like expected. @jorisvandenbossche @jreback

In [2]: import pandas as pd

In [3]: s = pd.Series([1, 2, 3], dtype='Int64')

In [4]: s[0]
Out[4]: 1

In [5]: s[0] + s
Out[5]:
0    2
1    3
2    4
dtype: Int64

In [6]: s + s[0]
Out[6]:
0    2
1    3
2    4
dtype: Int64

@jreback
Copy link
Contributor

jreback commented Nov 9, 2018

lots of work by @jbrockmendel and others in ops likely fixed this
i believe we have good test coverage for this but pls take a look
if we do then can just close this

@TomAugspurger
Copy link
Contributor

We have #22974 for testing ops between EA and ndarrays / sequences directly (we just do series right now). So we can close this in favor of the issue for creating a base test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays.
Projects
None yet
Development

No branches or pull requests

4 participants