[英]Extract multiple pattern from string pandas
使用从数据集中的列中提取的中间和最后一个字符串创建新列。
数据
Status ID
Ok hello_dd
Ok hello_aa_now
No standard_cc
no standard_ee_not
想要的
Status ID type
Ok hello_dd dd
Ok hello_aa_now aa
No standard_cc cc
no standard_ee_not ee
正在做
我能够提取最后一个字符串,但是,仍在研究如何提取中间字符串。
df['type'] = df['ID'].str.strip('_').str[-1]
任何建议表示赞赏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.