Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the sample script with questions for HW1. Questions are marked in this script, and please write the answer using Python code for each

This is the sample script with questions for HW1.

Questions are marked in this script, and please write the answer using Python code for each question. Each student needs to submit a python script (.py file).

Part I: Basic pandas data manipulation (60pt) Please answer the following question. You only need one line of code to answer each question.

'''

# Q1: Read the train.csv file as a pandas dataframe. (10pt) # It is Titanic dataset and definition of columns can be found: https://www.kaggle.com/c/titanic/data?select=train.csv

# Q2: Print the top 3 rows of the dataframe. (5pt)

# Q3: Only print 4 selected columns including: survival, pclass, sex and cabin. (10pt)

# Q4: Only print survived people who are older than 50 or have pclass = 1. (15pt)

# Q5: Print average fare by pclass. (10pt) # Hint: the result should include 2 columns: pclass and average fare

# Q6: Print the survival rate for each pclass. (10pt) # (Hint: survival rate can be calculbated as the number of survived people divide by total number of passengers)

''' Part II: Data Collection using API 40pt Using Yelp API to finish the following tasks. Please refer to Yelp Developer website for detailed documentation: https://www.yelp.com/developers. '''

# Q1: Using Yelp business search API to search for sandwich stores near your home and get the search resutls. You can search by keyword "sandwich". You can go to Yelp website and search by the same criteria to check your results. (15pt)

# Q2: Print the name (and only print name) of 10 businesses from your results. If there are less than 10 businesses in your search result, please return all of their names. (10pt)

# Q3: Make a dataframe with 3 columns: "name", "rating" and "review_count". The dataframe should store business information you get from previous steps. (10pt)

# Q4: Write the code to export the dataframe into a csv file. (5pt)

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

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

1.. What is meant by productive capacity in services?

Answered: 1 week ago

Question

technologies on organizations.

Answered: 1 week ago

Question

=+8. Why is productivity important?

Answered: 1 week ago

Question

=+ 9. What is inflation and what causes it?

Answered: 1 week ago