Reputation: 2181
Here are a few examples:
Input
Col
"temp, temp2"
"name, inc., name2"
Output
Col_upd
["temp","temp2]
["name, inc.", "name2]
Right now, I'm using:
Col_upd.apply(lambda x: [i.lower().strip() for i in x.split(',')])
This fails in row 2 in the above example. I'm not sure what alternatives I have in this situation aside from your a dictionary.
Any suggestions would be really helpful.
Upvotes: 0
Views: 34
Reputation: 862
If we can assume that there's no extra commas in the second part, you can try to use rsplit()
.
Col_upd.apply(lambda x: [i.lower().strip() for i in x.rsplit(',', 1)])
str.rsplit()
lets you specify how many times to split.
Upvotes: 3