【发布时间】:2021-11-26 11:34:43
【问题描述】:
我有一个具有以下设置的数据集:
id string_to_parse
1 "a","b"
2 "a,b","c"
3 "c"
我需要把它放进去
id string_to_parse
1 a
1 b
2 a,b
2 c
3 c
我试过了
exploded_ = df['string_to_parse'].map(lambda x:x\
.replace('"','')\
.split(",")).explode()
除了速度很慢之外,它还错过了"a,b" 并将它们也拆分了。
【问题讨论】: