python-3.x 将保存框架保存到具有加密列的parquet

t0ybt7op  于 8个月前  发布在  Python
关注(0)|答案(1)|浏览(64)

我想保存一个 Dataframe 到parquet文件。然而,当写入数据到parquet文件,我得到以下错误

df.to_parquet(path_to_data + 'data_temp.gzip', compression='GZIP')

TypeError                                 Traceback (most recent call last)
TypeError: Expected unicode, got quoted_name
Exception ignored in: 'fastparquet.cencoding.write_list'
Traceback (most recent call last):
  File "/manifests/venv/lib/python3.10/site-packages/fastparquet/writer.py", line 1499, in write_thrift
    return f.write(obj.to_bytes())
TypeError: Expected unicode, got quoted_name

字符串
同样的代码在其他dataframes中也可以工作,但这是我工作过的第一个有两个加密列的df
任何想法我可以解决这个问题,请。

9rnv2umw

9rnv2umw1#

我解决这个问题的方法是选择engine类型,如下所示:

df.to_parquet(path_to_data + 'data_temp.gzip', compression='GZIP', engine='pyarrow')

字符串
文件已成功保存,没有任何错误消息。
如果你有其他建议,请随时发表。

相关问题