@@ -60,6 +60,7 @@ def __init__(self):
60
60
61
61
self ._pyarrow_lt_050 = LooseVersion (pyarrow .__version__ ) < '0.5.0'
62
62
self ._pyarrow_lt_060 = LooseVersion (pyarrow .__version__ ) < '0.6.0'
63
+ self ._pyarrow_lt_071 = LooseVersion (pyarrow .__version__ ) < '0.7.1'
63
64
self .api = pyarrow
64
65
65
66
def write (self , df , path , compression = 'snappy' ,
@@ -147,27 +148,30 @@ def to_parquet(df, path, engine='auto', compression='snappy', **kwargs):
147
148
148
149
valid_types = {'string' , 'unicode' }
149
150
150
- # validate index
151
- # --------------
152
-
153
151
# validate that we have only a default index
154
152
# raise on anything else as we don't serialize the index
155
-
156
- if not isinstance (df .index , Int64Index ):
157
- raise ValueError ("parquet does not support serializing {} "
158
- "for the index; you can .reset_index()"
159
- "to make the index into column(s)" .format (
160
- type (df .index )))
161
-
162
- if not df .index .equals (RangeIndex .from_range (range (len (df )))):
163
- raise ValueError ("parquet does not support serializing a "
164
- "non-default index for the index; you "
165
- "can .reset_index() to make the index "
166
- "into column(s)" )
167
-
168
- if df .index .name is not None :
169
- raise ValueError ("parquet does not serialize index meta-data on a "
170
- "default index" )
153
+ # *unless* we're using pyarrow >= 0.7.1 which does support multi-indexes
154
+ if impl .api .__name__ == 'pyarrow' and not impl ._pyarrow_lt_071 :
155
+ validate_index = False
156
+ else :
157
+ validate_index = True
158
+
159
+ if validate_index :
160
+ if not isinstance (df .index , Int64Index ):
161
+ raise ValueError ("parquet does not support serializing {} "
162
+ "for the index; you can .reset_index()"
163
+ "to make the index into column(s)" .format (
164
+ type (df .index )))
165
+
166
+ if not df .index .equals (RangeIndex .from_range (range (len (df )))):
167
+ raise ValueError ("parquet does not support serializing a "
168
+ "non-default index for the index; you "
169
+ "can .reset_index() to make the index "
170
+ "into column(s)" )
171
+
172
+ if df .index .name is not None :
173
+ raise ValueError ("parquet does not serialize index meta-data on a "
174
+ "default index" )
171
175
172
176
# validate columns
173
177
# ----------------
0 commit comments