Skip to content

TST: DataFrame.to_parquet accepts pathlib.Path with partition_cols defined #36491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pandas/tests/io/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from distutils.version import LooseVersion
from io import BytesIO
import os
import pathlib
from warnings import catch_warnings

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

@pytest.mark.parametrize(
"path_type", [lambda path: path, lambda path: pathlib.Path(path)]
)
def test_partition_cols_pathlib(self, pa, df_compat, path_type):
# GH 35902

partition_cols = "B"
partition_cols_list = [partition_cols]
df = df_compat

with tm.ensure_clean_dir() as path_str:
path = path_type(path_str)
df.to_parquet(path, partition_cols=partition_cols_list)

def test_empty_dataframe(self, pa):
# GH #27339
df = pd.DataFrame()
Expand Down