Skip to content
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

REF: implement EA.pad_or_backfill #54001

Merged
merged 16 commits into from
Jul 31, 2023

Conversation

jbrockmendel
Copy link
Member

Sits on top of #53989.

The deprecation is a little bit awkward. If a 3rd party EA has implement fillna but not pad_or_backfill, we warn and call that. DecimalArray tests that deprecation.

The "method" paths for our existing EA.fillna methods could be ripped out as they are no longer used. I left them untouched for now.

In a follow-up, can de-duplicate Block.pad_or_backfill with EABlock.pad_or_backfill.

@jbrockmendel jbrockmendel changed the title Ref pad or backfill ea 3 REF: implement EA.pad_or_backfill Jul 4, 2023
@jbrockmendel jbrockmendel requested a review from mroeschke as a code owner July 5, 2023 04:07
@jbrockmendel
Copy link
Member Author

/home/runner/work/pandas/pandas/pandas/core/arrays/base.py:docstring of pandas.core.arrays.base.ExtensionArray:119: WARNING: autosummary: stub file not found 'pandas.api.extensions.ExtensionArray.pad_or_backfill'. Check your autosummary_generate setting.

@mroeschke help? i dont understand what this is asking for

@jbrockmendel
Copy link
Member Author

@MarcoGorelli any idea whats going on with the docbuild? i have a premonition its going to be really obvious as soon as someone points it out to me

@jbrockmendel jbrockmendel force-pushed the ref-pad_or_backfill-ea-3 branch from c951419 to 777fb83 Compare July 6, 2023 21:55
@MarcoGorelli
Copy link
Member

My guess is that you need to add this new method to doc/source/reference/extensions.rst ?

@mroeschke mroeschke added the ExtensionArray Extending pandas with custom dtypes or arrays. label Jul 7, 2023
@jbrockmendel
Copy link
Member Author

That solved it, thanks

@@ -281,6 +281,16 @@ def convert_values(param):
def value_counts(self, dropna: bool = True):
return value_counts(self.to_numpy(), dropna=dropna)

# We override fillna here to simulate a 3rd party EA that has done so. This
Copy link
Member

Choose a reason for hiding this comment

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

So we can remove this in 3.0 when the deprecation is enforced? (if so can we add a note)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. I'll add that to my next Assorted branch

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

looks good, just got minor comments

limit_area: Literal["inside", "outside"] | None = None,
copy: bool = True,
) -> Self:
msg = "pad_or_backfill with 'method' requires high memory usage."
Copy link
Member

Choose a reason for hiding this comment

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

'method' is required here? why not just "pad_or_backfill for sparse arrays requires high memory usage."

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, will update.

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm i think this warning would be unnecessary if we move SparseArray to use the new get_fill_indexer implementation. ill do that as a separate PR

Copy link
Member Author

Choose a reason for hiding this comment

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

updated+green

pandas/core/arrays/arrow/array.py Show resolved Hide resolved
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

might need another merge after recent CI changes

I'd suggest adding a little example here too, so as to not add even more to the list of exclusions (which we're hoping to remove next week)

@@ -82,6 +82,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.api.extensions.ExtensionArray._reduce \
pandas.api.extensions.ExtensionArray._values_for_factorize \
pandas.api.extensions.ExtensionArray.interpolate \
pandas.api.extensions.ExtensionArray.pad_or_backfill \
Copy link
Member

Choose a reason for hiding this comment

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

can we add a little example while we're here?

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

Nice one! Ok to merge imo

@mroeschke mroeschke added this to the 2.1 milestone Jul 31, 2023
@mroeschke mroeschke merged commit 0a9efad into pandas-dev:main Jul 31, 2023
@mroeschke
Copy link
Member

Thanks @jbrockmendel

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: EA.ffill/bfill?
3 participants