-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
DEPR: Deprecate downcast keyword for fillna #40988
Comments
The more I look at this, the wonkier it seems. #40861 implemented a test case:
But similar calls still raise:
Moreover, there are several places in NDFrame.fillna and Block.fillna where we ignore the 'downcast' keyword so end up using None. There's also a couple of layers of special-casing in Block._maybe_downcast and Block.downcast. Notwithstanding the places where the downcast keyword is ignored, the status quo is roughly:
Some of this we can improve by actually respecting the keyword in more places and call that a bugfix. But the rest of the special-casing (object dtype, ndim==1 vs ndim==2) will likely change things and need a deprecation. AFAICT the useful cases for downcasting after fillna (and interpolate, the other places from which _maybe_downcast is called) are 1) float->int and 2) object->not_object. If this were greenfield, my inclination would be to make |
xref #11537 |
More questionable behavior: 1) we do the downcast even if the fillna is a no-op, 2) we ignore |
Based on a few days of trying to figure this out, along with #11537, I propose we deprecate the 'downcast' keyword in 'fillna', 'interpolate', 'ffill', 'bfill', with the future behavior being to always downcast for object dtype and never for anything else (the only relevant case for "anything else" being floats) |
sounds ok to me |
Having some trouble with the "do X instead" part because we don't have a method for downcasting floats (do we?) |
we don't downcast floats as a general rule |
update: deprecating the argument seems increasingly invasive. Leaning towards chipping away at the inconsistencies and calling them bugfixes. |
@jbrockmendel - I removed the deprecate tag; do you know if this issue remain open for tracking or if it is now duplicative of other issues? |
I've completely lost track |
For the four examples in the top of #40988 (comment), the first remains okay, the last is now fixed, and the other two still raise. A quick search for downcast and fillna gives some issues, but none of the nature here. |
@phofl what are your current thoughts here? |
Ideally, we would get rid of downcast in fillna and others and provide a proper down casting method? |
Sounds good to me. Want to take point on this? |
Yep, can take care of this. Would add deprecation note and new method for 2.1, so that we can immediately point users to an alternative. |
I got annoyed enough by this to spend some more time on it. Thinking of deprecating in steps:
|
This came up recently in #40861
Depending on the way forward this would allow us to get downcast out from Block or be stricter about it
Thougts?
cc @jbrockmendel @jreback
The text was updated successfully, but these errors were encountered: