Question: Write code to convert the values of genres column into a list of strings instead of a list of dictionaries, keeping only the value of
Write code to convert the values of genres column into a list of strings instead of a list of dictionaries, keeping only the value of the "name" attribute
I want to modify my data in my dataframe by using panda in python. What function in panda can I use?
genres genres
1 [{'id': 16, 'name': 'Animation'}, {'id': 35, 'name': 'Comedy'}, {'id': 10751, 'name': 'Family'}] ------>To something like-------> 1 ['Animation','Comedey','Family']
2 [{'id': 16, 'name': 'Animation'}, {'id': 35, 'name': 'Comedy'}] 2 ['Animation','Comedey']
3 [{'id': 16, 'name': 'Animation'}, {'id': 35, 'name': 'Comedy'}, {'id': 103, 'name': 'lol'}] 3 ['Animation','Comedey','lol']
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
