【发布时间】:2020-12-08 18:57:15
【问题描述】:
您好,我有分组的 pandas 数据框想要取消分组数据框,列值用逗号分隔,数据框如下所示
col1 col2 name exams
0,0,0 0,0,0, A1 exm1,exm2, exm3
0,1,0,20 0,0,2,20 A2 exm1,exm2, exm4, exm5
0,0,0,30 0,0,20,20 A3 exm1,exm2, exm3, exm5
输出我想要的方式
col1 col2 name exam
0 0 A1 exm1
0 0 A1 exm2
0 0 A1 exm3
0 0 A2 exm1
1 0 A2 exm2
0 2 A2 exm4
20 20 A2 exm5
..............
30 20 A3 exm5
我尝试使用Split (explode) pandas dataframe string entry to separate rows ,但无法获得正确的方法任何人请给我建议如何获得我的输出
【问题讨论】:
-
拆分后多列爆炸......
-
@BEN_YO 我试过它的显示 nameError: name 'explode' is not defined
标签: python-3.x pandas