Skip to content

Improve check for sparse dataframes #16845

@jorisvandenbossche

Description

@jorisvandenbossche

Originally posted by @jorisvandenbossche in #16728

To be safe, I would also add a check that all columns are indeed sparse (the .sparse accessor now raises if not all columns are sparse, but I am not sure this is necessarily guaranteed to stay that way).
The explicit check would be something like:

df.dtypes.apply(pd.api.types.is_sparse).all()

See also pandas-dev/pandas#26706

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions