Skip to content

Commit

Permalink
add filepath stringification
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback committed Apr 2, 2017
1 parent 71e1e5d commit a017d8f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pandas/io/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from warnings import catch_warnings
from pandas import DataFrame, RangeIndex, Int64Index, get_option
from pandas.compat import range
from pandas.io.common import get_filepath_or_buffer


def get_engine(engine):
Expand Down Expand Up @@ -38,11 +39,13 @@ def __init__(self):
self.api = pyarrow

def write(self, df, path, compression=None, **kwargs):
path, _, _ = get_filepath_or_buffer(path)
table = self.api.Table.from_pandas(df)
self.api.parquet.write_table(
table, path, compression=compression, **kwargs)

def read(self, path):
path, _, _ = get_filepath_or_buffer(path)
return self.api.parquet.read_table(path).to_pandas()


Expand All @@ -66,11 +69,13 @@ def write(self, df, path, compression=None, **kwargs):
# thriftpy/protocol/compact.py:339:
# DeprecationWarning: tostring() is deprecated.
# Use tobytes() instead.
path, _, _ = get_filepath_or_buffer(path)
with catch_warnings(record=True):
self.api.write(path, df,
compression=compression, **kwargs)

def read(self, path):
path, _, _ = get_filepath_or_buffer(path)
return self.api.ParquetFile(path).to_pandas()


Expand Down

0 comments on commit a017d8f

Please sign in to comment.