pandas - 什么是 pyarrow 表?它会替代熊猫数据框吗?
问题描述
我已经尝试阅读文档,但我仍然感到困惑。pyarrow 表是否能够进行 groupbys 并具有所有美妙的 pandas 功能?
import pyarrow as pa
import pandas as pd
df = pd.DataFrame({"a": [1, 2, 3]})
table = pa.Table.from_pandas(df)
但现在是虎头蛇尾:
table["a"]
# ---------------------------------------------------------------------------
# TypeError Traceback (most recent call last)
# <ipython-input-18-fb884245e2de> in <module>()
# ----> 1 table["a"]
# table.pxi in pyarrow.lib.Table.__getitem__()
# TypeError: an integer is required
table[0]
# <pyarrow.lib.Column object at 0x111306330>
# chunk 0: <pyarrow.lib.Int64Array object at 0x11728d1d8>
# [
# 1,
# 2,
# 3
# ]
c = table[0]
c[c>2]
# ---------------------------------------------------------------------------
# TypeError Traceback (most recent call last)
# <ipython-input-16-cc54312229de> in <module>()
# ----> 1 c[c>2]
#
# TypeError: '>' not supported between instances of 'pyarrow.lib.Column' and 'int'
pyarrow 是一个更适合熊猫内部的库还是什么?
解决方案
是的,pyarrow 是一个用于构建数据框内部(和其他数据处理应用程序)的库。它不是像 pandas 那样的最终用户库。如果您想进一步讨论,请写在 Apache Arrow 邮件列表上。
推荐阅读
- python - 错误:未找到雪花连接器-python==2.5.0 的匹配分布
- reactjs - 想要在“react-native-image-layout”中的图像模式上显示一个菜单栏,以提供删除等图像的选项
- c++ - 如何在 C++ 中记录屏幕时间?
- javascript - 更新 Mongoose 检索对象中的现有嵌套属性
- java - 取消刷新尝试:org.springframework.beans.factory.BeanDefinitionStoreException:无法解析配置类
- android - 您如何让订阅者订阅 kotlin sharedflow 并行运行操作?
- linux - 如何将 Linux 驱动程序与硬件设备匹配
- asp.net - ASP.NET 复选框在首次加载时不会触发检查更改事件
- vue.js - 在 Vue 3 中为 img src 使用具有动态名称的本地文件
- firebase - Streambuilder 不使用具有多个 where 子句的 Firebase 查询