相关疑难解决方法(0)

根据列值在pandas DataFrame中重复行

我有以下df:

code . role    . persons
123 .  Janitor . 3
123 .  Analyst . 2
321 .  Vallet  . 2
321 .  Auditor . 5
Run Code Online (Sandbox Code Playgroud)

第一行意味着我有3个角色扮演者.我的问题是我需要每个人都有一行.我的df应该是这样的:

df:

code . role    . persons
123 .  Janitor . 3
123 .  Janitor . 3
123 .  Janitor . 3
123 .  Analyst . 2
123 .  Analyst . 2
321 .  Vallet  . 2
321 .  Vallet  . 2
321 .  Auditor . 5
321 .  Auditor . 5
321 . …
Run Code Online (Sandbox Code Playgroud)

python repeat dataframe pandas

14
推荐指数
2
解决办法
3538
查看次数

标签 统计

dataframe ×1

pandas ×1

python ×1

repeat ×1