小编San*_*der的帖子

列中的逗号分隔值与 pandas 中的行一样

我在 pandas 中有一个数据框,如下所述,其中列中的元素info与列中的唯一文件相同id

id   text         info
1    great        boy,police
1    excellent    boy,police
2    nice         girl,mother,teacher
2    good         girl,mother,teacher
2    bad          girl,mother,teacher
3    awesome      grandmother
4    superb       grandson
Run Code Online (Sandbox Code Playgroud)

我只想将列表元素作为每个文件的行,例如:

id   text         info
1    great        boy
1    excellent    police
2    nice         girl
2    good         mother
2    bad          teacher
3    awesome      grandmother
4    superb       grandson
Run Code Online (Sandbox Code Playgroud)

dataframe python-3.x pandas

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

标签 统计

dataframe ×1

pandas ×1

python-3.x ×1