You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

248 lines
7.3 KiB

{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "6da5789a",
"metadata": {},
"source": [
"## Problématique :\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "f0c31a3f",
"metadata": {},
"source": [
"# <span style=\"color: #FF0000\">**Qu'est ce qui fait qu'une voiture est vendue plus chère qu'une autre ?**</span>\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "f64fb802",
"metadata": {},
"source": [
"## I/ Charger et explorer les données\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "c0f0ed8f",
"metadata": {},
"outputs": [],
"source": [
"# On charge les données, avec la librairie Pandas:\n",
"import pandas as pd\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "5cc5c8ff",
"metadata": {},
"source": [
"## III/ Nettoyage et présentation de données\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "c068815f",
"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>Brand</th>\n",
" <th>Model</th>\n",
" <th>Price</th>\n",
" <th>Year</th>\n",
" <th>Kilometer</th>\n",
" <th>FuelType</th>\n",
" <th>Transmission</th>\n",
" <th>Location</th>\n",
" <th>Color</th>\n",
" <th>Owner</th>\n",
" <th>SellerType</th>\n",
" <th>Engine</th>\n",
" <th>MaxPower</th>\n",
" <th>MaxTorque</th>\n",
" <th>Drivetrain</th>\n",
" <th>Length</th>\n",
" <th>Width</th>\n",
" <th>Height</th>\n",
" <th>SeatingCapacity</th>\n",
" <th>FuelTankCapacity</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>31</th>\n",
" <td>Hyundai</td>\n",
" <td>Creta 1.6 SX Plus AT</td>\n",
" <td>925000</td>\n",
" <td>2016</td>\n",
" <td>66000</td>\n",
" <td>Diesel</td>\n",
" <td>Automatic</td>\n",
" <td>Raipur</td>\n",
" <td>Black</td>\n",
" <td>First</td>\n",
" <td>Individual</td>\n",
" <td>1582 cc</td>\n",
" <td>126 bhp @ 4000 rpm</td>\n",
" <td>265 Nm @ 1900 rpm</td>\n",
" <td>FWD</td>\n",
" <td>4270.0</td>\n",
" <td>1780.0</td>\n",
" <td>1630.0</td>\n",
" <td>5.0</td>\n",
" <td>60.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>32</th>\n",
" <td>Ford</td>\n",
" <td>Ecosport Titanium+ 1.0L EcoBoost</td>\n",
" <td>535000</td>\n",
" <td>2015</td>\n",
" <td>28000</td>\n",
" <td>Petrol</td>\n",
" <td>Manual</td>\n",
" <td>Mumbai</td>\n",
" <td>Silver</td>\n",
" <td>First</td>\n",
" <td>Individual</td>\n",
" <td>999 cc</td>\n",
" <td>124 bhp @ 6000 rpm</td>\n",
" <td>170 Nm @ 1400 rpm</td>\n",
" <td>FWD</td>\n",
" <td>3999.0</td>\n",
" <td>1765.0</td>\n",
" <td>1708.0</td>\n",
" <td>5.0</td>\n",
" <td>52.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>34</th>\n",
" <td>Hyundai</td>\n",
" <td>Santro GL (CNG)</td>\n",
" <td>145000</td>\n",
" <td>2009</td>\n",
" <td>72000</td>\n",
" <td>CNG</td>\n",
" <td>Manual</td>\n",
" <td>Kanpur</td>\n",
" <td>Silver</td>\n",
" <td>Second</td>\n",
" <td>Individual</td>\n",
" <td>1086 cc</td>\n",
" <td>62 bhp @ 5500 rpm</td>\n",
" <td>96 Nm @ 3000 rpm</td>\n",
" <td>FWD</td>\n",
" <td>3565.0</td>\n",
" <td>1525.0</td>\n",
" <td>1590.0</td>\n",
" <td>5.0</td>\n",
" <td>35.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Brand Model Price Year Kilometer \\\n",
"31 Hyundai Creta 1.6 SX Plus AT 925000 2016 66000 \n",
"32 Ford Ecosport Titanium+ 1.0L EcoBoost 535000 2015 28000 \n",
"34 Hyundai Santro GL (CNG) 145000 2009 72000 \n",
"\n",
" FuelType Transmission Location Color Owner SellerType Engine \\\n",
"31 Diesel Automatic Raipur Black First Individual 1582 cc \n",
"32 Petrol Manual Mumbai Silver First Individual 999 cc \n",
"34 CNG Manual Kanpur Silver Second Individual 1086 cc \n",
"\n",
" MaxPower MaxTorque Drivetrain Length Width Height \\\n",
"31 126 bhp @ 4000 rpm 265 Nm @ 1900 rpm FWD 4270.0 1780.0 1630.0 \n",
"32 124 bhp @ 6000 rpm 170 Nm @ 1400 rpm FWD 3999.0 1765.0 1708.0 \n",
"34 62 bhp @ 5500 rpm 96 Nm @ 3000 rpm FWD 3565.0 1525.0 1590.0 \n",
"\n",
" SeatingCapacity FuelTankCapacity \n",
"31 5.0 60.0 \n",
"32 5.0 52.0 \n",
"34 5.0 35.0 "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"df = pd.read_csv(\"csv/carDetailsOld.csv\", encoding=\"latin-1\")\n",
"df = df.dropna(axis=0)\n",
"\n",
"#Permet d'afficher le dataframe\n",
"display(df[30:33])\n",
"\n",
"# Permet de suppr les NAN\n",
"df[\"Engine\"] = df[\"Engine\"].dropna()\n",
"# Permet d'enlever les deux caractères cc\n",
"df[\"Engine\"] = df[\"Engine\"].replace('cc', '')\n",
"df[\"Engine\"] = df[\"Engine\"].astype(str).apply(lambda x: x[:-3])"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "dc0a7b57",
"metadata": {},
"outputs": [],
"source": [
"df.to_csv('csv/carDetails.csv', index=False)\n"
]
}
],
"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.9.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}