Skip to content

Fix read parquet import error message #33361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Apr 8, 2020
25 changes: 13 additions & 12 deletions pandas/io/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,23 @@ def get_engine(engine: str) -> "BaseImpl":

if engine == "auto":
# try engines in this order
try:
return PyArrowImpl()
except ImportError:
pass
engine_impls = [PyArrowImpl, FastParquetImpl]

try:
return FastParquetImpl()
except ImportError:
pass
error_msgs = []
for eimpl in engine_impls:
try:
return eimpl()
except ImportError as ie:
error_msgs.append(ie.msg)

raise ImportError(
"Unable to find a usable engine; "
"tried using: 'pyarrow', 'fastparquet'.\n"
"pyarrow or fastparquet is required for parquet support"
"A suitable version of "
"pyarrow or fastparquet is required for parquet "
"support. \n"
"Trying to import the above resulted in these errors: \n"
+ "\n".join(error_msgs)
)

if engine == "pyarrow":
Expand Down Expand Up @@ -105,9 +108,7 @@ def write(
**kwargs,
)
else:
self.api.parquet.write_table(
table, path, compression=compression, **kwargs,
)
self.api.parquet.write_table(table, path, compression=compression, **kwargs)

def read(self, path, columns=None, **kwargs):
path, _, _, should_close = get_filepath_or_buffer(path)
Expand Down