pandas - 迭代 Pyarrow 表的最快方法

标签 pandas pyarrow

我正在使用 Pyarrow 库来优化 Pandas DataFrame 的存储。我需要尽可能快地逐行处理 pyarrow Table 而不将其转换为 Pandas DataFrame(它不适合内存)。 Pandas 有 iterrows()/iterrtuples() 方法。除了 for 循环和索引寻址之外,是否有任何快速迭代 Pyarrow Table 的方法?

最佳答案

这段代码对我有用:

for batch in table.to_batches():
    d = batch.to_pydict()
    for c1, c2, c3 in zip(d['c1'], d['c2'], d['c3']):
        # Do something with the row of c1, c2, c3

关于pandas - 迭代 Pyarrow 表的最快方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53157495/

相关文章:

python - 从现有的两列python创建唯一ID

python - python中的分位数函数是否忽略NaN?

python-3.x - PyArrow/S3文件系统 : How to use the retry_strategy correctly with self defined max attempts

python - 为什么 Pyarrow 可以读取额外的索引列,而 Pandas dataframe 却不能?

python - 将带有时间增量的 Pandas 数据框写入 Parquet

amazon-s3 - 记录 pyarrow 在 S3 上创建的 Parquet 文件名

python - Pandas 数据帧 : convert columns into rows of a single column

python - 如何将 pandas DataFrame 中的 2 行与连续时间戳合并?

python - 加载索引具有冗余列的 parquet 文件时出现 pyarrow 问题

python - Pandas 数据框插入缺失的行并填充上一行