python - 如何在 Python 中读取 gzipped parquet 文件
问题描述
我需要打开一个压缩文件,里面有一个镶木地板文件,里面有一些数据。我在尝试打印/读取文件中的内容时遇到了很多麻烦。我尝试了以下方法:
with gzip.open("myFile.parquet.gzip", "rb") as f:
data = f.read()
这似乎不起作用,因为我收到一个错误,即我的文件 id 不是 gz 文件。谢谢!
解决方案
您可以使用模块中read_parquet
的功能pandas
:
- 安装
pandas
和pyarrow
:
pip install pandas pyarrow
- 使用
read_parquet
which 返回DataFrame
:
data = read_parquet("myFile.parquet.gzip")
print(data.count()) # example of operation on the returned DataFrame
推荐阅读
- javascript - 如何使用 Vue 和 Vuetify 正确设置移动设备的视口?视口不适合手机的全屏
- python - 如何遍历 2 个文件中的行,比较值并在满足条件时更新文件中的值?
- python - Visual Studio Code:Jupyter Notebooks 的调试不起作用
- python - SQLITE 和 PYQT5 停止响应 sql 执行
- flutter - ShowTimePicker 我需要在文本字段上显示时间选择器
- pandas - Python:我需要在大型 csv 文件的特定列中找到超过 x 行的平均值
- python - Python Bokeh 将所有回调放在一个与主文件分开的文件中
- reactjs - yup() 测试多个条件
- xamarin - MIUI12.5.0版本包含xamarin.Forms应用点击工具栏按钮崩溃
- python - 如何使用pyautogui从1到5依次单击随机位置的多个图像