Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started