Skip to content

Support None in integer_array #23224

@TomAugspurger

Description

@TomAugspurger

It mostly works

In [1]: import pandas as pd In [2]: pd.core.arrays.integer_array([0, 1, None]) Out[2]: IntegerArray([0, 1, nan], dtype='Int64')

aside from

In [3]: pd.core.arrays.integer_array([None]) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-3-1010251caa97> in <module> ----> 1 pd.core.arrays.integer_array([None]) ~/sandbox/pandas/pandas/core/arrays/integer.py in integer_array(values, dtype, copy) 104 TypeError if incompatible types 105 """ --> 106 values, mask = coerce_to_array(values, dtype=dtype, copy=copy) 107 return IntegerArray(values, mask) 108 ~/sandbox/pandas/pandas/core/arrays/integer.py in coerce_to_array(values, dtype, mask, copy) 177 'mixed-integer', 'mixed-integer-float']: 178 raise TypeError("{} cannot be converted to an IntegerDtype".format( --> 179 values.dtype)) 180 181 elif not (is_integer_dtype(values) or is_float_dtype(values)): TypeError: object cannot be converted to an IntegerDtype

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExtensionArrayExtending pandas with custom dtypes or arrays.Missing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions