Skip to content
Advertisement

How to split string and get only one word in python [closed]

I have a string similar like this:

JavaScript

I got this string from selecting row and column:

JavaScript

and I want to get the “PARIS” only to be in a new column which is ‘location_id’

I tried to split them, but it was hard for me to get the “PARIS” only.

How can I do this with python? Thank you

Advertisement

Answer

I would use Named groups. Say you have df;

JavaScript

Using Named Groups

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement