小编NFe*_*ern的帖子

根据列值重复 Polars DataFrame 中的行

我想通过根据数量列中的值重复行来扩展以下Polars数据框。

原始数据框:

水果 数量
苹果 2
香蕉 3

预期输出:

水果 数量
苹果 1
苹果 1
香蕉 1
香蕉 1
香蕉 1

这是一个非常相似的问题,但使用 Pandas 而不是 Polars:Repeat rows in a pandas DataFrame based on column value

Polars 重复函数似乎没有提供与 Pandas 对应函数相同的功能:https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.repeat.html

python rust-polars python-polars

1
推荐指数
1
解决办法
1335
查看次数

标签 统计

python ×1

python-polars ×1

rust-polars ×1