问题描述
我知道 Pandas 可以使用不同的后端读取和写入 Parquet 文件:pyarrow
和 fastparquet
.
我有一个带有 Intel 发行版的 Conda 发行版并且它有效":我可以使用 pandas.DataFrame.to_parquet
.但是我没有安装 pyarrow
所以我猜使用了 fastparquet
(我也找不到).
有没有办法确定使用了哪个后端?
一种方法是调用 show_versions()
,它会列出依赖项(以及其他环境内容):
pd.show_versions()已安装的版本------------------提交:无蟒蛇:3.6.0.final.0蟒蛇位:64操作系统:Windows操作系统版本:7机器:AMD64处理器:Intel64 Family 6 Model 42 Stepping 7, GenuineIntel字节序:小LC_ALL:无朗:无地区:无.无熊猫:0.23.0pytest: 3.0.5点数:9.0.3设置工具:27.2.0赛通:0.25.2麻木:1.14.3scipy:1.1.0pyarrow:无xarray:无IPython:5.1.0狮身人面像:1.5.1帕齐:0.4.1日期工具:2.6.0pytz:2016.10块:无瓶颈:1.2.1表:3.4.3数字表达式:2.6.5羽毛:无matplotlib:2.2.2openpyxl:2.4.1xlrd: 1.0.0xlwt:1.2.0xlsxwriter:0.9.6lxml:3.7.2BS4:4.5.3html5lib: 0.9999999sqlalchemy:1.1.5pymysql:无psycopg2:无jinja2:2.9.4s3fs:无快速拼花:无pandas_gbq:无pandas_datareader:无
顺便说一下,我没有安装 pyarrow
或 fastparquet
其实你可以调用pd.io.parquet.get_engine('auto')
:
在[193]:pd.io.parquet.get_engine('auto')---------------------------------------------------------------------------导入错误回溯(最近一次调用最后一次)<ipython-input-193-929185e5aca8>在 <module>()---->1 pd.io.parquet.get_engine('auto')C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parquet.py in get_engine(engine)27关28--->29 raise ImportError("无法找到可用的引擎;"30 "尝试使用:'pyarrow'、'fastparquet'.\n"31镶木地板需要pyarrow或fastparquet"导入错误:无法找到可用的引擎;尝试使用:'pyarrow'、'fastparquet'.镶木地板支持需要 pyarrow 或 fastparquet
由于我没有安装这会引发 ImportError,大概在您的环境中这实际上会返回已安装的引擎
安装 fastparquet
后,我现在得到:
在[194]:pd.io.parquet.get_engine('auto')输出[194]:<pandas.io.parquet.FastParquetImpl at 0xf5582b0>
如果我们看一下class
:
在[202]:impl = pd.io.parquet.get_engine('auto')impl.__class__出[202]:pandas.io.parquet.FastParquetImpl
它告诉我们它是哪个 impl.
如果安装了 pyarrow
,将会得到:
I understand that Pandas can read and write to and from Parquet files using different backends: pyarrow
and fastparquet
.
I have a Conda distribution with the Intel distribution and "it works": I can use pandas.DataFrame.to_parquet
. However I do not have pyarrow
installed so I guess that fastparquet
is used (which I cannot find either).
Is there a way to identify which backend is used?
One method would be to call show_versions()
which will list the dependencies (plus other environment stuff):
pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.0.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 42 Stepping 7, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.23.0
pytest: 3.0.5
pip: 9.0.3
setuptools: 27.2.0
Cython: 0.25.2
numpy: 1.14.3
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 5.1.0
sphinx: 1.5.1
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: 1.2.1
tables: 3.4.3
numexpr: 2.6.5
feather: None
matplotlib: 2.2.2
openpyxl: 2.4.1
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: 0.9.6
lxml: 3.7.2
bs4: 4.5.3
html5lib: 0.9999999
sqlalchemy: 1.1.5
pymysql: None
psycopg2: None
jinja2: 2.9.4
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
Here incidentally I don't have either pyarrow
or fastparquet
installed
Actually you can call pd.io.parquet.get_engine('auto')
:
In[193]:
pd.io.parquet.get_engine('auto')
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-193-929185e5aca8> in <module>()
----> 1 pd.io.parquet.get_engine('auto')
C:\ProgramData\Anaconda3\lib\site-packages\pandas\io\parquet.py in get_engine(engine)
27 pass
28
---> 29 raise ImportError("Unable to find a usable engine; "
30 "tried using: 'pyarrow', 'fastparquet'.\n"
31 "pyarrow or fastparquet is required for parquet "
ImportError: Unable to find a usable engine; tried using: 'pyarrow', 'fastparquet'.
pyarrow or fastparquet is required for parquet support
As I don't have either installed this raises an ImportError, presumably on your environment this will actually return the installed engine
And after installing fastparquet
I now get:
In[194]:
pd.io.parquet.get_engine('auto')
Out[194]: <pandas.io.parquet.FastParquetImpl at 0xf5582b0>
And if we look at the class
:
In[202]:
impl = pd.io.parquet.get_engine('auto')
impl.__class__
Out[202]: pandas.io.parquet.FastParquetImpl
it tells us which impl it is.
If pyarrow
is installed one would get:
>>> pd.io.parquet.get_engine('auto')
<pandas.io.parquet.PyArrowImpl object at 0xa13fb1ef0>
>>> pd.io.parquet.get_engine('auto').__class__
<class 'pandas.io.parquet.PyArrowImpl'>
这篇关于如何识别 Pandas 的 Parquet 后端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!