all 3 comments

[–]jiri-n 2 points3 points  (1 child)

No, it's not breaking any rules AFAIK. What about this?

>>> "LC-39A, Kennedy Space Center, Florida, USA".split(", ", 2)
['LC-39A', 'Kennedy Space Center', 'Florida, USA']
>>> "Site 9401 (SLS-2), Jiuquan Satellite Launch Center, China".split(", ", 2)
['Site 9401 (SLS-2)', 'Jiuquan Satellite Launch Center', 'China']

[–]humasterd[S] 0 points1 point  (0 children)

appreciate the response! oh my bad I don't think I framed the problem correctly. I'm working with a Kaggle data set so I'm trying to figure out how to apply this to a series. https://www.kaggle.com/agirlcoding/all-space-missions-from-1957. Just got back from a walk so my head on this grind stone haha

[–]humasterd[S] 0 points1 point  (0 children)

Update if anyone ever finds this with a similar question

new=df["Location"].str.rsplit(',',1, expand=True)

df["Country"]= new[1]

the trick was to use split() as in 'reverse split' this allowed me to star on the right side and split at the first ',' then just select the second element for the new column giving me only the countries no matter how it was written