我正在使用 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/