3
3
from warnings import catch_warnings
4
4
from pandas import DataFrame , RangeIndex , Int64Index , get_option
5
5
from pandas .compat import range
6
+ from pandas .io .common import get_filepath_or_buffer
6
7
7
8
8
9
def get_engine (engine ):
@@ -38,11 +39,13 @@ def __init__(self):
38
39
self .api = pyarrow
39
40
40
41
def write (self , df , path , compression = None , ** kwargs ):
42
+ path , _ , _ = get_filepath_or_buffer (path )
41
43
table = self .api .Table .from_pandas (df )
42
44
self .api .parquet .write_table (
43
45
table , path , compression = compression , ** kwargs )
44
46
45
47
def read (self , path ):
48
+ path , _ , _ = get_filepath_or_buffer (path )
46
49
return self .api .parquet .read_table (path ).to_pandas ()
47
50
48
51
@@ -66,11 +69,13 @@ def write(self, df, path, compression=None, **kwargs):
66
69
# thriftpy/protocol/compact.py:339:
67
70
# DeprecationWarning: tostring() is deprecated.
68
71
# Use tobytes() instead.
72
+ path , _ , _ = get_filepath_or_buffer (path )
69
73
with catch_warnings (record = True ):
70
74
self .api .write (path , df ,
71
75
compression = compression , ** kwargs )
72
76
73
77
def read (self , path ):
78
+ path , _ , _ = get_filepath_or_buffer (path )
74
79
return self .api .ParquetFile (path ).to_pandas ()
75
80
76
81
0 commit comments