<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Basic Metrics
When we think about summarizing data, what are the metrics that we look at?
In this notebook, we will look at the car dataset
To read how the data was acquired, please read this repo to get more information
Step1:  Read the dataset
Step2:  Warm up
Step3:  Exercise
Step4:  How to handle missing values?
Step5:  Mean, Median, Variance, Standard Deviation
Mean
arithmetic average of a range of values or quantities, computed by dividing the total of all values by the number of values.
Step6:  Let's do something fancier.
Let's find mean mileage of every make. 
Hint
Step7:  Exercise
How about finding the average mileage for every Type-GearType combination?
Median
Denotes value or quantity lying at the midpoint of a frequency distribution of observed values or quantities, such that there is an equal probability of falling above or below it. Simply put, it is the middle value in the list of numbers.
If count is odd, the median is the value at (n+1)/2,
else it is the average of n/2 and (n+1)/2
Find median of mileage
Step8:  Mode
It is the number which appears most often in a set of numbers. 
Find the mode of Type of cars
Step9:  Variance
Once two statistician of height 4 feet and 5 feet have to cross a river of AVERAGE depth 3 feet. Meanwhile, a third person comes and said, "what are you waiting for? You can easily cross the river"
It's the average distance of the data values from the mean
<img style="float
Step10:  Standard Deviation
It is the square root of variance. This will have the same units as the data and mean. 
Find standard deviation of mileage
Step11:  Using Pandas built-in function
Step12:  Co-variance
covariance as a measure of the (average) co-variation between two variables, say x and y. Covariance describes both how far the variables are spread out, and the nature of their relationship, Covariance is a measure of how much two variables change together. Compare this to Variance, which is just the range over which one measure (or variable) varies.
<img style="float
Step13:  The number of observations have to be same. For the current exercise, let's take the first 300 observations in both the datasets
Step14:  Correlation
Extent to which two or more variables fluctuate together. A positive correlation indicates the extent to which those variables increase or decrease in parallel; a negative correlation indicates the extent to which one variable increases as the other decreases.
<img style="float
<ASSISTANT_TASK:>
Python Code:
#Import the required libraries
import numpy as np
import pandas as pd
from datetime import datetime as dt
from scipy import stats
Explanation: Basic Metrics
When we think about summarizing data, what are the metrics that we look at?
In this notebook, we will look at the car dataset
To read how the data was acquired, please read this repo to get more information
End of explanation
cars = pd.read_csv("cars_v1.csv", encoding = "ISO-8859-1")
Explanation: Read the dataset
End of explanation
cars.head()
Explanation: Warm up
End of explanation
#Display the first 10 records
cars.head(10)
#Display the last 5 records
cars.tail()
#Find the number of rows and columns in the dataset
cars.shape
#What are the column names in the dataset?
cars.columns
#What are the types of those columns ? 
cars.dtypes
cars.head()
#How to check if there are null values in any of the columns?
#Hint: use the isnull() function  (how about using sum or values/any with it?)
cars.isnull().sum()
Explanation: Exercise
End of explanation
#fillna function
Explanation: How to handle missing values?
End of explanation
#Find mean of price
cars.Price.mean()
#Find mean of Mileage
cars.Mileage.mean()
Explanation: Mean, Median, Variance, Standard Deviation
Mean
arithmetic average of a range of values or quantities, computed by dividing the total of all values by the number of values.
End of explanation
#cars.groupby('Make') : Finish the code
cars.groupby('Make').Mileage.mean().reset_index()
Explanation: Let's do something fancier.
Let's find mean mileage of every make. 
Hint: need to use groupby
End of explanation
cars.Mileage.median()
Explanation: Exercise
How about finding the average mileage for every Type-GearType combination?
Median
Denotes value or quantity lying at the midpoint of a frequency distribution of observed values or quantities, such that there is an equal probability of falling above or below it. Simply put, it is the middle value in the list of numbers.
If count is odd, the median is the value at (n+1)/2,
else it is the average of n/2 and (n+1)/2
Find median of mileage
End of explanation
#Let's first find count of each of the car Types
#Hint: use value_counts
cars.Type.value_counts()
#Mode of cars
cars.Type
cars.Type.mode()
cars.head()
Explanation: Mode
It is the number which appears most often in a set of numbers. 
Find the mode of Type of cars
End of explanation
cars.Mileage.var()
Explanation: Variance
Once two statistician of height 4 feet and 5 feet have to cross a river of AVERAGE depth 3 feet. Meanwhile, a third person comes and said, "what are you waiting for? You can easily cross the river"
It's the average distance of the data values from the mean
<img style="float: left;" src="img/variance.png" height="320" width="320">
Find variance of mileage
End of explanation
cars.Mileage.std()
Explanation: Standard Deviation
It is the square root of variance. This will have the same units as the data and mean. 
Find standard deviation of mileage
End of explanation
cars.describe()
Explanation: Using Pandas built-in function
End of explanation
pd.unique(cars.GearType)
cars_Automatic = cars[cars.GearType==' Automatic'].copy().reset_index()
cars_Manual = cars[cars.GearType==' Manual'].copy().reset_index()
cars_Automatic.head()
cars_Manual.head()
cars_Manual.shape
cars_Automatic.shape
Explanation: Co-variance
covariance as a measure of the (average) co-variation between two variables, say x and y. Covariance describes both how far the variables are spread out, and the nature of their relationship, Covariance is a measure of how much two variables change together. Compare this to Variance, which is just the range over which one measure (or variable) varies.
<img style="float: left;" src="img/covariance.png" height="270" width="270">
<br>
<br>
<br>
<br>
Co-variance of mileage of Automatic and Manual Gear Type
End of explanation
cars_Automatic = cars_Automatic.ix[:299,:]
cars_Manual = cars_Manual.ix[:299,:]
cars_Automatic.shape
cars_Manual.shape
cars_manual_automatic = pd.DataFrame([cars_Automatic.Mileage, cars_Manual.Mileage])
cars_manual_automatic
cars_manual_automatic = cars_manual_automatic.T
cars_manual_automatic.head()
cars_manual_automatic.columns = ['Mileage_Automatic', 'Mileage_Manual']
cars_manual_automatic.head()
#Co-variance matrix between the mileages of automatic and manual:
cars_manual_automatic.cov()
Explanation: The number of observations have to be same. For the current exercise, let's take the first 300 observations in both the datasets
End of explanation
#### Find the correlation between the mileages of automatic and manual in the above dataset
cars_manual_automatic.corr()
cars_manual_automatic.corrwith?
Explanation: Correlation
Extent to which two or more variables fluctuate together. A positive correlation indicates the extent to which those variables increase or decrease in parallel; a negative correlation indicates the extent to which one variable increases as the other decreases.
<img style="float: left;" src="img/correlation.gif" height="270" width="270">
<br>
<br>
<br>
End of explanation
<END_TASK>