Skip to content

BUG: IntegerArray cannot cast from int to uint #22440

Closed
@jorisvandenbossche

Description

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

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

In [27]: s.astype('UInt32')
...
TypeError: Cannot cast array from dtype('int64') to dtype('uint32') according to the rule 'same_kind'

with numpy dtypes this works:

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

In [31]: s.astype('uint32')
Out[31]: 
0    1
1    2
2    3
3    4
dtype: uint32

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugExtensionArrayExtending pandas with custom dtypes or arrays.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions