Skip to content

to_parquet() fails with empty partitions #2016

Closed

Description

Hi,

I am currently facing the following problem with dask (version 0.13.0): to_parquet() fails when one of the partitions is empty. The error one gets is:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-48-faa825ea24c4> in <module>()
     11 # fails as there are empty partitions
     12 ddf2 = ddf[ddf.a <= 5]
---> 13 ddf2.to_parquet("/tmp/test2.parquet")

/opt/conda/lib/python3.5/site-packages/dask/dataframe/core.py in to_parquet(self, path, *args, **kwargs)
    931         """ See dd.to_parquet docstring for more information """
    932         from .io import to_parquet
--> 933         return to_parquet(path, self, *args, **kwargs)
    934 
    935     def to_csv(self, filename, **kwargs):

/opt/conda/lib/python3.5/site-packages/dask/dataframe/io/parquet.py in to_parquet(path, df, compression, write_index, has_nulls, fixed_text, object_encoding, storage_options)
    242 
    243     for fn, rg in zip(filenames, out):
--> 244         for chunk in rg.columns:
    245             chunk.file_path = fn
    246         fmd.row_groups.append(rg)

AttributeError: 'NoneType' object has no attribute 'columns'

Reproducible example:

import pandas as pd
import dask.dataframe as dd

df = pd.DataFrame({"a": range(10), "b": range(10)})
ddf = dd.from_pandas(df, npartitions=5)


# works
ddf.to_parquet("/tmp/test.parquet")

# fails as there are empty partitions
ddf2 = ddf[ddf.a <= 5]
ddf2.to_parquet("/tmp/test2.parquet")

I assume this is not the intended behaviour.

Activity

  1. mrocklin commented on Feb 27, 2017

    @mrocklin
    Member

    @martindurant do you have time to address this?

  2. martindurant commented on Feb 27, 2017

    @martindurant
    Member

    On it.

  3. added a commit that references this issue on Feb 27, 2017
    9de0349
  4. added this to the 0.14.1 milestone on Mar 30, 2017
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions