[英]PANDAS : move a part of a sub-string to the end of the string based on condition
您可以使用:
after = df1['Title'].str.split('_', 1)
before = after.str[1].str.split('-', 1)
df1['new'] = after.str[0] + '-' + before.str[1] + '/' + before.str[0]
OUTPUT
Title new
0 WAW_WELCOME AIRPORT-Q3-2022 Facility WAW-Q3-2022 Facility/WELCOME AIRPORT
1 GVA_NEWREST INFLIGHT-Q3-2022 Cleaning GVA-Q3-2022 Cleaning/NEWREST INFLIGHT
2 AGP_RENTEVIC-Q3-2022 Office AGP-Q3-2022 Office/RENTEVIC
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.