<jupyter_start><jupyter_text>Data Analysis Pipeline 1) Load Data<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

data = pd.read_csv("database.csv")
data.head()
include = data.describe(percentiles=None, include= np.number, exclude=None)
include
exclude= data.describe(percentiles=None, include=None, exclude=np.number)
exclude<jupyter_output><empty_output><jupyter_text>2) Clean Data<jupyter_code>data1=data.drop(columns=['Unrounded City MPG (FT1)','Unrounded City MPG (FT2)','Highway Range (FT2)','Highway Range (FT1)','City Range (FT1)','City Range (FT2)',
                         'Composite Combined MPG','Composite Highway MPG','Composite City MPG','Manufacturer Code','Vehicle Charger','Alternate Charger','Hours to Charge (120V)'
                         ,'Hours to Charge (240V)','Hours to Charge (AC 240V)','Range (FT2)','4D Passenger Volume','4D Luggage Volume','Hatchback Passenger Volume',
                         'Hatchback Luggage Volume','Electric Motor','Gasoline/Electricity Blended (CD)','Tailpipe CO2 in Grams/Mile (FT2)','GHG Score','GHG Score (Alt Fuel)',
                         'My MPG Data','2D Passenger Volume','2D Luggage Volume','Tailpipe CO2 (FT1)','Tailpipe CO2 in Grams/Mile (FT1)','Tailpipe CO2 (FT2)','Start Stop Technology',
                         'Annual Consumption in Barrels (FT2)','Annual Fuel Cost (FT2)','Engine Index','Combined Electricity Consumption','Combined Gasoline Consumption (CD)','Combined Utility Factor'
                         ,'Gas Guzzler Tax','Range (FT1)','Alternative Fuel/Technology','Unrounded Combined MPG (FT2)','Combined MPG (FT2)','Unrounded Combined MPG (FT1)','Combined MPG (FT1)',
                        'Engine Descriptor','Highway Electricity Consumption','Highway Utility Factor','Unadjusted City MPG (FT1)','Unadjusted Highway MPG (FT1)','Unadjusted City MPG (FT2)',
                         'Unadjusted Highway MPG (FT2)','Transmission Descriptor','Engine Cylinders','Engine Displacement','City Utility Factor','Highway MPG (FT1)','Unrounded Highway MPG (FT1)',
                        'Highway MPG (FT2)','Unrounded Highway MPG (FT2)','Highway Gasoline Consumption (CD)','Turbocharger','Supercharger','Fuel Type 1','Fuel Type 2','City MPG (FT1)','City MPG (FT2)',
                        'City Gasoline Consumption (CD)','City Electricity Consumption','Vehicle ID'])
data1
data2=data1.dropna()
data2
data2 = data2.reset_index(drop=True)
data2<jupyter_output><empty_output><jupyter_text>3) Process Data<jupyter_code>data2['Overal_costs']= (data2['Annual Fuel Cost (FT1)']*5)-data2['Save or Spend (5 Year)']
data2
# creating a column to display how much money is spent on the vehicle over 5 years including fuel costs<jupyter_output><empty_output><jupyter_text>Task 2 Method chaining<jupyter_code>import pandas as pd
import numpy as np

data = pd.read_csv("database.csv")


data1=(pd.DataFrame(data.drop(columns=['Unrounded City MPG (FT1)','Unrounded City MPG (FT2)','Highway Range (FT2)','Highway Range (FT1)','City Range (FT1)','City Range (FT2)',
                         'Composite Combined MPG','Composite Highway MPG','Composite City MPG','Manufacturer Code','Vehicle Charger','Alternate Charger','Hours to Charge (120V)'
                         ,'Hours to Charge (240V)','Hours to Charge (AC 240V)','Range (FT2)','4D Passenger Volume','4D Luggage Volume','Hatchback Passenger Volume',
                         'Hatchback Luggage Volume','Electric Motor','Gasoline/Electricity Blended (CD)','Tailpipe CO2 in Grams/Mile (FT2)','GHG Score','GHG Score (Alt Fuel)',
                         'My MPG Data','2D Passenger Volume','2D Luggage Volume','Tailpipe CO2 (FT1)','Tailpipe CO2 in Grams/Mile (FT1)','Tailpipe CO2 (FT2)','Start Stop Technology',
                         'Annual Consumption in Barrels (FT2)','Annual Fuel Cost (FT2)','Engine Index','Combined Electricity Consumption','Combined Gasoline Consumption (CD)','Combined Utility Factor'
                         ,'Gas Guzzler Tax','Range (FT1)','Alternative Fuel/Technology','Unrounded Combined MPG (FT2)','Combined MPG (FT2)','Unrounded Combined MPG (FT1)','Combined MPG (FT1)',
                        'Engine Descriptor','Highway Electricity Consumption','Highway Utility Factor','Unadjusted City MPG (FT1)','Unadjusted Highway MPG (FT1)','Unadjusted City MPG (FT2)',
                         'Unadjusted Highway MPG (FT2)','Transmission Descriptor','Engine Cylinders','Engine Displacement','City Utility Factor','Highway MPG (FT1)','Unrounded Highway MPG (FT1)',
                        'Highway MPG (FT2)','Unrounded Highway MPG (FT2)','Highway Gasoline Consumption (CD)','Turbocharger','Supercharger','Fuel Type 1','Fuel Type 2','City MPG (FT1)','City MPG (FT2)',
                        'City Gasoline Consumption (CD)','City Electricity Consumption','Vehicle ID'])
                   .dropna()
                   .reset_index(drop=True)))

data1['Overal_costs']= (data1['Annual Fuel Cost (FT1)']*5)-data1['Save or Spend (5 Year)']
data1

import pandas as pd
import numpy as np

data = pd.read_csv("database.csv")


data1=(pd.DataFrame(data.drop(columns=['Unrounded City MPG (FT1)','Unrounded City MPG (FT2)','Highway Range (FT2)','Highway Range (FT1)','City Range (FT1)','City Range (FT2)',
                         'Composite Combined MPG','Composite Highway MPG','Composite City MPG','Manufacturer Code','Vehicle Charger','Alternate Charger','Hours to Charge (120V)'
                         ,'Hours to Charge (240V)','Hours to Charge (AC 240V)','Range (FT2)','4D Passenger Volume','4D Luggage Volume','Hatchback Passenger Volume',
                         'Hatchback Luggage Volume','Electric Motor','Gasoline/Electricity Blended (CD)','Tailpipe CO2 in Grams/Mile (FT2)','GHG Score','GHG Score (Alt Fuel)',
                         'My MPG Data','2D Passenger Volume','2D Luggage Volume','Tailpipe CO2 (FT1)','Tailpipe CO2 in Grams/Mile (FT1)','Tailpipe CO2 (FT2)','Start Stop Technology',
                         'Annual Consumption in Barrels (FT2)','Annual Fuel Cost (FT2)','Engine Index','Combined Electricity Consumption','Combined Gasoline Consumption (CD)','Combined Utility Factor'
                         ,'Gas Guzzler Tax','Range (FT1)','Alternative Fuel/Technology','Unrounded Combined MPG (FT2)','Combined MPG (FT2)','Unrounded Combined MPG (FT1)','Combined MPG (FT1)',
                        'Engine Descriptor','Highway Electricity Consumption','Highway Utility Factor','Unadjusted City MPG (FT1)','Unadjusted Highway MPG (FT1)','Unadjusted City MPG (FT2)',
                         'Unadjusted Highway MPG (FT2)','Transmission Descriptor','Engine Cylinders','Engine Displacement','City Utility Factor','Highway MPG (FT1)','Unrounded Highway MPG (FT1)',
                        'Highway MPG (FT2)','Unrounded Highway MPG (FT2)','Highway Gasoline Consumption (CD)','Turbocharger','Supercharger','Fuel Type 1','Fuel Type 2','City MPG (FT1)','City MPG (FT2)',
                        'City Gasoline Consumption (CD)','City Electricity Consumption','Vehicle ID'])
                   .dropna()
                   .reset_index(drop=True)
                   .assign(Overal_costs=data['Annual Fuel Cost (FT1)']*5-data['Save or Spend (5 Year)'])
                   ))


data1
def load_and_process(data):
    df1=(
    pd.read_csv("database.csv")
    .drop(columns=['Unrounded City MPG (FT1)','Unrounded City MPG (FT2)','Highway Range (FT2)','Highway Range (FT1)','City Range (FT1)','City Range (FT2)',
                         'Composite Combined MPG','Composite Highway MPG','Composite City MPG','Manufacturer Code','Vehicle Charger','Alternate Charger','Hours to Charge (120V)'
                         ,'Hours to Charge (240V)','Hours to Charge (AC 240V)','Range (FT2)','4D Passenger Volume','4D Luggage Volume','Hatchback Passenger Volume',
                         'Hatchback Luggage Volume','Electric Motor','Gasoline/Electricity Blended (CD)','Tailpipe CO2 in Grams/Mile (FT2)','GHG Score','GHG Score (Alt Fuel)',
                         'My MPG Data','2D Passenger Volume','2D Luggage Volume','Tailpipe CO2 (FT1)','Tailpipe CO2 in Grams/Mile (FT1)','Tailpipe CO2 (FT2)','Start Stop Technology',
                         'Annual Consumption in Barrels (FT2)','Annual Fuel Cost (FT2)','Engine Index','Combined Electricity Consumption','Combined Gasoline Consumption (CD)','Combined Utility Factor'
                         ,'Gas Guzzler Tax','Range (FT1)','Alternative Fuel/Technology','Unrounded Combined MPG (FT2)','Combined MPG (FT2)','Unrounded Combined MPG (FT1)','Combined MPG (FT1)',
                        'Engine Descriptor','Highway Electricity Consumption','Highway Utility Factor','Unadjusted City MPG (FT1)','Unadjusted Highway MPG (FT1)','Unadjusted City MPG (FT2)',
                         'Unadjusted Highway MPG (FT2)','Transmission Descriptor','Engine Cylinders','Engine Displacement','City Utility Factor','Highway MPG (FT1)','Unrounded Highway MPG (FT1)',
                        'Highway MPG (FT2)','Unrounded Highway MPG (FT2)','Highway Gasoline Consumption (CD)','Turbocharger','Supercharger','Fuel Type 1','Fuel Type 2','City MPG (FT1)','City MPG (FT2)',
                        'City Gasoline Consumption (CD)','City Electricity Consumption','Vehicle ID'])
        .dropna()
        .reset_index(drop=True))
    
    df2=(df1.assign(Overal_costs=data['Annual Fuel Cost (FT1)']*5-data['Save or Spend (5 Year)']))
                   
    
    return df2

print(load_and_process)<jupyter_output><function load_and_process at 0x7faf81d14e50><jupyter_text>Task 3<jupyter_code>sns.set_theme(context='notebook',
    style='whitegrid',
    palette='muted',
    font='sans-serif',
    font_scale=1,
    color_codes=True)
ax=sns.lineplot(x='Fuel Economy Score',y='Overal_costs',data=data1,palette='Greys')
ax
# this plot shows how fuel economy scores do relative to cost on the vehicle over a span of 5 years
ax= sns.boxplot(x='Fuel Economy Score',y='Fuel Type',data=data1, palette='Greys')
ax
#This plot is shows which fuel type is efficient based off fuel economy scores 
ax=sns.barplot(x='Annual Fuel Cost (FT1)',y='Fuel Type',data=data1, palette= 'Greys')
ax
# This plot shows the cost of fuel based off of the fuel type a vehicle is using on a yearly bases
ax= sns.violinplot(x='Overal_costs',y='Fuel Type',data=data1, palette='Blues')
ax
# This plot show the which fuel types can save or spend costs on a vehicle. 

fig_dims = (10, 5)
fig, ax = plt.subplots(figsize=fig_dims)
ax = sns.lineplot(y='Overal_costs',x='Year',data=data1, palette='Blues')
ax
# This plot shows depending on which year the car was made how much it would cost over a span of 5 years.<jupyter_output><empty_output><jupyter_text>Task 4Research Question: Based off of Fuel Econonmy estimates, which type of vehicle would save costs considering fuel consumption and costs of vehicle management over 5 years?Through my EDA I was able to see the cost of different fuels over a year. It allows me to process which cars can effective for use in lower budget households. With the the plots I'm able to analysis which model year the vehicle was made is sustainable for people wanting to save money in the long term. My overall costs takes a look at how much the vehicle will cost with gas in a span of 5 years.<jupyter_code>ax=sns.barplot(x='Annual Fuel Cost (FT1)',y='Fuel Type',data=data1, palette= 'Greys')
ax<jupyter_output><empty_output><jupyter_text>Figure 1With the information displayed in figure 1 we can see that costs of natural gas, gasoline or propane are much higher than the rest of the fuel types. On the other end we can see that electric and hybrid car have a much lower amount than the rest. With this data I can say that in order to save money on fuel it would be best to get a car that is fully electric or is a Hybrid car.<jupyter_code>fig_dims = (10, 5)
fig, ax = plt.subplots(figsize=fig_dims)
ax = sns.lineplot(y='Overal_costs',x='Year',data=data1, palette='Blues')
ax<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13240302350693578, 'fraction_numerical': 0.021596478112800067, 'mean_word_length': 4.03765690376569, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '518677', 'license': 'MIT', 'n_tokens_mistral': 3935, 'n_tokens_neox': 3621, 'n_words': 1100, 'path': 'analysis/Garnoork/Data Analysis Pipline.ipynb', 'repo_name': 'data301-2021-summer2/project-group34-project', 'size': '12039'}