Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Can you help me to find what is the error? Jungkook is a dataframe by using panda liberary. Please solve the question by using panda.

Can you help me to find what is the error? Jungkook is a dataframe by using panda liberary. Please solve the question by using panda. Beacause Jungkook is very large (more than 40000 rows) I'll only show you the first two row by using head function.

image text in transcribedimage text in transcribed

3.2 You might have noticed that the data of the genres column is represented as a list of dictionaries. Let's change this format into an easier one. 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. For example, the value Fid': 16, 'name': 'Animation', [id: 35, 'name': 'Comedy1, tid: 10751, 'name: 'Family')l should be ['Animation', Comedey,Family]. The newly converted values should be stored in an extra new column called "genres_cleaned". (4 Marks) You should display the first 5 rows of the movies dataframe after adding this new column. The output of this question should be in the following format: Q3.2 The first 5 rows after adding the "genres_cleaned" column are: where # is the first 5 rows in the movies dataframe In [29]: def dictolist(list_of_dic): for i in range (,len(list_of_dic)): a.append(list_of_dic[i]["name"]) return (a) In [49]: ### answer 03.2 def dictolist (list_of_dic): for i in range(e,len(list_of_dic)): a.append(list_of dic[i]["name"]) return(a) Jungkook[ genres_cleaned'-Jungkook.genres.apply(dictolist) Traceback (most recent call last) TypeError in () 19 11 Jungkook[ 'genres_cleaned'-Jungkook.genres.apply (dictolist) Anaconda3\liblsite-packages\pandas\corelseries.py in apply(self, func, convert_dtype, args,**kwds) 3190 3191 ->3192 3193 3194 else: valuesself.astype (object).values mapped-lib.map_infer(values, f, convert-convert_dtype) if len (mapped) and isinstance (mapped[e], Series) pandas/_libs/src\inference.pyx in pandas._libs.lib.map_infer

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students explore these related Databases questions