Skip to content

Commit 7b17aa9

Browse files
committed
Support for partition_cols in to_parquet
1 parent 5dd4cae commit 7b17aa9

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

pandas/io/parquet.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,17 @@ 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 \
127+
len(kwargs['partition_cols']) > 0:
128+
table = self.api.Table.from_pandas(df)
129+
self.api.parquet.write_to_dataset(
130+
table, path, compression=compression,
131+
coerce_timestamps=coerce_timestamps, **kwargs)
132+
else:
133+
table = self.api.Table.from_pandas(df)
134+
self.api.parquet.write_table(
135+
table, path, compression=compression,
136+
coerce_timestamps=coerce_timestamps, **kwargs)
130137

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

0 commit comments

Comments
 (0)