Skip to content

Support None in integer_array #23224

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

Closed
TomAugspurger opened this issue Oct 18, 2018 · 0 comments · Fixed by #23237
Closed

Support None in integer_array #23224

TomAugspurger opened this issue Oct 18, 2018 · 0 comments · Fixed by #23237
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Milestone

Comments

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Oct 18, 2018

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
@TomAugspurger TomAugspurger added the ExtensionArray Extending pandas with custom dtypes or arrays. label Oct 18, 2018
@jreback jreback added this to the 0.24.0 milestone Oct 19, 2018
@jreback jreback added the Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate label Oct 19, 2018
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. Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants