[
https://issues.apache.org/jira/browse/ARROW-9864?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Joris Van den Bossche updated ARROW-9864:
-----------------------------------------
Summary: [Python] pathlib.Path not supported in write_to_dataset with
partition columns (was: [Python] pathlib.Path not suppored in write_to_dataset
with partition columns)
> [Python] pathlib.Path not supported in write_to_dataset with partition columns
> ------------------------------------------------------------------------------
>
> Key: ARROW-9864
> URL: https://issues.apache.org/jira/browse/ARROW-9864
> Project: Apache Arrow
> Issue Type: Bug
> Components: Python
> Reporter: Joris Van den Bossche
> Priority: Major
> Labels: parquet
>
> Copying over from https://github.com/pandas-dev/pandas/issues/35902
> {code:python}
> import pathlib
> df = pd.DataFrame({'A':[1,2,3,4], 'B':'C'})
> df.to_parquet('tmp_path1.parquet') # OK
> df.to_parquet(pathlib.Path('tmp_path2.parquet')) # OK
> df.to_parquet('tmp_path3.parquet', partition_cols=['B']) # OK
> df.to_parquet(pathlib.Path('tmp_path4.parquet'), partition_cols=['B']) #
> TypeError
> {code}
> {{to_parquet}} method raises TypeError when using {{pathlib.Path()}} as an
> argument in case when `partition_cols` argument is not None. If no partition
> cols are provided, then {{pathlib.Path()}} is properly accepted
> {code}
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call last)
> <ipython-input-53-cae5a944d982> in <module>
> 3
> 4 df.to_parquet('tmp_path3.parquet', partition_cols=['B']) # OK
> ----> 5 df.to_parquet(pathlib.Path('tmp_path4.parquet'),
> partition_cols=['B']) # TypeError
> ...
> ~/miniconda3/lib/python3.7/site-packages/pyarrow/parquet.py in
> write_to_dataset(table, root_path, partition_cols, partition_filename_cb,
> filesystem, **kwargs)
> 1790 subtable = pa.Table.from_pandas(subgroup,
> schema=subschema,
> 1791 safe=False)
> -> 1792 _mkdir_if_not_exists(fs, '/'.join([root_path, subdir]))
> 1793 if partition_filename_cb:
> 1794 outfile = partition_filename_cb(keys)
> TypeError: sequence item 0: expected str instance, PosixPath found
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)