ADE*_*ANI 5 python group-by pandas apache-arrow pyarrow
假设我有以下数据框:
| 代码 | 价格 |
|---|---|
| AA1 | 10 |
| AA1 | 20 |
| BB2 | 30 |
我想对其执行以下操作:
df.groupby("code").aggregate({
"price": "sum"
})
Run Code Online (Sandbox Code Playgroud)
我尝试使用 Pandas 2.0 中引入的新 pyarrow dtypes,并创建了 3 个副本,对于每个副本,我测量了上述操作的执行时间(5 次执行的平均值)。
| 代码列数据类型 | 价格列数据类型 | 执行时间处理时间 |
|---|---|---|
| 目的 | 浮动64 | 2.94秒 |
| 字符串[pyarrow] | 双[pyarrow] | 49.5秒 |
| 字符串[pyarrow] | 浮动64 | 1.11秒 |
谁能解释为什么与标准 numpy float64 dtype 相比,在具有 double pyarrow dtype 的列上应用聚合函数如此慢?
wkg*_*sam 10
https://github.com/pandas-dev/pandas/issues/52070
看起来箭头的 groupby 尚未实现 - 因此内部可能发生箭头 -> numpy 导致性能损失。
| 归档时间: |
|
| 查看次数: |
1283 次 |
| 最近记录: |