Skip to content

Commit 2ed549d

Browse files
authored
TST: DataFrame.to_parquet accepts pathlib.Path with partition_cols defined (#36491)
1 parent bd38a9c commit 2ed549d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/tests/io/test_parquet.py

+15
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from distutils.version import LooseVersion
44
from io import BytesIO
55
import os
6+
import pathlib
67
from warnings import catch_warnings
78

89
import numpy as np
@@ -663,6 +664,20 @@ def test_partition_cols_string(self, pa, df_full):
663664
assert len(dataset.partitions.partition_names) == 1
664665
assert dataset.partitions.partition_names == set(partition_cols_list)
665666

667+
@pytest.mark.parametrize(
668+
"path_type", [lambda path: path, lambda path: pathlib.Path(path)]
669+
)
670+
def test_partition_cols_pathlib(self, pa, df_compat, path_type):
671+
# GH 35902
672+
673+
partition_cols = "B"
674+
partition_cols_list = [partition_cols]
675+
df = df_compat
676+
677+
with tm.ensure_clean_dir() as path_str:
678+
path = path_type(path_str)
679+
df.to_parquet(path, partition_cols=partition_cols_list)
680+
666681
def test_empty_dataframe(self, pa):
667682
# GH #27339
668683
df = pd.DataFrame()

0 commit comments

Comments
 (0)