pandas.DataFrame.from_arrow#

classmethod DataFrame.from_arrow(data)[source]#

从表格 Arrow 对象构造 DataFrame。

此函数接受任何实现 Arrow PyCapsule 协议(即具有 __arrow_c_array____arrow_c_stream__ 方法)的 Arrow 兼容表格对象。

此函数目前依赖 pyarrow 将 Arrow 格式的表格对象转换为 pandas。

已添加到版本 3.0。

参数:
datapyarrow.Table 或 Arrow 兼容的表

任何实现 Arrow PyCapsule 协议(即具有 __arrow_c_array____arrow_c_stream__ 方法)的表格对象。

返回:
DataFrame

另请参阅

Series.from_arrow

从 Arrow 对象构造一个 Series。

示例

>>> import pyarrow as pa
>>> table = pa.table({"a": [1, 2, 3], "b": ["x", "y", "z"]})
>>> pd.DataFrame.from_arrow(table)
   a  b
0  1  x
1  2  y
2  3  z