Reputation: 83
I have an dataframe which looks like this:
ID Name
1-10000 Max
1-11000 Peter
1-12000 Hans
And I need to clean the prefix from the ID number to get a dataframe like this:
ID Name
10000 Max
11000 Peter
12000 Hans
Upvotes: 2
Views: 74
Reputation: 863301
You can split by -
and select by last lists for working correct if not exist -
in ID
:
df['ID'] = df['ID'].str.split('-').str[-1]
Upvotes: 2