-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
REF: implement EA.pad_or_backfill #54001
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
Changes from 7 commits
de31d92
c30b1a9
791e34f
777fb83
531d9e6
68e67e6
0cefb1c
5e1bcb8
d97393f
3e2f874
2bc4708
4fa7b1d
c824323
13c3b1d
36aab80
43b550b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -713,6 +713,30 @@ def isna(self): | |
mask[self.sp_index.indices] = isna(self.sp_values) | ||
return type(self)(mask, fill_value=False, dtype=dtype) | ||
|
||
def pad_or_backfill( | ||
self, | ||
*, | ||
method: FillnaOptions, | ||
limit: int | None = None, | ||
limit_area: Literal["inside", "outside"] | None = None, | ||
copy: bool = True, | ||
) -> Self: | ||
msg = "pad_or_backfill with 'method' requires high memory usage." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, will update. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated+green |
||
warnings.warn( | ||
msg, | ||
PerformanceWarning, | ||
stacklevel=find_stack_level(), | ||
) | ||
new_values = np.asarray(self) | ||
# pad_or_backfill_inplace modifies new_values inplace | ||
# error: Argument "method" to "pad_or_backfill_inplace" has incompatible | ||
# type "Literal['backfill', 'bfill', 'ffill', 'pad']"; expected | ||
# "Literal['pad', 'backfill']" | ||
pad_or_backfill_inplace( | ||
new_values, method=method, limit=limit # type: ignore[arg-type] | ||
) | ||
return type(self)(new_values, fill_value=self.fill_value) | ||
|
||
def fillna( | ||
self, | ||
value=None, | ||
|
There was a problem hiding this comment.
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?