Skip to content

Commit 61888b2

Browse files
committed
TST: Update pyarrow tests to test parquet faithful roundtrip for Categorical support
Fixes #27955
1 parent 9f93d57 commit 61888b2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pandas/tests/io/test_parquet.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
""" test parquet compat """
22
import datetime
3+
from distutils.version import LooseVersion
34
import os
45
from warnings import catch_warnings
56

@@ -166,6 +167,7 @@ def compare(repeat):
166167
df.to_parquet(path, **write_kwargs)
167168
with catch_warnings(record=True):
168169
actual = read_parquet(path, **read_kwargs)
170+
169171
tm.assert_frame_equal(expected, actual, check_names=check_names)
170172

171173
if path is None:
@@ -453,9 +455,12 @@ def test_categorical(self, pa):
453455
# supported in >= 0.7.0
454456
df = pd.DataFrame({"a": pd.Categorical(list("abc"))})
455457

456-
# de-serialized as object
457-
expected = df.assign(a=df.a.astype(object))
458-
check_round_trip(df, pa, expected=expected)
458+
if LooseVersion(pyarrow.__version__) >= LooseVersion("0.15.0"):
459+
check_round_trip(df, pa)
460+
else:
461+
# de-serialized as object for pyarrow < 0.15
462+
expected = df.assign(a=df.a.astype(object))
463+
check_round_trip(df, pa, expected=expected)
459464

460465
def test_s3_roundtrip(self, df_compat, s3_resource, pa):
461466
# GH #19134

0 commit comments

Comments
 (0)