Skip to content

Difficult to convert pd.DataFrame to Dataset with multi-index #8794

Closed
@staadecker

Description

@staadecker

What is your issue?

No direct way to create multi-index dataset

Unless I'm missing something, there is no easy way to convert a Pandas dataframe to a dataset with a multi-index. For example, xr.Dataset.from_dataframe automatically converts any Pandas multi-index into separate dimensions.

Workaround is inefficient

One workaround is doing xr.Dataset.from_dataframe(df).stack(...) however this is very inefficient for sparse multi-indices.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue that has not been reviewed by xarray team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions