Questions refer to the Titanic data 1.Write a function that determines the number of missing entries for a specified column in the dataset.The function should return an`int`that corresponds to the...

1 answer below »
PFB


Questions refer to the Titanic data 1.Write a function that determines the number of missing entries for a specified column in the dataset.The function should return an`int`that corresponds to the number of missing entries in the specified column. 2. Write a function that takes in as input a dataframe and a column name, and returns the `mean` for numerical columns and the `mode` for non-numerical columns. 3. Write a function that returns the survival probability of a passenger, given a condition on a **numerical variable** from the dataset. The condition will consist of a `column_name`, a `value` and a `boolean_operator`. Possible boolean operators include `"<"`,`">"`, or `"=="`. For example, `column_name = "Age"`, `boolean_operator = ">"`, and `value = 40` together form the condition `Age > 40`.
Answered Same DayJul 28, 2021

Answer To: Questions refer to the Titanic data 1.Write a function that determines the number of missing entries...

Zubair answered on Aug 30 2021
156 Votes
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Exploring the Raw Titanic Dataset\n",
"© Explore Data Science Academy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Part of the journey to making a good regression model is to understand the data that we are modelling. To do this, we will perform some exploratory data analysis on the raw data from the [Titanic Kaggle Challenge](https://www.kaggle.com/c/titanic). T
he purpose of this challenge is to predict the probability of survival for a given passenger, given their boarding details."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"
\n",
" " alt=\"Titanic\"\n",
" style=\"float: center; padding-bottom=0.5em\"\n",
" width=600px/>\n",
"The RMS Titanic\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "RTgCNTpbOBNC"
},
"source": [
"### Honour Code"
]
},
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "gU0hL6yxOBNE"
},
"source": [
"I **YOUR NAME, YOUR SURNAME**, confirm - by submitting this document - that the solutions in this notebook are a result of my own work and that I abide by the EDSA honour code (https://drive.google.com/file/d/1QDCjGZJ8-FmJE3bZdIQNwnJyQKPhHZBn/view?usp=sharing). \n",
"\n",
"Non-compliance with the honour code constitutes a material breach of contract."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Imports"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv('https://raw.githubusercontent.com/Explore-AI/Public-Data/master/Data/regression_sprint/titanic_train_raw.csv')\n",
"df_clean = pd.read_csv('https://raw.githubusercontent.com/Explore-AI/Public-Data/master/Data/regression_sprint/titanic_train_clean_raw.csv')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": " PassengerId Survived Pclass \\\n0 1 0 3 \n1 2 1 1 \n2 3 1 3 \n3 4 1 1 \n4 5 0 3 \n\n Name Sex Age SibSp \\\n0 Braund, Mr. Owen Harris male 22.0 1 \n1 Cumings, Mrs. John Bradley (Florence Briggs Th... female 38.0 1 \n2 Heikkinen, Miss. Laina female 26.0 0 \n3 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35.0 1 \n4 Allen, Mr. William Henry male 35.0 0 \n\n Parch Ticket Fare Cabin Embarked \n0 0 A/5 21171 7.2500 NaN S \n1 0 PC 17599 71.2833 C85 C \n2 0 STON/O2. 3101282 7.9250 NaN S \n3 0 113803 53.1000 C123 S \n4 0 373450 8.0500 NaN S ",
"text/html": "
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here
PassengerIdSurvivedPclassNameSexAgeSibSpParchTicketFareCabinEmbarked
0103Braund, Mr. Owen Harrismale22.010A/5 211717.2500NaNS
1211Cumings, Mrs. John Bradley (Florence Briggs Th...female38.010PC 1759971.2833C85C