Skip to content

[DISCUSSION] What to do about None vs no_default as a pandas kwargs #8645

Open

Description

@jsignell

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)

Activity

  1. added
    discussion
    on Feb 1, 2022
  2. quasiben commented on Feb 1, 2022

    @quasiben
    Member
  3. galipremsagar commented on Feb 2, 2022

    @galipremsagar
    Contributor

    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)

  4. shwina commented on Feb 2, 2022

    @shwina
    Contributor

    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...

  5. jsignell commented on Feb 2, 2022

    @jsignell
    MemberAuthor

    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.

  6. shwina commented on Feb 2, 2022

    @shwina
    Contributor

    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).

  7. added
    needs attention
    on Mar 7, 2022
  8. phofl commented on Apr 26, 2023

    @phofl
    Collaborator

    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_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.

  9. fjetter commented on Apr 26, 2023

    @fjetter
    Member

    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.

  10. j-bennet commented on Apr 26, 2023

    @j-bennet
    Contributor

    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.

  11. removed
    needs attention
    on Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dataframediscussion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions