Skip to content

TST: Fix test_parquet failures for pyarrow 1.0 #35814

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 4 commits into from
Aug 25, 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
23 changes: 15 additions & 8 deletions pandas/tests/io/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,15 +565,22 @@ def test_s3_roundtrip(self, df_compat, s3_resource, pa):
@pytest.mark.parametrize("partition_col", [["A"], []])
def test_s3_roundtrip_for_dir(self, df_compat, s3_resource, pa, partition_col):
# GH #26388
# https://github.com/apache/arrow/blob/master/python/pyarrow/tests/test_parquet.py#L2716
# As per pyarrow partitioned columns become 'categorical' dtypes
# and are added to back of dataframe on read
if partition_col and pd.compat.is_platform_windows():
pytest.skip("pyarrow/win incompatibility #35791")

expected_df = df_compat.copy()
if partition_col:
expected_df[partition_col] = expected_df[partition_col].astype("category")

# GH #35791
# read_table uses the new Arrow Datasets API since pyarrow 1.0.0
# Previous behaviour was pyarrow partitioned columns become 'category' dtypes
# These are added to back of dataframe on read. In new API category dtype is
# only used if partition field is string.
legacy_read_table = LooseVersion(pyarrow.__version__) < LooseVersion("1.0.0")
if partition_col and legacy_read_table:
partition_col_type = "category"
else:
partition_col_type = "int32"

expected_df[partition_col] = expected_df[partition_col].astype(
partition_col_type
)

check_round_trip(
df_compat,
Expand Down