Skip to content

Commit 5bc3def

Browse files
committed
COMPAT: pyarrow >= 0.7.0 compat
closes #17581
1 parent 0e85ca7 commit 5bc3def

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

pandas/tests/io/test_parquet.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import pytest
44
import datetime
5+
from distutils.version import LooseVersion
56
from warnings import catch_warnings
67

78
import numpy as np
@@ -42,8 +43,24 @@ def engine(request):
4243
def pa():
4344
if not _HAVE_PYARROW:
4445
pytest.skip("pyarrow is not installed")
45-
if is_platform_windows():
46-
pytest.skip("pyarrow-parquet not building on windows")
46+
return 'pyarrow'
47+
48+
49+
@pytest.fixture
50+
def pa_lt_070():
51+
if not _HAVE_PYARROW:
52+
pytest.skip("pyarrow is not installed")
53+
if LooseVersion(pyarrow.__version__) >= '0.7.0':
54+
pytest.skip("pyarrow is >= 0.7.0")
55+
return 'pyarrow'
56+
57+
58+
@pytest.fixture
59+
def pa_ge_070():
60+
if not _HAVE_PYARROW:
61+
pytest.skip("pyarrow is not installed")
62+
if LooseVersion(pyarrow.__version__) < '0.7.0':
63+
pytest.skip("pyarrow is < 0.7.0")
4764
return 'pyarrow'
4865

4966

@@ -302,10 +319,6 @@ def test_unsupported(self, pa):
302319
df = pd.DataFrame({'a': pd.period_range('2013', freq='M', periods=3)})
303320
self.check_error_on_write(df, pa, ValueError)
304321

305-
# categorical
306-
df = pd.DataFrame({'a': pd.Categorical(list('abc'))})
307-
self.check_error_on_write(df, pa, NotImplementedError)
308-
309322
# timedelta
310323
df = pd.DataFrame({'a': pd.timedelta_range('1 day',
311324
periods=3)})
@@ -315,6 +328,21 @@ def test_unsupported(self, pa):
315328
df = pd.DataFrame({'a': ['a', 1, 2.0]})
316329
self.check_error_on_write(df, pa, ValueError)
317330

331+
@pytest.mark.xfail(reason="incompat return type")
332+
def test_categorical(self, pa_ge_070):
333+
pa = pa_ge_070
334+
335+
# supported in >= 0.7.0
336+
df = pd.DataFrame({'a': pd.Categorical(list('abc'))})
337+
self.check_round_trip(df, pa)
338+
339+
def test_categorical_unsupported(self, pa_lt_070):
340+
pa = pa_lt_070
341+
342+
# supported in >= 0.7.0
343+
df = pd.DataFrame({'a': pd.Categorical(list('abc'))})
344+
self.check_error_on_write(df, pa, NotImplementedError)
345+
318346

319347
class TestParquetFastParquet(Base):
320348

0 commit comments

Comments
 (0)