-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Align ExtensionArray with abc.Sequence #28770
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
Comments
@WillAyd do you know how numpy arrays do that? |
Numpy arrays resolve to |
For this specific case, don't we have some kind of Personally, I am a bit hesitant to add |
So you wouldn't consider an ExtensionArray to be a type of Sequence, right? Ignoring typing for a second it seems intuitive to me that an ExtensionArray is inherently a Sequence, and if that is true then it would make sense to adhere to the interface as defined by Python |
Somewhat relevant discussions in numpy about this: numpy/numpy#2776 and numpy/numpy#7315 (although they have other issues that complicate things). Yes, I would consider an EA as a sequence. I mainly find it a bit unfortunate that Python defines methods (count, index) that are not essential for sequence as part of the abc. |
Nice find - I'll give it a deeper look later. FWIW I don't know if we'd necessarily even need to define count or index - I think inheriting from the ABC will take care of that for us (haven't verified) |
Removing Needs Discussion label and replacing with good first issue as I think we are aligned and can probably be done easy by community, though if you disagree @jorisvandenbossche lmk |
One other concern that is that adding |
The mental clash with our NDFrame methods is unfortunate. I think |
Hey, coming to this discussion from the numpy issues, and thinking about how numpy arrays and pandas Series fit in terms of Wanted to leave a few thoughts in case it's helpful--it seems like a kind of tricky issue, since a Series sits sort of between a couple What is an
|
ref #28762 (comment)
Right now the ExtensionArray is missing a few methods that would allow it to align with the
abc.Sequence
interface, namelycount
,index
,__reversed__
and__contains__
I think we might want to add those items to the interface to aid our type checking and make for more intuitive use cases of the ExtensionArray
The text was updated successfully, but these errors were encountered: