Skip to content

Value error raised when looking at a column in a partitioned parquet file. #3170

Closed

Description

@JonGlancy

Having used dask to read a bunch of csv files and write them as a partitioned parquet file, I'm now having issues reading the parquet file with dask.

The following works as expected:
ddf = dd.load_parquet('file.parquet') ddf.head()
However, when I try to work on a single column a ValueError is thrown:

ddf.A.head()

ValueError: Length mismatch: Expected axis has 2 elements, new values have 1 elements

The issue can be resolved by resetting the index, but that doesn't seem ideal.

Using the following versions: dask==0.17.0, fastparquet==0.1.4, pandas==0.22.0

class TestParquet(unittest.TestCase):

    def setUp(self):
        data = {'A': [1, 2, 3, 4, 5, 6, 7],
                'B': ['str {}'.format(num) for num in range(1, 8)],
                'C': [1, 1, 1, 2, 3, 3, 3]}
        df = pd.DataFrame.from_dict(data)
        ddf = dd.from_pandas(df, npartitions=3)

        ddf.to_parquet('test.parquet')
        ddf.to_parquet('test_partitioned.parquet', partition_on=['C'])

    def test_load_with_pandas(self):  # Passes
        df = pd.read_parquet('test.parquet')
        df.head()
        df.B.head()

    def test_load_with_dask_compute_frame(self):  # Passes
        df = dd.read_parquet('test.parquet')
        df = df.compute()
        df.B

    def test_load_with_dask_compute_column(self):  # Passes
        df = dd.read_parquet('test.parquet')
        df.B.compute()

    def test_load_with_dask_reset_index(self):  # Passes
        df = dd.read_parquet('test.parquet')
        df = df.reset_index()
        df.B.compute()

    def test_load_partitioned_with_pandas(self):  # Passes
        df = pd.read_parquet('test_partitioned.parquet')
        df.head()
        df.B.head()

    def test_load_partitioned_with_dask_compute_frame(self):  # Passes
        df = dd.read_parquet('test_partitioned.parquet')
        df.compute()

    def test_load_partitioned_with_dask_compute_column(self):  # Fails
        df = dd.read_parquet('test_partitioned.parquet')
        df.B.compute()

    def test_load_partitioned_with_dask_reset_index(self):  # Passes
        df = dd.read_parquet('test_partitioned.parquet')
        df = df.reset_index()
        df.B.compute()

Activity

  1. martindurant commented on Feb 15, 2018

    @martindurant
    Member

    Nice test case.

    This looks like a duplicate of #3168

  2. martindurant commented on Feb 15, 2018

    @martindurant
    Member

    @jcrist @mrocklin , is dask.dataframe.optimize doing the right thing here? I think there is a bug in fastparquet where you cannot do pf.to_pandas(columns=['a']) where 'a' is a column coming from directory names rather than data files; but it's not totally clear to me what should happen in that case.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions