{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "df=pd.read_csv('car data.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Car_Name</th>\n",
       "      <th>Year</th>\n",
       "      <th>Selling_Price</th>\n",
       "      <th>Present_Price</th>\n",
       "      <th>Kms_Driven</th>\n",
       "      <th>Fuel_Type</th>\n",
       "      <th>Seller_Type</th>\n",
       "      <th>Transmission</th>\n",
       "      <th>Owner</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>ritz</td>\n",
       "      <td>2014</td>\n",
       "      <td>3.35</td>\n",
       "      <td>5.59</td>\n",
       "      <td>27000</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>sx4</td>\n",
       "      <td>2013</td>\n",
       "      <td>4.75</td>\n",
       "      <td>9.54</td>\n",
       "      <td>43000</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ciaz</td>\n",
       "      <td>2017</td>\n",
       "      <td>7.25</td>\n",
       "      <td>9.85</td>\n",
       "      <td>6900</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>wagon r</td>\n",
       "      <td>2011</td>\n",
       "      <td>2.85</td>\n",
       "      <td>4.15</td>\n",
       "      <td>5200</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>swift</td>\n",
       "      <td>2014</td>\n",
       "      <td>4.60</td>\n",
       "      <td>6.87</td>\n",
       "      <td>42450</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Car_Name  Year  Selling_Price  Present_Price  Kms_Driven Fuel_Type  \\\n",
       "0     ritz  2014           3.35           5.59       27000    Petrol   \n",
       "1      sx4  2013           4.75           9.54       43000    Diesel   \n",
       "2     ciaz  2017           7.25           9.85        6900    Petrol   \n",
       "3  wagon r  2011           2.85           4.15        5200    Petrol   \n",
       "4    swift  2014           4.60           6.87       42450    Diesel   \n",
       "\n",
       "  Seller_Type Transmission  Owner  \n",
       "0      Dealer       Manual      0  \n",
       "1      Dealer       Manual      0  \n",
       "2      Dealer       Manual      0  \n",
       "3      Dealer       Manual      0  \n",
       "4      Dealer       Manual      0  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(301, 9)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Dealer' 'Individual']\n"
     ]
    }
   ],
   "source": [
    "print(df['Seller_Type'].unique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Manual' 'Automatic']\n"
     ]
    }
   ],
   "source": [
    "print(df['Transmission'].unique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0 1 3]\n"
     ]
    }
   ],
   "source": [
    "print(df['Owner'].unique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Petrol' 'Diesel' 'CNG']\n"
     ]
    }
   ],
   "source": [
    "print(df['Fuel_Type'].unique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "##CHECKING missing or null values\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Car_Name         0\n",
       "Year             0\n",
       "Selling_Price    0\n",
       "Present_Price    0\n",
       "Kms_Driven       0\n",
       "Fuel_Type        0\n",
       "Seller_Type      0\n",
       "Transmission     0\n",
       "Owner            0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>Selling_Price</th>\n",
       "      <th>Present_Price</th>\n",
       "      <th>Kms_Driven</th>\n",
       "      <th>Owner</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>301.000000</td>\n",
       "      <td>301.000000</td>\n",
       "      <td>301.000000</td>\n",
       "      <td>301.000000</td>\n",
       "      <td>301.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>2013.627907</td>\n",
       "      <td>4.661296</td>\n",
       "      <td>7.628472</td>\n",
       "      <td>36947.205980</td>\n",
       "      <td>0.043189</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>2.891554</td>\n",
       "      <td>5.082812</td>\n",
       "      <td>8.644115</td>\n",
       "      <td>38886.883882</td>\n",
       "      <td>0.247915</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>2003.000000</td>\n",
       "      <td>0.100000</td>\n",
       "      <td>0.320000</td>\n",
       "      <td>500.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>2012.000000</td>\n",
       "      <td>0.900000</td>\n",
       "      <td>1.200000</td>\n",
       "      <td>15000.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>2014.000000</td>\n",
       "      <td>3.600000</td>\n",
       "      <td>6.400000</td>\n",
       "      <td>32000.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>2016.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>9.900000</td>\n",
       "      <td>48767.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>2018.000000</td>\n",
       "      <td>35.000000</td>\n",
       "      <td>92.600000</td>\n",
       "      <td>500000.000000</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              Year  Selling_Price  Present_Price     Kms_Driven       Owner\n",
       "count   301.000000     301.000000     301.000000     301.000000  301.000000\n",
       "mean   2013.627907       4.661296       7.628472   36947.205980    0.043189\n",
       "std       2.891554       5.082812       8.644115   38886.883882    0.247915\n",
       "min    2003.000000       0.100000       0.320000     500.000000    0.000000\n",
       "25%    2012.000000       0.900000       1.200000   15000.000000    0.000000\n",
       "50%    2014.000000       3.600000       6.400000   32000.000000    0.000000\n",
       "75%    2016.000000       6.000000       9.900000   48767.000000    0.000000\n",
       "max    2018.000000      35.000000      92.600000  500000.000000    3.000000"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Car_Name', 'Year', 'Selling_Price', 'Present_Price', 'Kms_Driven',\n",
       "       'Fuel_Type', 'Seller_Type', 'Transmission', 'Owner'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "##VIEWING ALL COLUMNS NAME ONLY \n",
    "df.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "##REMOVING CAR NAME FROM DATASET SINCE IT WILL NOT PREDICT THE PRICE "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "final_dataset=df[['Year', 'Selling_Price', 'Present_Price', 'Kms_Driven',\n",
    "       'Fuel_Type', 'Seller_Type', 'Transmission', 'Owner']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>Selling_Price</th>\n",
       "      <th>Present_Price</th>\n",
       "      <th>Kms_Driven</th>\n",
       "      <th>Fuel_Type</th>\n",
       "      <th>Seller_Type</th>\n",
       "      <th>Transmission</th>\n",
       "      <th>Owner</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2014</td>\n",
       "      <td>3.35</td>\n",
       "      <td>5.59</td>\n",
       "      <td>27000</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2013</td>\n",
       "      <td>4.75</td>\n",
       "      <td>9.54</td>\n",
       "      <td>43000</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2017</td>\n",
       "      <td>7.25</td>\n",
       "      <td>9.85</td>\n",
       "      <td>6900</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2011</td>\n",
       "      <td>2.85</td>\n",
       "      <td>4.15</td>\n",
       "      <td>5200</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2014</td>\n",
       "      <td>4.60</td>\n",
       "      <td>6.87</td>\n",
       "      <td>42450</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Year  Selling_Price  Present_Price  Kms_Driven Fuel_Type Seller_Type  \\\n",
       "0  2014           3.35           5.59       27000    Petrol      Dealer   \n",
       "1  2013           4.75           9.54       43000    Diesel      Dealer   \n",
       "2  2017           7.25           9.85        6900    Petrol      Dealer   \n",
       "3  2011           2.85           4.15        5200    Petrol      Dealer   \n",
       "4  2014           4.60           6.87       42450    Diesel      Dealer   \n",
       "\n",
       "  Transmission  Owner  \n",
       "0       Manual      0  \n",
       "1       Manual      0  \n",
       "2       Manual      0  \n",
       "3       Manual      0  \n",
       "4       Manual      0  "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "final_dataset.head()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "#ADDING OUR OWN COLUMN/FEATURE IN THE DATA SET AS CURRENT YEAR "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>Selling_Price</th>\n",
       "      <th>Present_Price</th>\n",
       "      <th>Kms_Driven</th>\n",
       "      <th>Fuel_Type</th>\n",
       "      <th>Seller_Type</th>\n",
       "      <th>Transmission</th>\n",
       "      <th>Owner</th>\n",
       "      <th>Current_Year</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2014</td>\n",
       "      <td>3.35</td>\n",
       "      <td>5.59</td>\n",
       "      <td>27000</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2013</td>\n",
       "      <td>4.75</td>\n",
       "      <td>9.54</td>\n",
       "      <td>43000</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2017</td>\n",
       "      <td>7.25</td>\n",
       "      <td>9.85</td>\n",
       "      <td>6900</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2011</td>\n",
       "      <td>2.85</td>\n",
       "      <td>4.15</td>\n",
       "      <td>5200</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2014</td>\n",
       "      <td>4.60</td>\n",
       "      <td>6.87</td>\n",
       "      <td>42450</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Year  Selling_Price  Present_Price  Kms_Driven Fuel_Type Seller_Type  \\\n",
       "0  2014           3.35           5.59       27000    Petrol      Dealer   \n",
       "1  2013           4.75           9.54       43000    Diesel      Dealer   \n",
       "2  2017           7.25           9.85        6900    Petrol      Dealer   \n",
       "3  2011           2.85           4.15        5200    Petrol      Dealer   \n",
       "4  2014           4.60           6.87       42450    Diesel      Dealer   \n",
       "\n",
       "  Transmission  Owner  Current_Year  \n",
       "0       Manual      0          2020  \n",
       "1       Manual      0          2020  \n",
       "2       Manual      0          2020  \n",
       "3       Manual      0          2020  \n",
       "4       Manual      0          2020  "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "final_dataset['Current_Year']=2020\n",
    "final_dataset.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "##ADDING ANOTHER COLUMN NO_YEAR\n",
    "## SUBSTRACTING CURRENT YEAR AND YEAR TO GIVE VALUE OF NO_YEAR AND DISPLAYING IT \n",
    "  \n",
    "final_dataset['no_year']=final_dataset['Current_Year']-final_dataset['Year']\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>Selling_Price</th>\n",
       "      <th>Present_Price</th>\n",
       "      <th>Kms_Driven</th>\n",
       "      <th>Fuel_Type</th>\n",
       "      <th>Seller_Type</th>\n",
       "      <th>Transmission</th>\n",
       "      <th>Owner</th>\n",
       "      <th>Current_Year</th>\n",
       "      <th>no_year</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2014</td>\n",
       "      <td>3.35</td>\n",
       "      <td>5.59</td>\n",
       "      <td>27000</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2013</td>\n",
       "      <td>4.75</td>\n",
       "      <td>9.54</td>\n",
       "      <td>43000</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2017</td>\n",
       "      <td>7.25</td>\n",
       "      <td>9.85</td>\n",
       "      <td>6900</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2011</td>\n",
       "      <td>2.85</td>\n",
       "      <td>4.15</td>\n",
       "      <td>5200</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2014</td>\n",
       "      <td>4.60</td>\n",
       "      <td>6.87</td>\n",
       "      <td>42450</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Year  Selling_Price  Present_Price  Kms_Driven Fuel_Type Seller_Type  \\\n",
       "0  2014           3.35           5.59       27000    Petrol      Dealer   \n",
       "1  2013           4.75           9.54       43000    Diesel      Dealer   \n",
       "2  2017           7.25           9.85        6900    Petrol      Dealer   \n",
       "3  2011           2.85           4.15        5200    Petrol      Dealer   \n",
       "4  2014           4.60           6.87       42450    Diesel      Dealer   \n",
       "\n",
       "  Transmission  Owner  Current_Year  no_year  \n",
       "0       Manual      0          2020        6  \n",
       "1       Manual      0          2020        7  \n",
       "2       Manual      0          2020        3  \n",
       "3       Manual      0          2020        9  \n",
       "4       Manual      0          2020        6  "
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "final_dataset.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Selling_Price</th>\n",
       "      <th>Present_Price</th>\n",
       "      <th>Kms_Driven</th>\n",
       "      <th>Fuel_Type</th>\n",
       "      <th>Seller_Type</th>\n",
       "      <th>Transmission</th>\n",
       "      <th>Owner</th>\n",
       "      <th>Current_Year</th>\n",
       "      <th>no_year</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3.35</td>\n",
       "      <td>5.59</td>\n",
       "      <td>27000</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4.75</td>\n",
       "      <td>9.54</td>\n",
       "      <td>43000</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>7.25</td>\n",
       "      <td>9.85</td>\n",
       "      <td>6900</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2.85</td>\n",
       "      <td>4.15</td>\n",
       "      <td>5200</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4.60</td>\n",
       "      <td>6.87</td>\n",
       "      <td>42450</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Selling_Price  Present_Price  Kms_Driven Fuel_Type Seller_Type  \\\n",
       "0           3.35           5.59       27000    Petrol      Dealer   \n",
       "1           4.75           9.54       43000    Diesel      Dealer   \n",
       "2           7.25           9.85        6900    Petrol      Dealer   \n",
       "3           2.85           4.15        5200    Petrol      Dealer   \n",
       "4           4.60           6.87       42450    Diesel      Dealer   \n",
       "\n",
       "  Transmission  Owner  Current_Year  no_year  \n",
       "0       Manual      0          2020        6  \n",
       "1       Manual      0          2020        7  \n",
       "2       Manual      0          2020        3  \n",
       "3       Manual      0          2020        9  \n",
       "4       Manual      0          2020        6  "
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "##REMOVING YEAR COLUMN\n",
    "## AXIS MEANS, 0=ROW, 1= COLUMN, INPLACE =TRUE MEANS IT SAVES AFTER, FALSE MEANS JUST FOR ONE TIME \n",
    "\n",
    "final_dataset.drop(['Year'],axis=1,inplace=True)\n",
    "final_dataset.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Selling_Price</th>\n",
       "      <th>Present_Price</th>\n",
       "      <th>Kms_Driven</th>\n",
       "      <th>Fuel_Type</th>\n",
       "      <th>Seller_Type</th>\n",
       "      <th>Transmission</th>\n",
       "      <th>Owner</th>\n",
       "      <th>no_year</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3.35</td>\n",
       "      <td>5.59</td>\n",
       "      <td>27000</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4.75</td>\n",
       "      <td>9.54</td>\n",
       "      <td>43000</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>7.25</td>\n",
       "      <td>9.85</td>\n",
       "      <td>6900</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2.85</td>\n",
       "      <td>4.15</td>\n",
       "      <td>5200</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4.60</td>\n",
       "      <td>6.87</td>\n",
       "      <td>42450</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Selling_Price  Present_Price  Kms_Driven Fuel_Type Seller_Type  \\\n",
       "0           3.35           5.59       27000    Petrol      Dealer   \n",
       "1           4.75           9.54       43000    Diesel      Dealer   \n",
       "2           7.25           9.85        6900    Petrol      Dealer   \n",
       "3           2.85           4.15        5200    Petrol      Dealer   \n",
       "4           4.60           6.87       42450    Diesel      Dealer   \n",
       "\n",
       "  Transmission  Owner  no_year  \n",
       "0       Manual      0        6  \n",
       "1       Manual      0        7  \n",
       "2       Manual      0        3  \n",
       "3       Manual      0        9  \n",
       "4       Manual      0        6  "
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "##REMOVING CURRENT YEAR USING DROP\n",
    "final_dataset.drop(['Current_Year'],axis=1,inplace=True)\n",
    "final_dataset.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "##REMOVING THE DUMMIES VARIABLES SUCH AS FUELTYPE, SELLER TYPE, TRANSMISSION AND DROPPING THE FIRST COLUMN\n",
    "##ALSO KNOWN AS ONE HOT ENCODED \n",
    "\n",
    "final_dataset=pd.get_dummies(final_dataset,drop_first=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Selling_Price</th>\n",
       "      <th>Present_Price</th>\n",
       "      <th>Kms_Driven</th>\n",
       "      <th>Owner</th>\n",
       "      <th>no_year</th>\n",
       "      <th>Fuel_Type_Diesel</th>\n",
       "      <th>Fuel_Type_Petrol</th>\n",
       "      <th>Seller_Type_Individual</th>\n",
       "      <th>Transmission_Manual</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3.35</td>\n",
       "      <td>5.59</td>\n",
       "      <td>27000</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4.75</td>\n",
       "      <td>9.54</td>\n",
       "      <td>43000</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>7.25</td>\n",
       "      <td>9.85</td>\n",
       "      <td>6900</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2.85</td>\n",
       "      <td>4.15</td>\n",
       "      <td>5200</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4.60</td>\n",
       "      <td>6.87</td>\n",
       "      <td>42450</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Selling_Price  Present_Price  Kms_Driven  Owner  no_year  Fuel_Type_Diesel  \\\n",
       "0           3.35           5.59       27000      0        6                 0   \n",
       "1           4.75           9.54       43000      0        7                 1   \n",
       "2           7.25           9.85        6900      0        3                 0   \n",
       "3           2.85           4.15        5200      0        9                 0   \n",
       "4           4.60           6.87       42450      0        6                 1   \n",
       "\n",
       "   Fuel_Type_Petrol  Seller_Type_Individual  Transmission_Manual  \n",
       "0                 1                       0                    1  \n",
       "1                 0                       0                    1  \n",
       "2                 1                       0                    1  \n",
       "3                 1                       0                    1  \n",
       "4                 0                       0                    1  "
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "final_dataset.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}

6957bf189e506dcf4f99d3c0c2726434f180fb41
<mask token>

{'cells': [{'cell_type': 'code', 'execution_count': 1, 'metadata': {},
    'outputs': [], 'source': ['import pandas as pd ']}, {'cell_type':
    'code', 'execution_count': 2, 'metadata': {}, 'outputs': [], 'source':
    ["df=pd.read_csv('car data.csv')"]}, {'cell_type': 'code',
    'execution_count': 3, 'metadata': {}, 'outputs': [{'data': {'text/html':
    ['<div>\n', '<style scoped>\n',
    """    .dataframe tbody tr th:only-of-type {
""",
    '        vertical-align: middle;\n', '    }\n', '\n',
    '    .dataframe tbody tr th {\n', """        vertical-align: top;
""",
    '    }\n', '\n', '    .dataframe thead th {\n',
    '        text-align: right;\n', '    }\n', '</style>\n',
    """<table border="1" class="dataframe">
""", '  <thead>\n',
    '    <tr style="text-align: right;">\n', '      <th></th>\n',
    """      <th>Car_Name</th>
""", '      <th>Year</th>\n',
    '      <th>Selling_Price</th>\n', '      <th>Present_Price</th>\n',
    """      <th>Kms_Driven</th>
""", '      <th>Fuel_Type</th>\n',
    '      <th>Seller_Type</th>\n', '      <th>Transmission</th>\n',
    """      <th>Owner</th>
""", '    </tr>\n', '  </thead>\n',
    '  <tbody>\n', '    <tr>\n', '      <th>0</th>\n',
    """      <td>ritz</td>
""", '      <td>2014</td>\n',
    '      <td>3.35</td>\n', '      <td>5.59</td>\n',
    """      <td>27000</td>
""", '      <td>Petrol</td>\n',
    '      <td>Dealer</td>\n', '      <td>Manual</td>\n',
    """      <td>0</td>
""", '    </tr>\n', '    <tr>\n',
    '      <th>1</th>\n', '      <td>sx4</td>\n',
    """      <td>2013</td>
""", '      <td>4.75</td>\n',
    '      <td>9.54</td>\n', '      <td>43000</td>\n',
    """      <td>Diesel</td>
""", '      <td>Dealer</td>\n',
    '      <td>Manual</td>\n', '      <td>0</td>\n', '    </tr>\n',
    '    <tr>\n', """      <th>2</th>
""", '      <td>ciaz</td>\n',
    '      <td>2017</td>\n', '      <td>7.25</td>\n',
    """      <td>9.85</td>
""", '      <td>6900</td>\n',
    '      <td>Petrol</td>\n', '      <td>Dealer</td>\n',
    """      <td>Manual</td>
""", '      <td>0</td>\n', '    </tr>\n',
    '    <tr>\n', '      <th>3</th>\n', """      <td>wagon r</td>
""",
    '      <td>2011</td>\n', '      <td>2.85</td>\n',
    '      <td>4.15</td>\n', """      <td>5200</td>
""",
    '      <td>Petrol</td>\n', '      <td>Dealer</td>\n',
    '      <td>Manual</td>\n', """      <td>0</td>
""", '    </tr>\n',
    '    <tr>\n', '      <th>4</th>\n', '      <td>swift</td>\n',
    """      <td>2014</td>
""", '      <td>4.60</td>\n',
    '      <td>6.87</td>\n', '      <td>42450</td>\n',
    """      <td>Diesel</td>
""", '      <td>Dealer</td>\n',
    '      <td>Manual</td>\n', '      <td>0</td>\n', '    </tr>\n',
    '  </tbody>\n', '</table>\n', '</div>'], 'text/plain': [
    """  Car_Name  Year  Selling_Price  Present_Price  Kms_Driven Fuel_Type  \\
"""
    ,
    '0     ritz  2014           3.35           5.59       27000    Petrol   \n'
    ,
    """1      sx4  2013           4.75           9.54       43000    Diesel   
"""
    ,
    '2     ciaz  2017           7.25           9.85        6900    Petrol   \n'
    ,
    """3  wagon r  2011           2.85           4.15        5200    Petrol   
"""
    ,
    '4    swift  2014           4.60           6.87       42450    Diesel   \n'
    , '\n', """  Seller_Type Transmission  Owner  
""",
    '0      Dealer       Manual      0  \n',
    '1      Dealer       Manual      0  \n',
    """2      Dealer       Manual      0  
""",
    '3      Dealer       Manual      0  \n',
    '4      Dealer       Manual      0  ']}, 'execution_count': 3,
    'metadata': {}, 'output_type': 'execute_result'}], 'source': [
    'df.head()']}, {'cell_type': 'code', 'execution_count': 4, 'metadata':
    {}, 'outputs': [{'data': {'text/plain': ['(301, 9)']},
    'execution_count': 4, 'metadata': {}, 'output_type': 'execute_result'}],
    'source': ['df.shape']}, {'cell_type': 'code', 'execution_count': 5,
    'metadata': {}, 'outputs': [{'name': 'stdout', 'output_type': 'stream',
    'text': ["""['Dealer' 'Individual']
"""]}], 'source': [
    "print(df['Seller_Type'].unique())"]}, {'cell_type': 'code',
    'execution_count': 6, 'metadata': {}, 'outputs': [{'name': 'stdout',
    'output_type': 'stream', 'text': ["""['Manual' 'Automatic']
"""]}],
    'source': ["print(df['Transmission'].unique())"]}, {'cell_type': 'code',
    'execution_count': 23, 'metadata': {}, 'outputs': [{'name': 'stdout',
    'output_type': 'stream', 'text': ['[0 1 3]\n']}], 'source': [
    "print(df['Owner'].unique())"]}, {'cell_type': 'code',
    'execution_count': 24, 'metadata': {}, 'outputs': [{'name': 'stdout',
    'output_type': 'stream', 'text': ["""['Petrol' 'Diesel' 'CNG']
"""]}],
    'source': ["print(df['Fuel_Type'].unique())"]}, {'cell_type': 'code',
    'execution_count': 8, 'metadata': {}, 'outputs': [], 'source': [
    """##CHECKING missing or null values
"""]}, {'cell_type': 'code',
    'execution_count': 9, 'metadata': {}, 'outputs': [{'data': {
    'text/plain': ["""Car_Name         0
""", 'Year             0\n',
    'Selling_Price    0\n', 'Present_Price    0\n', 'Kms_Driven       0\n',
    """Fuel_Type        0
""", 'Seller_Type      0\n',
    'Transmission     0\n', 'Owner            0\n', 'dtype: int64']},
    'execution_count': 9, 'metadata': {}, 'output_type': 'execute_result'}],
    'source': ['df.isnull().sum()']}, {'cell_type': 'code',
    'execution_count': 10, 'metadata': {}, 'outputs': [{'data': {
    'text/html': ['<div>\n', '<style scoped>\n',
    """    .dataframe tbody tr th:only-of-type {
""",
    '        vertical-align: middle;\n', '    }\n', '\n',
    '    .dataframe tbody tr th {\n', """        vertical-align: top;
""",
    '    }\n', '\n', '    .dataframe thead th {\n',
    '        text-align: right;\n', '    }\n', '</style>\n',
    """<table border="1" class="dataframe">
""", '  <thead>\n',
    '    <tr style="text-align: right;">\n', '      <th></th>\n',
    """      <th>Year</th>
""", '      <th>Selling_Price</th>\n',
    '      <th>Present_Price</th>\n', """      <th>Kms_Driven</th>
""",
    '      <th>Owner</th>\n', '    </tr>\n', '  </thead>\n', '  <tbody>\n',
    '    <tr>\n', """      <th>count</th>
""",
    '      <td>301.000000</td>\n', '      <td>301.000000</td>\n',
    '      <td>301.000000</td>\n', """      <td>301.000000</td>
""",
    '      <td>301.000000</td>\n', '    </tr>\n', '    <tr>\n',
    '      <th>mean</th>\n', """      <td>2013.627907</td>
""",
    '      <td>4.661296</td>\n', '      <td>7.628472</td>\n',
    '      <td>36947.205980</td>\n', """      <td>0.043189</td>
""",
    '    </tr>\n', '    <tr>\n', '      <th>std</th>\n',
    '      <td>2.891554</td>\n', """      <td>5.082812</td>
""",
    '      <td>8.644115</td>\n', '      <td>38886.883882</td>\n',
    '      <td>0.247915</td>\n', '    </tr>\n', '    <tr>\n',
    """      <th>min</th>
""", '      <td>2003.000000</td>\n',
    '      <td>0.100000</td>\n', '      <td>0.320000</td>\n',
    """      <td>500.000000</td>
""", '      <td>0.000000</td>\n',
    '    </tr>\n', '    <tr>\n', '      <th>25%</th>\n',
    """      <td>2012.000000</td>
""", '      <td>0.900000</td>\n',
    '      <td>1.200000</td>\n', '      <td>15000.000000</td>\n',
    """      <td>0.000000</td>
""", '    </tr>\n', '    <tr>\n',
    '      <th>50%</th>\n', '      <td>2014.000000</td>\n',
    """      <td>3.600000</td>
""", '      <td>6.400000</td>\n',
    '      <td>32000.000000</td>\n', '      <td>0.000000</td>\n',
    '    </tr>\n', '    <tr>\n', """      <th>75%</th>
""",
    '      <td>2016.000000</td>\n', '      <td>6.000000</td>\n',
    '      <td>9.900000</td>\n', """      <td>48767.000000</td>
""",
    '      <td>0.000000</td>\n', '    </tr>\n', '    <tr>\n',
    '      <th>max</th>\n', """      <td>2018.000000</td>
""",
    '      <td>35.000000</td>\n', '      <td>92.600000</td>\n',
    '      <td>500000.000000</td>\n', """      <td>3.000000</td>
""",
    '    </tr>\n', '  </tbody>\n', '</table>\n', '</div>'], 'text/plain': [
    """              Year  Selling_Price  Present_Price     Kms_Driven       Owner
"""
    ,
    'count   301.000000     301.000000     301.000000     301.000000  301.000000\n'
    ,
    """mean   2013.627907       4.661296       7.628472   36947.205980    0.043189
"""
    ,
    'std       2.891554       5.082812       8.644115   38886.883882    0.247915\n'
    ,
    """min    2003.000000       0.100000       0.320000     500.000000    0.000000
"""
    ,
    '25%    2012.000000       0.900000       1.200000   15000.000000    0.000000\n'
    ,
    """50%    2014.000000       3.600000       6.400000   32000.000000    0.000000
"""
    ,
    '75%    2016.000000       6.000000       9.900000   48767.000000    0.000000\n'
    ,
    'max    2018.000000      35.000000      92.600000  500000.000000    3.000000'
    ]}, 'execution_count': 10, 'metadata': {}, 'output_type':
    'execute_result'}], 'source': ['df.describe()']}, {'cell_type': 'code',
    'execution_count': 11, 'metadata': {}, 'outputs': [{'data': {
    'text/plain': [
    """Index(['Car_Name', 'Year', 'Selling_Price', 'Present_Price', 'Kms_Driven',
"""
    , "       'Fuel_Type', 'Seller_Type', 'Transmission', 'Owner'],\n",
    "      dtype='object')"]}, 'execution_count': 11, 'metadata': {},
    'output_type': 'execute_result'}], 'source': [
    """##VIEWING ALL COLUMNS NAME ONLY 
""", 'df.columns']}, {'cell_type':
    'code', 'execution_count': 12, 'metadata': {}, 'outputs': [], 'source':
    [
    '##REMOVING CAR NAME FROM DATASET SINCE IT WILL NOT PREDICT THE PRICE '
    ]}, {'cell_type': 'code', 'execution_count': 13, 'metadata': {},
    'outputs': [], 'source': [
    """final_dataset=df[['Year', 'Selling_Price', 'Present_Price', 'Kms_Driven',
"""
    , "       'Fuel_Type', 'Seller_Type', 'Transmission', 'Owner']]"]}, {
    'cell_type': 'code', 'execution_count': 14, 'metadata': {}, 'outputs':
    [{'data': {'text/html': ['<div>\n', '<style scoped>\n',
    """    .dataframe tbody tr th:only-of-type {
""",
    '        vertical-align: middle;\n', '    }\n', '\n',
    '    .dataframe tbody tr th {\n', """        vertical-align: top;
""",
    '    }\n', '\n', '    .dataframe thead th {\n',
    '        text-align: right;\n', '    }\n', '</style>\n',
    """<table border="1" class="dataframe">
""", '  <thead>\n',
    '    <tr style="text-align: right;">\n', '      <th></th>\n',
    """      <th>Year</th>
""", '      <th>Selling_Price</th>\n',
    '      <th>Present_Price</th>\n', """      <th>Kms_Driven</th>
""",
    '      <th>Fuel_Type</th>\n', '      <th>Seller_Type</th>\n',
    '      <th>Transmission</th>\n', """      <th>Owner</th>
""",
    '    </tr>\n', '  </thead>\n', '  <tbody>\n', '    <tr>\n',
    '      <th>0</th>\n', """      <td>2014</td>
""",
    '      <td>3.35</td>\n', '      <td>5.59</td>\n',
    '      <td>27000</td>\n', """      <td>Petrol</td>
""",
    '      <td>Dealer</td>\n', '      <td>Manual</td>\n',
    '      <td>0</td>\n', '    </tr>\n', '    <tr>\n',
    """      <th>1</th>
""", '      <td>2013</td>\n',
    '      <td>4.75</td>\n', '      <td>9.54</td>\n',
    """      <td>43000</td>
""", '      <td>Diesel</td>\n',
    '      <td>Dealer</td>\n', '      <td>Manual</td>\n',
    """      <td>0</td>
""", '    </tr>\n', '    <tr>\n',
    '      <th>2</th>\n', '      <td>2017</td>\n',
    """      <td>7.25</td>
""", '      <td>9.85</td>\n',
    '      <td>6900</td>\n', '      <td>Petrol</td>\n',
    """      <td>Dealer</td>
""", '      <td>Manual</td>\n',
    '      <td>0</td>\n', '    </tr>\n', '    <tr>\n',
    """      <th>3</th>
""", '      <td>2011</td>\n',
    '      <td>2.85</td>\n', '      <td>4.15</td>\n',
    """      <td>5200</td>
""", '      <td>Petrol</td>\n',
    '      <td>Dealer</td>\n', '      <td>Manual</td>\n',
    """      <td>0</td>
""", '    </tr>\n', '    <tr>\n',
    '      <th>4</th>\n', '      <td>2014</td>\n',
    """      <td>4.60</td>
""", '      <td>6.87</td>\n',
    '      <td>42450</td>\n', '      <td>Diesel</td>\n',
    """      <td>Dealer</td>
""", '      <td>Manual</td>\n',
    '      <td>0</td>\n', '    </tr>\n', '  </tbody>\n', '</table>\n',
    '</div>'], 'text/plain': [
    """   Year  Selling_Price  Present_Price  Kms_Driven Fuel_Type Seller_Type  \\
"""
    ,
    '0  2014           3.35           5.59       27000    Petrol      Dealer   \n'
    ,
    """1  2013           4.75           9.54       43000    Diesel      Dealer   
"""
    ,
    '2  2017           7.25           9.85        6900    Petrol      Dealer   \n'
    ,
    """3  2011           2.85           4.15        5200    Petrol      Dealer   
"""
    ,
    '4  2014           4.60           6.87       42450    Diesel      Dealer   \n'
    , '\n', """  Transmission  Owner  
""", '0       Manual      0  \n',
    '1       Manual      0  \n', '2       Manual      0  \n',
    """3       Manual      0  
""", '4       Manual      0  ']},
    'execution_count': 14, 'metadata': {}, 'output_type': 'execute_result'}
    ], 'source': ["""final_dataset.head()
"""]}, {'cell_type': 'code',
    'execution_count': 15, 'metadata': {}, 'outputs': [], 'source': [
    '#ADDING OUR OWN COLUMN/FEATURE IN THE DATA SET AS CURRENT YEAR ']}, {
    'cell_type': 'code', 'execution_count': 16, 'metadata': {}, 'outputs':
    [{'data': {'text/html': ['<div>\n', '<style scoped>\n',
    """    .dataframe tbody tr th:only-of-type {
""",
    '        vertical-align: middle;\n', '    }\n', '\n',
    '    .dataframe tbody tr th {\n', """        vertical-align: top;
""",
    '    }\n', '\n', '    .dataframe thead th {\n',
    '        text-align: right;\n', '    }\n', '</style>\n',
    """<table border="1" class="dataframe">
""", '  <thead>\n',
    '    <tr style="text-align: right;">\n', '      <th></th>\n',
    """      <th>Year</th>
""", '      <th>Selling_Price</th>\n',
    '      <th>Present_Price</th>\n', """      <th>Kms_Driven</th>
""",
    '      <th>Fuel_Type</th>\n', '      <th>Seller_Type</th>\n',
    '      <th>Transmission</th>\n', """      <th>Owner</th>
""",
    '      <th>Current_Year</th>\n', '    </tr>\n', '  </thead>\n',
    '  <tbody>\n', '    <tr>\n', """      <th>0</th>
""",
    '      <td>2014</td>\n', '      <td>3.35</td>\n',
    '      <td>5.59</td>\n', """      <td>27000</td>
""",
    '      <td>Petrol</td>\n', '      <td>Dealer</td>\n',
    '      <td>Manual</td>\n', """      <td>0</td>
""",
    '      <td>2020</td>\n', '    </tr>\n', '    <tr>\n',
    '      <th>1</th>\n', """      <td>2013</td>
""",
    '      <td>4.75</td>\n', '      <td>9.54</td>\n',
    '      <td>43000</td>\n', """      <td>Diesel</td>
""",
    '      <td>Dealer</td>\n', '      <td>Manual</td>\n',
    '      <td>0</td>\n', """      <td>2020</td>
""", '    </tr>\n',
    '    <tr>\n', '      <th>2</th>\n', '      <td>2017</td>\n',
    """      <td>7.25</td>
""", '      <td>9.85</td>\n',
    '      <td>6900</td>\n', '      <td>Petrol</td>\n',
    """      <td>Dealer</td>
""", '      <td>Manual</td>\n',
    '      <td>0</td>\n', '      <td>2020</td>\n', '    </tr>\n',
    '    <tr>\n', """      <th>3</th>
""", '      <td>2011</td>\n',
    '      <td>2.85</td>\n', '      <td>4.15</td>\n',
    """      <td>5200</td>
""", '      <td>Petrol</td>\n',
    '      <td>Dealer</td>\n', '      <td>Manual</td>\n',
    """      <td>0</td>
""", '      <td>2020</td>\n', '    </tr>\n',
    '    <tr>\n', '      <th>4</th>\n', """      <td>2014</td>
""",
    '      <td>4.60</td>\n', '      <td>6.87</td>\n',
    '      <td>42450</td>\n', """      <td>Diesel</td>
""",
    '      <td>Dealer</td>\n', '      <td>Manual</td>\n',
    '      <td>0</td>\n', """      <td>2020</td>
""", '    </tr>\n',
    '  </tbody>\n', '</table>\n', '</div>'], 'text/plain': [
    """   Year  Selling_Price  Present_Price  Kms_Driven Fuel_Type Seller_Type  \\
"""
    ,
    '0  2014           3.35           5.59       27000    Petrol      Dealer   \n'
    ,
    """1  2013           4.75           9.54       43000    Diesel      Dealer   
"""
    ,
    '2  2017           7.25           9.85        6900    Petrol      Dealer   \n'
    ,
    """3  2011           2.85           4.15        5200    Petrol      Dealer   
"""
    ,
    '4  2014           4.60           6.87       42450    Diesel      Dealer   \n'
    , '\n', """  Transmission  Owner  Current_Year  
""",
    '0       Manual      0          2020  \n',
    '1       Manual      0          2020  \n',
    """2       Manual      0          2020  
""",
    '3       Manual      0          2020  \n',
    '4       Manual      0          2020  ']}, 'execution_count': 16,
    'metadata': {}, 'output_type': 'execute_result'}], 'source': [
    """final_dataset['Current_Year']=2020
""", 'final_dataset.head()']}, {
    'cell_type': 'code', 'execution_count': 17, 'metadata': {}, 'outputs':
    [], 'source': ["""##ADDING ANOTHER COLUMN NO_YEAR
""",
    '## SUBSTRACTING CURRENT YEAR AND YEAR TO GIVE VALUE OF NO_YEAR AND DISPLAYING IT \n'
    , '  \n',
    """final_dataset['no_year']=final_dataset['Current_Year']-final_dataset['Year']
"""
    ]}, {'cell_type': 'code', 'execution_count': 18, 'metadata': {},
    'outputs': [{'data': {'text/html': ['<div>\n', '<style scoped>\n',
    """    .dataframe tbody tr th:only-of-type {
""",
    '        vertical-align: middle;\n', '    }\n', '\n',
    '    .dataframe tbody tr th {\n', """        vertical-align: top;
""",
    '    }\n', '\n', '    .dataframe thead th {\n',
    '        text-align: right;\n', '    }\n', '</style>\n',
    """<table border="1" class="dataframe">
""", '  <thead>\n',
    '    <tr style="text-align: right;">\n', '      <th></th>\n',
    """      <th>Year</th>
""", '      <th>Selling_Price</th>\n',
    '      <th>Present_Price</th>\n', """      <th>Kms_Driven</th>
""",
    '      <th>Fuel_Type</th>\n', '      <th>Seller_Type</th>\n',
    '      <th>Transmission</th>\n', """      <th>Owner</th>
""",
    '      <th>Current_Year</th>\n', '      <th>no_year</th>\n',
    '    </tr>\n', '  </thead>\n', '  <tbody>\n', '    <tr>\n',
    """      <th>0</th>
""", '      <td>2014</td>\n',
    '      <td>3.35</td>\n', '      <td>5.59</td>\n',
    """      <td>27000</td>
""", '      <td>Petrol</td>\n',
    '      <td>Dealer</td>\n', '      <td>Manual</td>\n',
    """      <td>0</td>
""", '      <td>2020</td>\n', '      <td>6</td>\n',
    '    </tr>\n', '    <tr>\n', """      <th>1</th>
""",
    '      <td>2013</td>\n', '      <td>4.75</td>\n',
    '      <td>9.54</td>\n', """      <td>43000</td>
""",
    '      <td>Diesel</td>\n', '      <td>Dealer</td>\n',
    '      <td>Manual</td>\n', """      <td>0</td>
""",
    '      <td>2020</td>\n', '      <td>7</td>\n', '    </tr>\n',
    '    <tr>\n', """      <th>2</th>
""", '      <td>2017</td>\n',
    '      <td>7.25</td>\n', '      <td>9.85</td>\n',
    """      <td>6900</td>
""", '      <td>Petrol</td>\n',
    '      <td>Dealer</td>\n', '      <td>Manual</td>\n',
    """      <td>0</td>
""", '      <td>2020</td>\n', '      <td>3</td>\n',
    '    </tr>\n', '    <tr>\n', """      <th>3</th>
""",
    '      <td>2011</td>\n', '      <td>2.85</td>\n',
    '      <td>4.15</td>\n', """      <td>5200</td>
""",
    '      <td>Petrol</td>\n', '      <td>Dealer</td>\n',
    '      <td>Manual</td>\n', """      <td>0</td>
""",
    '      <td>2020</td>\n', '      <td>9</td>\n', '    </tr>\n',
    '    <tr>\n', """      <th>4</th>
""", '      <td>2014</td>\n',
    '      <td>4.60</td>\n', '      <td>6.87</td>\n',
    """      <td>42450</td>
""", '      <td>Diesel</td>\n',
    '      <td>Dealer</td>\n', '      <td>Manual</td>\n',
    """      <td>0</td>
""", '      <td>2020</td>\n', '      <td>6</td>\n',
    '    </tr>\n', '  </tbody>\n', '</table>\n', '</div>'], 'text/plain': [
    """   Year  Selling_Price  Present_Price  Kms_Driven Fuel_Type Seller_Type  \\
"""
    ,
    '0  2014           3.35           5.59       27000    Petrol      Dealer   \n'
    ,
    """1  2013           4.75           9.54       43000    Diesel      Dealer   
"""
    ,
    '2  2017           7.25           9.85        6900    Petrol      Dealer   \n'
    ,
    """3  2011           2.85           4.15        5200    Petrol      Dealer   
"""
    ,
    '4  2014           4.60           6.87       42450    Diesel      Dealer   \n'
    , '\n', """  Transmission  Owner  Current_Year  no_year  
""",
    '0       Manual      0          2020        6  \n',
    """1       Manual      0          2020        7  
""",
    '2       Manual      0          2020        3  \n',
    """3       Manual      0          2020        9  
""",
    '4       Manual      0          2020        6  ']}, 'execution_count': 
    18, 'metadata': {}, 'output_type': 'execute_result'}], 'source': [
    'final_dataset.head()']}, {'cell_type': 'code', 'execution_count': 19,
    'metadata': {}, 'outputs': [{'data': {'text/html': ['<div>\n',
    '<style scoped>\n', """    .dataframe tbody tr th:only-of-type {
""",
    '        vertical-align: middle;\n', '    }\n', '\n',
    '    .dataframe tbody tr th {\n', """        vertical-align: top;
""",
    '    }\n', '\n', '    .dataframe thead th {\n',
    '        text-align: right;\n', '    }\n', '</style>\n',
    """<table border="1" class="dataframe">
""", '  <thead>\n',
    '    <tr style="text-align: right;">\n', '      <th></th>\n',
    """      <th>Selling_Price</th>
""", '      <th>Present_Price</th>\n',
    '      <th>Kms_Driven</th>\n', '      <th>Fuel_Type</th>\n',
    """      <th>Seller_Type</th>
""", '      <th>Transmission</th>\n',
    '      <th>Owner</th>\n', '      <th>Current_Year</th>\n',
    """      <th>no_year</th>
""", '    </tr>\n', '  </thead>\n',
    '  <tbody>\n', '    <tr>\n', '      <th>0</th>\n',
    """      <td>3.35</td>
""", '      <td>5.59</td>\n',
    '      <td>27000</td>\n', '      <td>Petrol</td>\n',
    """      <td>Dealer</td>
""", '      <td>Manual</td>\n',
    '      <td>0</td>\n', '      <td>2020</td>\n', '      <td>6</td>\n',
    '    </tr>\n', '    <tr>\n', """      <th>1</th>
""",
    '      <td>4.75</td>\n', '      <td>9.54</td>\n',
    '      <td>43000</td>\n', """      <td>Diesel</td>
""",
    '      <td>Dealer</td>\n', '      <td>Manual</td>\n',
    '      <td>0</td>\n', """      <td>2020</td>
""", '      <td>7</td>\n',
    '    </tr>\n', '    <tr>\n', '      <th>2</th>\n',
    """      <td>7.25</td>
""", '      <td>9.85</td>\n',
    '      <td>6900</td>\n', '      <td>Petrol</td>\n',
    """      <td>Dealer</td>
""", '      <td>Manual</td>\n',
    '      <td>0</td>\n', '      <td>2020</td>\n', '      <td>3</td>\n',
    '    </tr>\n', '    <tr>\n', """      <th>3</th>
""",
    '      <td>2.85</td>\n', '      <td>4.15</td>\n',
    '      <td>5200</td>\n', """      <td>Petrol</td>
""",
    '      <td>Dealer</td>\n', '      <td>Manual</td>\n',
    '      <td>0</td>\n', """      <td>2020</td>
""", '      <td>9</td>\n',
    '    </tr>\n', '    <tr>\n', '      <th>4</th>\n',
    """      <td>4.60</td>
""", '      <td>6.87</td>\n',
    '      <td>42450</td>\n', '      <td>Diesel</td>\n',
    """      <td>Dealer</td>
""", '      <td>Manual</td>\n',
    '      <td>0</td>\n', '      <td>2020</td>\n', '      <td>6</td>\n',
    '    </tr>\n', '  </tbody>\n', '</table>\n', '</div>'], 'text/plain': [
    """   Selling_Price  Present_Price  Kms_Driven Fuel_Type Seller_Type  \\
"""
    ,
    '0           3.35           5.59       27000    Petrol      Dealer   \n',
    """1           4.75           9.54       43000    Diesel      Dealer   
"""
    ,
    '2           7.25           9.85        6900    Petrol      Dealer   \n',
    """3           2.85           4.15        5200    Petrol      Dealer   
"""
    ,
    '4           4.60           6.87       42450    Diesel      Dealer   \n',
    '\n', """  Transmission  Owner  Current_Year  no_year  
""",
    '0       Manual      0          2020        6  \n',
    """1       Manual      0          2020        7  
""",
    '2       Manual      0          2020        3  \n',
    """3       Manual      0          2020        9  
""",
    '4       Manual      0          2020        6  ']}, 'execution_count': 
    19, 'metadata': {}, 'output_type': 'execute_result'}], 'source': [
    """##REMOVING YEAR COLUMN
""",
    """## AXIS MEANS, 0=ROW, 1= COLUMN, INPLACE =TRUE MEANS IT SAVES AFTER, FALSE MEANS JUST FOR ONE TIME 
"""
    , '\n', "final_dataset.drop(['Year'],axis=1,inplace=True)\n",
    'final_dataset.head()']}, {'cell_type': 'code', 'execution_count': 21,
    'metadata': {}, 'outputs': [{'data': {'text/html': ['<div>\n',
    '<style scoped>\n', """    .dataframe tbody tr th:only-of-type {
""",
    '        vertical-align: middle;\n', '    }\n', '\n',
    '    .dataframe tbody tr th {\n', """        vertical-align: top;
""",
    '    }\n', '\n', '    .dataframe thead th {\n',
    '        text-align: right;\n', '    }\n', '</style>\n',
    """<table border="1" class="dataframe">
""", '  <thead>\n',
    '    <tr style="text-align: right;">\n', '      <th></th>\n',
    """      <th>Selling_Price</th>
""", '      <th>Present_Price</th>\n',
    '      <th>Kms_Driven</th>\n', '      <th>Fuel_Type</th>\n',
    """      <th>Seller_Type</th>
""", '      <th>Transmission</th>\n',
    '      <th>Owner</th>\n', '      <th>no_year</th>\n', '    </tr>\n',
    '  </thead>\n', '  <tbody>\n', '    <tr>\n', """      <th>0</th>
""",
    '      <td>3.35</td>\n', '      <td>5.59</td>\n',
    '      <td>27000</td>\n', """      <td>Petrol</td>
""",
    '      <td>Dealer</td>\n', '      <td>Manual</td>\n',
    '      <td>0</td>\n', """      <td>6</td>
""", '    </tr>\n',
    '    <tr>\n', '      <th>1</th>\n', '      <td>4.75</td>\n',
    """      <td>9.54</td>
""", '      <td>43000</td>\n',
    '      <td>Diesel</td>\n', '      <td>Dealer</td>\n',
    """      <td>Manual</td>
""", '      <td>0</td>\n',
    '      <td>7</td>\n', '    </tr>\n', '    <tr>\n', '      <th>2</th>\n',
    """      <td>7.25</td>
""", '      <td>9.85</td>\n',
    '      <td>6900</td>\n', '      <td>Petrol</td>\n',
    """      <td>Dealer</td>
""", '      <td>Manual</td>\n',
    '      <td>0</td>\n', '      <td>3</td>\n', '    </tr>\n', '    <tr>\n',
    """      <th>3</th>
""", '      <td>2.85</td>\n',
    '      <td>4.15</td>\n', '      <td>5200</td>\n',
    """      <td>Petrol</td>
""", '      <td>Dealer</td>\n',
    '      <td>Manual</td>\n', '      <td>0</td>\n',
    """      <td>9</td>
""", '    </tr>\n', '    <tr>\n',
    '      <th>4</th>\n', '      <td>4.60</td>\n',
    """      <td>6.87</td>
""", '      <td>42450</td>\n',
    '      <td>Diesel</td>\n', '      <td>Dealer</td>\n',
    """      <td>Manual</td>
""", '      <td>0</td>\n',
    '      <td>6</td>\n', '    </tr>\n', '  </tbody>\n', '</table>\n',
    '</div>'], 'text/plain': [
    """   Selling_Price  Present_Price  Kms_Driven Fuel_Type Seller_Type  \\
"""
    ,
    '0           3.35           5.59       27000    Petrol      Dealer   \n',
    """1           4.75           9.54       43000    Diesel      Dealer   
"""
    ,
    '2           7.25           9.85        6900    Petrol      Dealer   \n',
    """3           2.85           4.15        5200    Petrol      Dealer   
"""
    ,
    '4           4.60           6.87       42450    Diesel      Dealer   \n',
    '\n', """  Transmission  Owner  no_year  
""",
    '0       Manual      0        6  \n',
    '1       Manual      0        7  \n',
    """2       Manual      0        3  
""",
    '3       Manual      0        9  \n',
    '4       Manual      0        6  ']}, 'execution_count': 21, 'metadata':
    {}, 'output_type': 'execute_result'}], 'source': [
    """##REMOVING CURRENT YEAR USING DROP
""",
    "final_dataset.drop(['Current_Year'],axis=1,inplace=True)\n",
    'final_dataset.head()']}, {'cell_type': 'code', 'execution_count': 25,
    'metadata': {}, 'outputs': [], 'source': [
    """##REMOVING THE DUMMIES VARIABLES SUCH AS FUELTYPE, SELLER TYPE, TRANSMISSION AND DROPPING THE FIRST COLUMN
"""
    , '##ALSO KNOWN AS ONE HOT ENCODED \n', '\n',
    'final_dataset=pd.get_dummies(final_dataset,drop_first=True)']}, {
    'cell_type': 'code', 'execution_count': 26, 'metadata': {}, 'outputs':
    [{'data': {'text/html': ['<div>\n', '<style scoped>\n',
    """    .dataframe tbody tr th:only-of-type {
""",
    '        vertical-align: middle;\n', '    }\n', '\n',
    '    .dataframe tbody tr th {\n', """        vertical-align: top;
""",
    '    }\n', '\n', '    .dataframe thead th {\n',
    '        text-align: right;\n', '    }\n', '</style>\n',
    """<table border="1" class="dataframe">
""", '  <thead>\n',
    '    <tr style="text-align: right;">\n', '      <th></th>\n',
    """      <th>Selling_Price</th>
""", '      <th>Present_Price</th>\n',
    '      <th>Kms_Driven</th>\n', '      <th>Owner</th>\n',
    """      <th>no_year</th>
""", '      <th>Fuel_Type_Diesel</th>\n',
    '      <th>Fuel_Type_Petrol</th>\n',
    """      <th>Seller_Type_Individual</th>
""",
    '      <th>Transmission_Manual</th>\n', '    </tr>\n', '  </thead>\n',
    '  <tbody>\n', '    <tr>\n', """      <th>0</th>
""",
    '      <td>3.35</td>\n', '      <td>5.59</td>\n',
    '      <td>27000</td>\n', """      <td>0</td>
""", '      <td>6</td>\n',
    '      <td>0</td>\n', '      <td>1</td>\n', '      <td>0</td>\n',
    """      <td>1</td>
""", '    </tr>\n', '    <tr>\n',
    '      <th>1</th>\n', '      <td>4.75</td>\n',
    """      <td>9.54</td>
""", '      <td>43000</td>\n',
    '      <td>0</td>\n', '      <td>7</td>\n', '      <td>1</td>\n',
    """      <td>0</td>
""", '      <td>0</td>\n', '      <td>1</td>\n',
    '    </tr>\n', '    <tr>\n', '      <th>2</th>\n',
    """      <td>7.25</td>
""", '      <td>9.85</td>\n',
    '      <td>6900</td>\n', '      <td>0</td>\n', '      <td>3</td>\n',
    """      <td>0</td>
""", '      <td>1</td>\n', '      <td>0</td>\n',
    '      <td>1</td>\n', '    </tr>\n', '    <tr>\n',
    """      <th>3</th>
""", '      <td>2.85</td>\n',
    '      <td>4.15</td>\n', '      <td>5200</td>\n',
    """      <td>0</td>
""", '      <td>9</td>\n', '      <td>0</td>\n',
    '      <td>1</td>\n', '      <td>0</td>\n', """      <td>1</td>
""",
    '    </tr>\n', '    <tr>\n', '      <th>4</th>\n',
    '      <td>4.60</td>\n', """      <td>6.87</td>
""",
    '      <td>42450</td>\n', '      <td>0</td>\n', '      <td>6</td>\n',
    '      <td>1</td>\n', """      <td>0</td>
""", '      <td>0</td>\n',
    '      <td>1</td>\n', '    </tr>\n', '  </tbody>\n', '</table>\n',
    '</div>'], 'text/plain': [
    """   Selling_Price  Present_Price  Kms_Driven  Owner  no_year  Fuel_Type_Diesel  \\
"""
    ,
    '0           3.35           5.59       27000      0        6                 0   \n'
    ,
    """1           4.75           9.54       43000      0        7                 1   
"""
    ,
    '2           7.25           9.85        6900      0        3                 0   \n'
    ,
    """3           2.85           4.15        5200      0        9                 0   
"""
    ,
    '4           4.60           6.87       42450      0        6                 1   \n'
    , '\n',
    """   Fuel_Type_Petrol  Seller_Type_Individual  Transmission_Manual  
""",
    '0                 1                       0                    1  \n',
    """1                 0                       0                    1  
""",
    '2                 1                       0                    1  \n',
    """3                 1                       0                    1  
""",
    '4                 0                       0                    1  ']},
    'execution_count': 26, 'metadata': {}, 'output_type': 'execute_result'}
    ], 'source': ['final_dataset.head()']}, {'cell_type': 'code',
    'execution_count': null, 'metadata': {}, 'outputs': [], 'source': []}],
    'metadata': {'kernelspec': {'display_name': 'Python 3', 'language':
    'python', 'name': 'python3'}, 'language_info': {'codemirror_mode': {
    'name': 'ipython', 'version': 3}, 'file_extension': '.py', 'mimetype':
    'text/x-python', 'name': 'python', 'nbconvert_exporter': 'python',
    'pygments_lexer': 'ipython3', 'version': '3.7.6'}}, 'nbformat': 4,
    'nbformat_minor': 4}

{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "df=pd.read_csv('car data.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Car_Name</th>\n",
       "      <th>Year</th>\n",
       "      <th>Selling_Price</th>\n",
       "      <th>Present_Price</th>\n",
       "      <th>Kms_Driven</th>\n",
       "      <th>Fuel_Type</th>\n",
       "      <th>Seller_Type</th>\n",
       "      <th>Transmission</th>\n",
       "      <th>Owner</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>ritz</td>\n",
       "      <td>2014</td>\n",
       "      <td>3.35</td>\n",
       "      <td>5.59</td>\n",
       "      <td>27000</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>sx4</td>\n",
       "      <td>2013</td>\n",
       "      <td>4.75</td>\n",
       "      <td>9.54</td>\n",
       "      <td>43000</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ciaz</td>\n",
       "      <td>2017</td>\n",
       "      <td>7.25</td>\n",
       "      <td>9.85</td>\n",
       "      <td>6900</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>wagon r</td>\n",
       "      <td>2011</td>\n",
       "      <td>2.85</td>\n",
       "      <td>4.15</td>\n",
       "      <td>5200</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>swift</td>\n",
       "      <td>2014</td>\n",
       "      <td>4.60</td>\n",
       "      <td>6.87</td>\n",
       "      <td>42450</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Car_Name  Year  Selling_Price  Present_Price  Kms_Driven Fuel_Type  \\\n",
       "0     ritz  2014           3.35           5.59       27000    Petrol   \n",
       "1      sx4  2013           4.75           9.54       43000    Diesel   \n",
       "2     ciaz  2017           7.25           9.85        6900    Petrol   \n",
       "3  wagon r  2011           2.85           4.15        5200    Petrol   \n",
       "4    swift  2014           4.60           6.87       42450    Diesel   \n",
       "\n",
       "  Seller_Type Transmission  Owner  \n",
       "0      Dealer       Manual      0  \n",
       "1      Dealer       Manual      0  \n",
       "2      Dealer       Manual      0  \n",
       "3      Dealer       Manual      0  \n",
       "4      Dealer       Manual      0  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(301, 9)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Dealer' 'Individual']\n"
     ]
    }
   ],
   "source": [
    "print(df['Seller_Type'].unique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Manual' 'Automatic']\n"
     ]
    }
   ],
   "source": [
    "print(df['Transmission'].unique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0 1 3]\n"
     ]
    }
   ],
   "source": [
    "print(df['Owner'].unique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Petrol' 'Diesel' 'CNG']\n"
     ]
    }
   ],
   "source": [
    "print(df['Fuel_Type'].unique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "##CHECKING missing or null values\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Car_Name         0\n",
       "Year             0\n",
       "Selling_Price    0\n",
       "Present_Price    0\n",
       "Kms_Driven       0\n",
       "Fuel_Type        0\n",
       "Seller_Type      0\n",
       "Transmission     0\n",
       "Owner            0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>Selling_Price</th>\n",
       "      <th>Present_Price</th>\n",
       "      <th>Kms_Driven</th>\n",
       "      <th>Owner</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>301.000000</td>\n",
       "      <td>301.000000</td>\n",
       "      <td>301.000000</td>\n",
       "      <td>301.000000</td>\n",
       "      <td>301.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>2013.627907</td>\n",
       "      <td>4.661296</td>\n",
       "      <td>7.628472</td>\n",
       "      <td>36947.205980</td>\n",
       "      <td>0.043189</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>2.891554</td>\n",
       "      <td>5.082812</td>\n",
       "      <td>8.644115</td>\n",
       "      <td>38886.883882</td>\n",
       "      <td>0.247915</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>2003.000000</td>\n",
       "      <td>0.100000</td>\n",
       "      <td>0.320000</td>\n",
       "      <td>500.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>2012.000000</td>\n",
       "      <td>0.900000</td>\n",
       "      <td>1.200000</td>\n",
       "      <td>15000.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>2014.000000</td>\n",
       "      <td>3.600000</td>\n",
       "      <td>6.400000</td>\n",
       "      <td>32000.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>2016.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>9.900000</td>\n",
       "      <td>48767.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>2018.000000</td>\n",
       "      <td>35.000000</td>\n",
       "      <td>92.600000</td>\n",
       "      <td>500000.000000</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              Year  Selling_Price  Present_Price     Kms_Driven       Owner\n",
       "count   301.000000     301.000000     301.000000     301.000000  301.000000\n",
       "mean   2013.627907       4.661296       7.628472   36947.205980    0.043189\n",
       "std       2.891554       5.082812       8.644115   38886.883882    0.247915\n",
       "min    2003.000000       0.100000       0.320000     500.000000    0.000000\n",
       "25%    2012.000000       0.900000       1.200000   15000.000000    0.000000\n",
       "50%    2014.000000       3.600000       6.400000   32000.000000    0.000000\n",
       "75%    2016.000000       6.000000       9.900000   48767.000000    0.000000\n",
       "max    2018.000000      35.000000      92.600000  500000.000000    3.000000"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Car_Name', 'Year', 'Selling_Price', 'Present_Price', 'Kms_Driven',\n",
       "       'Fuel_Type', 'Seller_Type', 'Transmission', 'Owner'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "##VIEWING ALL COLUMNS NAME ONLY \n",
    "df.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "##REMOVING CAR NAME FROM DATASET SINCE IT WILL NOT PREDICT THE PRICE "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "final_dataset=df[['Year', 'Selling_Price', 'Present_Price', 'Kms_Driven',\n",
    "       'Fuel_Type', 'Seller_Type', 'Transmission', 'Owner']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>Selling_Price</th>\n",
       "      <th>Present_Price</th>\n",
       "      <th>Kms_Driven</th>\n",
       "      <th>Fuel_Type</th>\n",
       "      <th>Seller_Type</th>\n",
       "      <th>Transmission</th>\n",
       "      <th>Owner</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2014</td>\n",
       "      <td>3.35</td>\n",
       "      <td>5.59</td>\n",
       "      <td>27000</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2013</td>\n",
       "      <td>4.75</td>\n",
       "      <td>9.54</td>\n",
       "      <td>43000</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2017</td>\n",
       "      <td>7.25</td>\n",
       "      <td>9.85</td>\n",
       "      <td>6900</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2011</td>\n",
       "      <td>2.85</td>\n",
       "      <td>4.15</td>\n",
       "      <td>5200</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2014</td>\n",
       "      <td>4.60</td>\n",
       "      <td>6.87</td>\n",
       "      <td>42450</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Year  Selling_Price  Present_Price  Kms_Driven Fuel_Type Seller_Type  \\\n",
       "0  2014           3.35           5.59       27000    Petrol      Dealer   \n",
       "1  2013           4.75           9.54       43000    Diesel      Dealer   \n",
       "2  2017           7.25           9.85        6900    Petrol      Dealer   \n",
       "3  2011           2.85           4.15        5200    Petrol      Dealer   \n",
       "4  2014           4.60           6.87       42450    Diesel      Dealer   \n",
       "\n",
       "  Transmission  Owner  \n",
       "0       Manual      0  \n",
       "1       Manual      0  \n",
       "2       Manual      0  \n",
       "3       Manual      0  \n",
       "4       Manual      0  "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "final_dataset.head()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "#ADDING OUR OWN COLUMN/FEATURE IN THE DATA SET AS CURRENT YEAR "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>Selling_Price</th>\n",
       "      <th>Present_Price</th>\n",
       "      <th>Kms_Driven</th>\n",
       "      <th>Fuel_Type</th>\n",
       "      <th>Seller_Type</th>\n",
       "      <th>Transmission</th>\n",
       "      <th>Owner</th>\n",
       "      <th>Current_Year</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2014</td>\n",
       "      <td>3.35</td>\n",
       "      <td>5.59</td>\n",
       "      <td>27000</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2013</td>\n",
       "      <td>4.75</td>\n",
       "      <td>9.54</td>\n",
       "      <td>43000</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2017</td>\n",
       "      <td>7.25</td>\n",
       "      <td>9.85</td>\n",
       "      <td>6900</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2011</td>\n",
       "      <td>2.85</td>\n",
       "      <td>4.15</td>\n",
       "      <td>5200</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2014</td>\n",
       "      <td>4.60</td>\n",
       "      <td>6.87</td>\n",
       "      <td>42450</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Year  Selling_Price  Present_Price  Kms_Driven Fuel_Type Seller_Type  \\\n",
       "0  2014           3.35           5.59       27000    Petrol      Dealer   \n",
       "1  2013           4.75           9.54       43000    Diesel      Dealer   \n",
       "2  2017           7.25           9.85        6900    Petrol      Dealer   \n",
       "3  2011           2.85           4.15        5200    Petrol      Dealer   \n",
       "4  2014           4.60           6.87       42450    Diesel      Dealer   \n",
       "\n",
       "  Transmission  Owner  Current_Year  \n",
       "0       Manual      0          2020  \n",
       "1       Manual      0          2020  \n",
       "2       Manual      0          2020  \n",
       "3       Manual      0          2020  \n",
       "4       Manual      0          2020  "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "final_dataset['Current_Year']=2020\n",
    "final_dataset.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "##ADDING ANOTHER COLUMN NO_YEAR\n",
    "## SUBSTRACTING CURRENT YEAR AND YEAR TO GIVE VALUE OF NO_YEAR AND DISPLAYING IT \n",
    "  \n",
    "final_dataset['no_year']=final_dataset['Current_Year']-final_dataset['Year']\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>Selling_Price</th>\n",
       "      <th>Present_Price</th>\n",
       "      <th>Kms_Driven</th>\n",
       "      <th>Fuel_Type</th>\n",
       "      <th>Seller_Type</th>\n",
       "      <th>Transmission</th>\n",
       "      <th>Owner</th>\n",
       "      <th>Current_Year</th>\n",
       "      <th>no_year</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2014</td>\n",
       "      <td>3.35</td>\n",
       "      <td>5.59</td>\n",
       "      <td>27000</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2013</td>\n",
       "      <td>4.75</td>\n",
       "      <td>9.54</td>\n",
       "      <td>43000</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2017</td>\n",
       "      <td>7.25</td>\n",
       "      <td>9.85</td>\n",
       "      <td>6900</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2011</td>\n",
       "      <td>2.85</td>\n",
       "      <td>4.15</td>\n",
       "      <td>5200</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2014</td>\n",
       "      <td>4.60</td>\n",
       "      <td>6.87</td>\n",
       "      <td>42450</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Year  Selling_Price  Present_Price  Kms_Driven Fuel_Type Seller_Type  \\\n",
       "0  2014           3.35           5.59       27000    Petrol      Dealer   \n",
       "1  2013           4.75           9.54       43000    Diesel      Dealer   \n",
       "2  2017           7.25           9.85        6900    Petrol      Dealer   \n",
       "3  2011           2.85           4.15        5200    Petrol      Dealer   \n",
       "4  2014           4.60           6.87       42450    Diesel      Dealer   \n",
       "\n",
       "  Transmission  Owner  Current_Year  no_year  \n",
       "0       Manual      0          2020        6  \n",
       "1       Manual      0          2020        7  \n",
       "2       Manual      0          2020        3  \n",
       "3       Manual      0          2020        9  \n",
       "4       Manual      0          2020        6  "
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "final_dataset.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Selling_Price</th>\n",
       "      <th>Present_Price</th>\n",
       "      <th>Kms_Driven</th>\n",
       "      <th>Fuel_Type</th>\n",
       "      <th>Seller_Type</th>\n",
       "      <th>Transmission</th>\n",
       "      <th>Owner</th>\n",
       "      <th>Current_Year</th>\n",
       "      <th>no_year</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3.35</td>\n",
       "      <td>5.59</td>\n",
       "      <td>27000</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4.75</td>\n",
       "      <td>9.54</td>\n",
       "      <td>43000</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>7.25</td>\n",
       "      <td>9.85</td>\n",
       "      <td>6900</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2.85</td>\n",
       "      <td>4.15</td>\n",
       "      <td>5200</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4.60</td>\n",
       "      <td>6.87</td>\n",
       "      <td>42450</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>2020</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Selling_Price  Present_Price  Kms_Driven Fuel_Type Seller_Type  \\\n",
       "0           3.35           5.59       27000    Petrol      Dealer   \n",
       "1           4.75           9.54       43000    Diesel      Dealer   \n",
       "2           7.25           9.85        6900    Petrol      Dealer   \n",
       "3           2.85           4.15        5200    Petrol      Dealer   \n",
       "4           4.60           6.87       42450    Diesel      Dealer   \n",
       "\n",
       "  Transmission  Owner  Current_Year  no_year  \n",
       "0       Manual      0          2020        6  \n",
       "1       Manual      0          2020        7  \n",
       "2       Manual      0          2020        3  \n",
       "3       Manual      0          2020        9  \n",
       "4       Manual      0          2020        6  "
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "##REMOVING YEAR COLUMN\n",
    "## AXIS MEANS, 0=ROW, 1= COLUMN, INPLACE =TRUE MEANS IT SAVES AFTER, FALSE MEANS JUST FOR ONE TIME \n",
    "\n",
    "final_dataset.drop(['Year'],axis=1,inplace=True)\n",
    "final_dataset.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Selling_Price</th>\n",
       "      <th>Present_Price</th>\n",
       "      <th>Kms_Driven</th>\n",
       "      <th>Fuel_Type</th>\n",
       "      <th>Seller_Type</th>\n",
       "      <th>Transmission</th>\n",
       "      <th>Owner</th>\n",
       "      <th>no_year</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3.35</td>\n",
       "      <td>5.59</td>\n",
       "      <td>27000</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4.75</td>\n",
       "      <td>9.54</td>\n",
       "      <td>43000</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>7.25</td>\n",
       "      <td>9.85</td>\n",
       "      <td>6900</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2.85</td>\n",
       "      <td>4.15</td>\n",
       "      <td>5200</td>\n",
       "      <td>Petrol</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4.60</td>\n",
       "      <td>6.87</td>\n",
       "      <td>42450</td>\n",
       "      <td>Diesel</td>\n",
       "      <td>Dealer</td>\n",
       "      <td>Manual</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Selling_Price  Present_Price  Kms_Driven Fuel_Type Seller_Type  \\\n",
       "0           3.35           5.59       27000    Petrol      Dealer   \n",
       "1           4.75           9.54       43000    Diesel      Dealer   \n",
       "2           7.25           9.85        6900    Petrol      Dealer   \n",
       "3           2.85           4.15        5200    Petrol      Dealer   \n",
       "4           4.60           6.87       42450    Diesel      Dealer   \n",
       "\n",
       "  Transmission  Owner  no_year  \n",
       "0       Manual      0        6  \n",
       "1       Manual      0        7  \n",
       "2       Manual      0        3  \n",
       "3       Manual      0        9  \n",
       "4       Manual      0        6  "
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "##REMOVING CURRENT YEAR USING DROP\n",
    "final_dataset.drop(['Current_Year'],axis=1,inplace=True)\n",
    "final_dataset.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "##REMOVING THE DUMMIES VARIABLES SUCH AS FUELTYPE, SELLER TYPE, TRANSMISSION AND DROPPING THE FIRST COLUMN\n",
    "##ALSO KNOWN AS ONE HOT ENCODED \n",
    "\n",
    "final_dataset=pd.get_dummies(final_dataset,drop_first=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Selling_Price</th>\n",
       "      <th>Present_Price</th>\n",
       "      <th>Kms_Driven</th>\n",
       "      <th>Owner</th>\n",
       "      <th>no_year</th>\n",
       "      <th>Fuel_Type_Diesel</th>\n",
       "      <th>Fuel_Type_Petrol</th>\n",
       "      <th>Seller_Type_Individual</th>\n",
       "      <th>Transmission_Manual</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3.35</td>\n",
       "      <td>5.59</td>\n",
       "      <td>27000</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4.75</td>\n",
       "      <td>9.54</td>\n",
       "      <td>43000</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>7.25</td>\n",
       "      <td>9.85</td>\n",
       "      <td>6900</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2.85</td>\n",
       "      <td>4.15</td>\n",
       "      <td>5200</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4.60</td>\n",
       "      <td>6.87</td>\n",
       "      <td>42450</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Selling_Price  Present_Price  Kms_Driven  Owner  no_year  Fuel_Type_Diesel  \\\n",
       "0           3.35           5.59       27000      0        6                 0   \n",
       "1           4.75           9.54       43000      0        7                 1   \n",
       "2           7.25           9.85        6900      0        3                 0   \n",
       "3           2.85           4.15        5200      0        9                 0   \n",
       "4           4.60           6.87       42450      0        6                 1   \n",
       "\n",
       "   Fuel_Type_Petrol  Seller_Type_Individual  Transmission_Manual  \n",
       "0                 1                       0                    1  \n",
       "1                 0                       0                    1  \n",
       "2                 1                       0                    1  \n",
       "3                 1                       0                    1  \n",
       "4                 0                       0                    1  "
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "final_dataset.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
