Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def csv_cleaner(input_file): ''' Question - Read michelin.csv with CSV module and return a list of lists containing each cleaned row. - Make sure to include

def csv_cleaner(input_file): ''' Question - Read michelin.csv with CSV module and return a list of lists containing each cleaned row. - Make sure to include the headers - There are 3 issues with the csv that must be fixed: 1. Combine the last 2 columns to make one column. Rename this to be 'Cuisine Type' 2. Remove any excess white space from the new column, 'Cuisine Type', as well as the column titled 'Country' 3. Fill in all empty spaces in the 'Price' column with the average (as an integer) of the total price in an equivalent string format - 1 is equivalent to $ - 2 is equivalent to $$ - 3 is equivalent to $$$ and so on - Average is equal to the total dollar signs / total number of rows - Write the list of lists to a new csv file called 'clean_michelin.csv' to use for Question - Make sure to write to the new csv file before the return statement

Args: input_file(michelin.csv) Returns: Nested list

Expected Output: [['', 'Unnamed: 0', 'Restaurant Name', 'Number of Stars', 'City', 'Country', 'Price', 'Cuisine Type'], ... ['3', '3', 'Bottiglieria 1881', '1', 'Cracow', 'Poland', '$$$', 'Creative']]

'''

michelin.csv

,Unnamed: 0,Restaurant Name,Number of Stars,City,Country,Price,Cuisine_type_1,Cuisine_type_1.1 0,0,essncia,1,Budapest, Hungary,$$$,, Modern Cuisine 1,1,Babel,1,Budapest, Hungary,$$$$,Modern Cuisine, 2,2,Borkonyha Winekitchen,1,Budapest, Hungary,$$,Modern Cuisine, 3,3,Bottiglieria 1881,1,Cracow, Poland,$$$,Creative,

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

Step: 3

blur-text-image

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

PostgreSQL 10 High Performance Expert Techniques For Query Optimization High Availability And Efficient Database Maintenance

Authors: Ibrar Ahmed ,Gregory Smith ,Enrico Pirozzi

3rd Edition

1788474481, 978-1788474481

More Books

Students also viewed these Databases questions

Question

Determine a sensible structure for the dissertation AppendixLO1

Answered: 1 week ago