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:
dask
to_parquet()
--------------------------------------------------------------------------- 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.
@martindurant do you have time to address this?
On it.
Fix parquet write when some or all partitions are empty
Activity
mrocklin commentedon Feb 27, 2017
@martindurant do you have time to address this?
martindurant commentedon Feb 27, 2017
On it.
Fix parquet write when some or all partitions are empty