Skip to content

Commit 7c7a7a9

Browse files
authored
Support for partition_cols in to_parquet
1 parent 5dd4cae commit 7c7a7a9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pandas/io/parquet.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,16 @@ def write(self, df, path, compression='snappy',
123123
table, path, compression=compression, **kwargs)
124124

125125
else:
126-
table = self.api.Table.from_pandas(df, **from_pandas_kwargs)
127-
self.api.parquet.write_table(
128-
table, path, compression=compression,
129-
coerce_timestamps=coerce_timestamps, **kwargs)
126+
if 'partition_cols' in kwargs and len(kwargs['partition_cols']) > 0:
127+
table = self.api.Table.from_pandas(df)
128+
self.api.parquet.write_to_dataset(
129+
table, path, compression=compression,
130+
coerce_timestamps=coerce_timestamps, **kwargs)
131+
else:
132+
table = self.api.Table.from_pandas(df)
133+
self.api.parquet.write_table(
134+
table, path, compression=compression,
135+
coerce_timestamps=coerce_timestamps, **kwargs)
130136

131137
def read(self, path, columns=None, **kwargs):
132138
path, _, _, should_close = get_filepath_or_buffer(path)

0 commit comments

Comments
 (0)