2
2
3
3
import pytest
4
4
import datetime
5
+ from distutils .version import LooseVersion
5
6
from warnings import catch_warnings
6
7
7
8
import numpy as np
8
9
import pandas as pd
9
- from pandas .compat import PY3 , is_platform_windows
10
+ from pandas .compat import PY3
10
11
from pandas .io .parquet import (to_parquet , read_parquet , get_engine ,
11
12
PyArrowImpl , FastParquetImpl )
12
13
from pandas .util import testing as tm
@@ -42,8 +43,24 @@ def engine(request):
42
43
def pa ():
43
44
if not _HAVE_PYARROW :
44
45
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" )
47
64
return 'pyarrow'
48
65
49
66
@@ -302,10 +319,6 @@ def test_unsupported(self, pa):
302
319
df = pd .DataFrame ({'a' : pd .period_range ('2013' , freq = 'M' , periods = 3 )})
303
320
self .check_error_on_write (df , pa , ValueError )
304
321
305
- # categorical
306
- df = pd .DataFrame ({'a' : pd .Categorical (list ('abc' ))})
307
- self .check_error_on_write (df , pa , NotImplementedError )
308
-
309
322
# timedelta
310
323
df = pd .DataFrame ({'a' : pd .timedelta_range ('1 day' ,
311
324
periods = 3 )})
@@ -315,6 +328,23 @@ def test_unsupported(self, pa):
315
328
df = pd .DataFrame ({'a' : ['a' , 1 , 2.0 ]})
316
329
self .check_error_on_write (df , pa , ValueError )
317
330
331
+ def test_categorical (self , pa_ge_070 ):
332
+ pa = pa_ge_070
333
+
334
+ # supported in >= 0.7.0
335
+ df = pd .DataFrame ({'a' : pd .Categorical (list ('abc' ))})
336
+
337
+ # de-serialized as object
338
+ expected = df .assign (a = df .a .astype (object ))
339
+ self .check_round_trip (df , pa , expected )
340
+
341
+ def test_categorical_unsupported (self , pa_lt_070 ):
342
+ pa = pa_lt_070
343
+
344
+ # supported in >= 0.7.0
345
+ df = pd .DataFrame ({'a' : pd .Categorical (list ('abc' ))})
346
+ self .check_error_on_write (df , pa , NotImplementedError )
347
+
318
348
319
349
class TestParquetFastParquet (Base ):
320
350
0 commit comments