Skip to content

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

@jorisvandenbossche

Description

@jorisvandenbossche

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExtensionArrayExtending pandas with custom dtypes or arrays.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions