Skip to content

inconsistency in dataframe: no multiindex from pandas, but allowed from parquet #8323

Closed

Description

@bluss

What happened:
Unexpected difference in handling the same structure from pandas or from parquet. I'm not completely sure if this is a bug or just an incomplete feature. But that multiindex loading is allowed from parquet is a surprise.

What you expected to happen:
If MultiIndex can be supported from parquet, then it should be supported from pandas too(?)

Minimal Complete Verifiable Example:

import numpy as np
import pandas as pd
import fastparquet

np.random.seed(1)
df = pd.DataFrame(np.random.randint(0, 10, size=(10, 4)), columns=['a', 'b', 'c', 'd']).set_index(['a', 'b']).sort_index()

import dask.dataframe

# Errors with: NotImplementedError: Dask does not support MultiIndex Dataframes.
dask.dataframe.from_pandas(df)


# This succeeds and reads it with the MultiIndex
df.to_parquet("multi.pq", engine='fastparquet')
dask.dataframe.read_parquet("multi.pq").compute()

Anything else we need to know?:

Environment:

  • Dask version: '2021.10.0'
  • Python version: 3.8
  • Fastparquet version: '0.7.1'
  • Pandas version 1.3.4
  • Operating System: linux
  • Install method (conda, pip, source): pip

Activity

  1. jsignell commented on Nov 5, 2021

    @jsignell
    Member

    Yeah this is not a huge surprise. Dask doesn't really have MultiIndex support, but you can sometimes get MultiIndex partition within dask dataframes. There are limitations to what you can do with these dataframes because they will never be able to understand the range of each partition (dask calls these divisions). That is why from_pandas fails, that method always tries to figure out the divisions.

    If you are interested in real MultiIndex support in Dask, you can follow this PR: #8153. If you have ideas or suggestions of how things should work, please feel free to comment!

  2. added
    needs attention
    on Dec 6, 2021
  3. pavithraes commented on Mar 1, 2022

    @pavithraes
    Member

    @jsignell Thanks for looking into this!

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

    needs attention

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions