python - split string column by "_", drop the preceding text, recombine str by "_" in pandas - Stack Overflow

PHOTO EMBED

Mon Aug 08 2022 00:49:36 GMT+0000 (Coordinated Universal Time)

Saved by [deleted user] #python

In [85]: df[0].str.split('_').str[1:].str.join('_')
Out[85]:
0    toronto_maple-leafs_Canada
1              boston_bruins_US
2             detroit_red-wings
3                      montreal
Name: 0, dtype: object
content_copyCOPY

https://stackoverflow.com/questions/29993761/split-string-column-by-drop-the-preceding-text-recombine-str-by-in-pan