I have a column with the values like these
EUR, London , Germany
USD , New York , Boston, Canada
INR , Delhi, Mumbai
I am trying to extract the portion after the first ',' into another column, something like this
Desired output:
London , Germany
New York , Boston, Canada
Delhi, Mumbai
but, when I use Events['Col2'] = Events['OriginalColumn'].str.split(',').str[1:7], I get the desired however its in array, I dont the result to be come in square brackets and in quotes. Below is what I get
[' London','Germany']
[' New York','Boston','Canada']
['Delhi', 'Mumbai']
Is there a way in which we can avoid the square brackets and the quotes. thanks in advance.
I'm assuming the column you are referring to is a column in a pandas DataFrame. In that case you can use the parameter n
of pandas.Series.str.split
to limit the number of splits to one, e.g.
Events['Col2'] = Events['OriginalColumn'].str.split(',', n=1).str[1]