3
3
from warnings import catch_warnings
4
4
from distutils .version import LooseVersion
5
5
from pandas import DataFrame , RangeIndex , Int64Index , get_option
6
- from pandas .compat import range , string_types
6
+ from pandas .compat import string_types
7
7
from pandas .core .common import AbstractMethodError
8
8
from pandas .io .common import get_filepath_or_buffer
9
9
@@ -87,7 +87,7 @@ def __init__(self):
87
87
"pip install -U pyarrow\n "
88
88
)
89
89
self ._pyarrow_lt_070 = (
90
- LooseVersion (pyarrow .__version__ ) < LooseVersion ('0.7.0' )
90
+ LooseVersion (pyarrow .__version__ ) < LooseVersion ('0.7.0' )
91
91
)
92
92
self .api = pyarrow
93
93
@@ -113,14 +113,16 @@ def read(self, path, columns=None, **kwargs):
113
113
kwargs ['use_pandas_metadata' ] = True
114
114
return parquet_file .read (columns = columns , ** kwargs ).to_pandas ()
115
115
116
-
117
116
def _validate_write_lt_070 (self , df , path , compression = 'snappy' ,
118
- coerce_timestamps = 'ms' , ** kwargs ):
117
+ coerce_timestamps = 'ms' , ** kwargs ):
119
118
# Compatibility shim for pyarrow < 0.7.0
120
119
# TODO: Remove in pandas 0.22.0
121
120
from pandas .core .indexes .multi import MultiIndex
122
121
if isinstance (df .index , MultiIndex ):
123
- msg = "Mulit-index DataFrames are only supported with pyarrow >= 0.7.0"
122
+ msg = (
123
+ "Mulit-index DataFrames are only supported "
124
+ "with pyarrow >= 0.7.0"
125
+ )
124
126
raise ValueError (msg )
125
127
# Validate index
126
128
if not isinstance (df .index , Int64Index ):
@@ -150,7 +152,8 @@ def _read_lt_070(self, parquet_file, columns, **kwargs):
150
152
metadata = json .loads (parquet_file .metadata .metadata [b'pandas' ])
151
153
columns = set (chain (columns , metadata ['index_columns' ]))
152
154
kwargs ['columns' ] = columns
153
- return self .api .parquet .read_table (parquet_file .path , ** kwargs ).to_pandas ()
155
+ kwargs ['path' ] = parquet_file .path
156
+ return self .api .parquet .read_table (** kwargs ).to_pandas ()
154
157
155
158
156
159
class FastParquetImpl (BaseImpl ):
0 commit comments