[英]How to split pandas some of data frame rows that are not lists?
Is there a way to change this data frame:有没有办法改变这个数据框:
40 4.5 95
41 1.76 95
112 0.17/0.43 >95/>95
to this using pandas:为此使用 pandas:
40 4.5 95
41 1.76 95
112 0.17 95
112 0.43 95
This is the pandas dataframe:这是 pandas dataframe:
a b
19 560 80
40 4.5 95
41 1.76 95
112 0.17/0.43 >95/>95
154 7.2/1 >95/>95
... ... ...
2991 55 95
2992 33 95
3887 6.1 87.7
3893 3.9 70.3
3908 100 40
216 rows × 2 columns
I would use explode
:我会使用
explode
:
df = df.apply(lambda x: x.astype(str).str.split('/').explode(ignore_index=True))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.