Answered step by step
Verified Expert Solution
Question
1 Approved Answer
# importing data # DON'T MODIFY THIS CELL from pandasql import sqldf import pandas as pd pysqldf = lambda q: sqldf(q, globals()) titanic =
\
# importing data # DON'T MODIFY THIS CELL
from pandasql import sqldf import pandas as pd pysqldf = lambda q: sqldf(q, globals()) titanic = pd.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/titanic.csv') titanic.head()
was the largest ship afloat at the time it was made. Unfortunately, the ship sank in its maiden voyage. In the following cells, you will see data about the passengers in Titanic. You will use SQL and Python techniques to parsel process data about those passengers. 1 1 : # importing data # DON'T MODIFY THIS CELL from pandasql import sqldf import pandas as pd pysqldf = lambda q: sqldf(q, globals()) titanic = pd. read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/ti titanic.head() : survived pclass sex age sibsp parch fare embarked class who adult_male deck 0 0 3 male 22.0 1 0 7.2500 S Third man True NaN 1 1 1 female 38.0 1 0 71.2833 First woman False 2 1 3 female 26.0 0 0 7.9250 S Third woman False NaN 3 1 1 female 35.0 1 0 53.1000 S First woman False 4 0 3 male 35.0 0 0 8.0500 S Third man True NaN adult_male deck embark_town alive alone True NaN Southampton no False False False NaN Cherbourg yes False Southampton yes True Southampton yes False False True NaN Southampton no True Q4 [20 points]: How many of the passengers were male and how many were female? : # guideline: must use SQL, along with Python # hint: pysqldf returns a Pandas dataframe Q5 [15 points]: What is the average fare for all passengers? . Q6 [15 points]: How many people embarked on Titanic from a place other than "Southampton"? : # guideline: must use SQL, along with Python Q7 [15 points]: How many first-class passengers survived after the accident? : # guideline: must use SQL, along with Python Q8 [15 points]: Show only the class and fare records of the female passengers who suvived, who embarked from Southampton and whose age were between 30 and 40. Order the record entries by fare paid. : # guideline: must use SQL, along with PythonStep 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