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
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions ci/deps/azure-windows-38.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies:
- pytables
- python-dateutil
- pytz
- s3fs>=0.4.0
- scipy
- xlrd
- xlsxwriter
Expand Down
19 changes: 14 additions & 5 deletions pandas/tests/io/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,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
expected_df = df_compat.copy()

# read_table uses the new Arrow Datasets API since pyarrow 1.0.0
# Previous behaviour was pyarrow partitioned columns become 'categorical' dtypes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so only for integer columns the behaviour changed, for string columns it is still using category type

# and are added to back of dataframe on read

expected_df = df_compat.copy()
if partition_col:
expected_df[partition_col] = expected_df[partition_col].astype("category")
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,
pa,
Expand Down