You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[DISCUSSION] What to do about None vs no_default as a pandas kwargs #8645
Pandas has started to use a pattern where None means something different than no_default. So far we've been handling these as they come up (for example: #8554), but we should probably figure out what we want to do more generally.
I've been holding off on the general solution until we can get some feedback from cudf people (cc @quasiben)
From the discussion here: pandas-dev/pandas#45448, Looks like pandas is still going to enforce it widely. The no_default seems to be a synonymous change that happened with np.nan vs pd.NA. So to support this we would also have to include no_default-like support both in dask & cudf too - right?
But since no_default is buried and not widely known is pandas planning on standardizing it like pd.NA for nullable types? i.e., it'd be not so intuitive for us to expect a user to pass pd.api.extensions.no_default (vs a simpler pd.NA)
We could use pd.api.extensions.no_default directly. Agree with @galipremsagar that it'd be nice to have that as a top-level pd.no_default (although perhaps pd.NO_DEFAULT would be more clear).
Maybe I worry too much, but one potential concern if other package(s) follow suit and have their own "NoDefaultType", we end up with pd.no_default, other_lib.no_default, another_lib.no_default_value, etc...
Yeah dask already has its own no_default that we use in some places. I was kind of wondering if dask should just use that and strip it out of the kwargs before passing to pandas/cudf. I think the expectation is that users will not explicitly set pd.api.extensions.no_default as the value of a kwarg.
I think the expectation is that users will not explicitly set pd.api.extensions.no_default as the value of a kwarg.
I agree that this is the expectation, but being able to explicitly pass optional kwargs is valuable in so many contexts. Always stripping out the kwarg is doable, but adds unnecessary processing overhead.
At this point, I think I'm just complaining. I'm not strongly opposed to either solution (explicitly passing no_default or stripping it out).
Yes the expectation in pandas is that users don't set this explicitly. This is one of the reasons why adding it to the top-level namespace is highly unlikely. pd.api.extension.no_default is meant for downstream libraries, not end-users.
That said, We could get rid of a few places where we have to handle keywords awkwardly if we adapt this in Dask as well. This would remove the need to check for keyword values before passing them along in this case.
I'm not very deep into this but from a high level it makes sense for us to reuse the pandas pd.api.extension.no_default for all APIs that pass this to pandas directly. This doesn't mean we have to use it everywhere.
I'm not very deep into this but from a high level it makes sense for us to reuse the pandas pd.api.extension.no_default for all APIs that pass this to pandas directly. This doesn't mean we have to use it everywhere.
In dask, the backing dataframe can be something that only pretends to be a pandas dataframe. If it's a cudf dataframe, it will not know about the pandas enum pd.api.extensions.no_default, and will probably raise an error. If we don't know what sort of backend dataframe we're dealing with, the safest and easiest option is to remove no_default values from args / kwargs.
We could have some sort of branching logic to check what kind of backend we're dealing with, and use a no_default from there, but that will get complicated.
Activity
quasiben commentedon Feb 1, 2022
cc @shwina @galipremsagar @beckernick @brandon-b-miller
galipremsagar commentedon Feb 2, 2022
From the discussion here: pandas-dev/pandas#45448, Looks like
pandasis still going to enforce it widely. Theno_defaultseems to be a synonymous change that happened withnp.nanvspd.NA. So to support this we would also have to includeno_default-like support both indask&cudftoo - right?But since
no_defaultis buried and not widely known is pandas planning on standardizing it likepd.NAfor nullable types? i.e., it'd be not so intuitive for us to expect a user to passpd.api.extensions.no_default(vs a simplerpd.NA)shwina commentedon Feb 2, 2022
We could use
pd.api.extensions.no_defaultdirectly. Agree with @galipremsagar that it'd be nice to have that as a top-levelpd.no_default(although perhapspd.NO_DEFAULTwould be more clear).Maybe I worry too much, but one potential concern if other package(s) follow suit and have their own "
NoDefaultType", we end up withpd.no_default,other_lib.no_default,another_lib.no_default_value, etc...jsignell commentedon Feb 2, 2022
Yeah dask already has its own
no_defaultthat we use in some places. I was kind of wondering if dask should just use that and strip it out of the kwargs before passing to pandas/cudf. I think the expectation is that users will not explicitly setpd.api.extensions.no_defaultas the value of a kwarg.shwina commentedon Feb 2, 2022
I agree that this is the expectation, but being able to explicitly pass optional kwargs is valuable in so many contexts. Always stripping out the kwarg is doable, but adds unnecessary processing overhead.
At this point, I think I'm just complaining. I'm not strongly opposed to either solution (explicitly passing no_default or stripping it out).
phofl commentedon Apr 26, 2023
I want to bring this up again.
Yes the expectation in pandas is that users don't set this explicitly. This is one of the reasons why adding it to the top-level namespace is highly unlikely.
pd.api.extension.no_defaultis meant for downstream libraries, not end-users.That said, We could get rid of a few places where we have to handle keywords awkwardly if we adapt this in Dask as well. This would remove the need to check for keyword values before passing them along in this case.
fjetter commentedon Apr 26, 2023
I'm not very deep into this but from a high level it makes sense for us to reuse the pandas
pd.api.extension.no_defaultfor all APIs that pass this to pandas directly. This doesn't mean we have to use it everywhere.j-bennet commentedon Apr 26, 2023
In dask, the backing dataframe can be something that only pretends to be a pandas dataframe. If it's a cudf dataframe, it will not know about the pandas enum
pd.api.extensions.no_default, and will probably raise an error. If we don't know what sort of backend dataframe we're dealing with, the safest and easiest option is to removeno_defaultvalues from args / kwargs.We could have some sort of branching logic to check what kind of backend we're dealing with, and use a
no_defaultfrom there, but that will get complicated.