<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Generate Summary Statistics
In this notebook we are going to generate summary statistics for our data.
Generate Summary Statistics for the Entire Dataset
Step1:  Generate Summary Statistics for the Entire Dataset
Step2:  Generate Summary Statistics for Object Type Columns
Step3:  Get the Mode of the Entire Dataset
Step4:  Generate Summary Statistics for a Single Column
Generate Summary Statistics for a Single Column
Step5:  Get a Count of Unique Values for a Single Column
Step6:  Get the Minimum and Maximum of a Single Column
Step7:  Generate Quantiles for a Single Column
Step8:  Get the Mean, Median, Mode and Range for a Single Column
<ASSISTANT_TASK:>
Python Code:
# Import the libraries we need
import pandas as pd
# Import the dataset from the CSV file
accidents_data_file = '/Users/robert.dempsey/Dropbox/Private/Art of Skill Hacking/' \
                      'Books/Python Business Intelligence Cookbook/Data/Stats19-Data1979-2004/Accidents7904.csv'
accidents = pd.read_csv(accidents_data_file,
                        sep=',',
                        header=0,
                        index_col=False,
                        parse_dates=['Date'],
                        dayfirst=True,
                        tupleize_cols=False,
                        error_bad_lines=True,
                        warn_bad_lines=True,
                        skip_blank_lines=True,
                        low_memory=False
                        )
accidents.head()
Explanation: Generate Summary Statistics
In this notebook we are going to generate summary statistics for our data.
Generate Summary Statistics for the Entire Dataset
End of explanation
# Use the describe function to generate summary stats for the entire dataset
accidents.describe()
# Transpose the results provided by describe()
accidents.describe().transpose()
Explanation: Generate Summary Statistics for the Entire Dataset
End of explanation
# By default describe() restricts the stats to numerical or categorical columns. Use the following to include object columns
accidents.describe(include=['object'])
Explanation: Generate Summary Statistics for Object Type Columns
End of explanation
# Show the mode of each column and transpose it so we can read everything in iPython Notebook
accidents.mode().transpose()
Explanation: Get the Mode of the Entire Dataset
End of explanation
accidents['Weather_Conditions'].describe()
Explanation: Generate Summary Statistics for a Single Column
Generate Summary Statistics for a Single Column
End of explanation
# Get the count of each unique value in the Date column.
pd.value_counts(accidents['Date'])
Explanation: Get a Count of Unique Values for a Single Column
End of explanation
# Get the count of each unique value in the Date column.
print("Min Value: {}".format(accidents['Number_of_Vehicles'].min()))
print("Max Value: {}".format(accidents['Number_of_Vehicles'].max()))
Explanation: Get the Minimum and Maximum of a Single Column
End of explanation
accidents['Number_of_Vehicles'].quantile([.05, .1, .25, .5, .75, .9, .99])
Explanation: Generate Quantiles for a Single Column
End of explanation
# Mean: the average
# Median: the middle value 
# Mode: the value that occurs most often
# Range: the difference between the minimum and maximum values
print("Mean: {}".format(accidents['Number_of_Vehicles'].mean()))
print("Median: {}".format(accidents['Number_of_Vehicles'].median()))
print("Mode: {}".format(accidents['Number_of_Vehicles'].mode()))
print("Range: {}".format(
        range(accidents['Number_of_Vehicles'].min(), 
              accidents['Number_of_Vehicles'].max()
             )
    ))
Explanation: Get the Mean, Median, Mode and Range for a Single Column
End of explanation
<END_TASK>