Skip to content

Conversation

TomAugspurger
Copy link
Contributor

@TomAugspurger TomAugspurger commented Jan 7, 2020

This implements IntegerArray.to_numpy with similar semantics to BooleanArray.to_numpy. The implementation is now identical between BooleanArray & IntegerArray. #30789 will merge them.

  1. .to_numpy(dtype=float/bool/int) will raise if there are missing values
  2. .astype(float) will convert NA to NaN.

I've made a slight change from the BooleanArray implementation on master, which I'll annotate inline.

Closes #30038

@TomAugspurger TomAugspurger force-pushed the IntegerArray-to_numpy branch from b87b91c to 5156db0 Compare January 7, 2020 19:19
@TomAugspurger TomAugspurger added API - Consistency Internal Consistency of API/Behavior ExtensionArray Extending pandas with custom dtypes or arrays. labels Jan 7, 2020
@TomAugspurger TomAugspurger added this to the 1.0 milestone Jan 7, 2020
@TomAugspurger TomAugspurger added the Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate label Jan 7, 2020
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@WillAyd WillAyd merged commit 8d8ff8f into pandas-dev:master Jan 8, 2020
@WillAyd
Copy link
Member

WillAyd commented Jan 8, 2020

Thanks @TomAugspurger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API - Consistency Internal Consistency of API/Behavior 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 this pull request may close these issues.

API: how to handle NA in conversion to numpy arrays
3 participants