Reputation: 210
I have the following Pandas Dataframe:
Name | ID |
---|---|
AT_A | 1 |
AT_B | 2 |
AOS_PAR_F | 3 |
AOS_ROOT_LE_B | 4 |
I want to create a new column which would hold the string from column "Name" which is before the last "_" character and remove it from the original column.
So the desired output would be:
Name | ID | Name_2 |
---|---|---|
A | 1 | AT |
B | 2 | AT |
F | 3 | AOS_PAR |
B | 4 | AOS_ROOT_LE |
Any ideas?
Upvotes: 0
Views: 940