我有一个RecordBatch
从 Plasma DataStore 中,我可以将其读入pyarrow.RecordBatch
or a pyarrow.Table
。我现在尝试在将其转换为 pandas 之前过滤掉行(to_pandas
).
有没有办法使用filter
来自新 Dataset API 的方法(您可以在 ParquetDataset 上使用)pyarrow.Table
?这将使我能够使用这样的过滤器:
[[('date', '=', '2020-01-01')]]
两者都看源码pyarrow.Table
and pyarrow.RecordBatch
貌似有过滤功能但至少RecordBatch
需要布尔掩码。
这可能吗?原因是数据集包含大量非零拷贝的字符串(和/或类别),因此运行to_pandas
实际上引入了显着的延迟,而我每次只寻找大约 20% 的数据集。
Regards,
Niklas
现在这是可能的:
import pyarrow as pa
my_table = pa.Table.from_arrays(
[pa.array(['foo', 'bar', 'foo'], pa.string())],
names=['col1']
)
# Using the high level API with expressions:
filtered_table = my_table.filter(pa.compute.field("col1") == "FOO")
# Using a lower level API:
filtered_table = my_table.filter(pa.compute.equal(my_table['col1'], 'foo'))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)