Reputation: 191
i have a column that has a series of words and i need to transform it to a list and assign to the same column. I tried with a for loop but it has so many lines it takes too long
Here's the dataset:
name hobbies
0 James "study","play"
1 Harden "dance,"jump"
And i need to transform it to:
name hobbies
0 James ["study","play"]
1 Harden ["dance","jump"]
Upvotes: 1
Views: 26
Reputation: 862511
Use Series.str.split
:
df['hobbies'] = df['hobbies'].str.split(',')
Upvotes: 1