diff --git a/src/visualization/dash-app-vis.ipynb b/src/visualization/dash-app-vis.ipynb
index 4034baf..6ac47cb 100644
--- a/src/visualization/dash-app-vis.ipynb
+++ b/src/visualization/dash-app-vis.ipynb
@@ -394,7 +394,7 @@
},
{
"cell_type": "code",
- "execution_count": 77,
+ "execution_count": 108,
"metadata": {},
"outputs": [
{
@@ -417,859 +417,3930 @@
"
\n",
" \n",
" \n",
- " vehicle_type | \n",
+ " | \n",
+ " vehicle_id | \n",
+ " vehicleclass_ | \n",
" make_ | \n",
- " electric | \n",
- " fuel-only | \n",
- " hybrid | \n",
+ " model.1_ | \n",
+ " model_year | \n",
+ " cylinders_ | \n",
+ " fuelconsumption_city(l/100km) | \n",
+ " fuelconsumption_hwy(l/100km) | \n",
+ " fuelconsumption_comb(l/100km) | \n",
+ " co2emissions_(g/km) | \n",
+ " ... | \n",
+ " consumption_city(kwh/100km) | \n",
+ " fuelconsumption_hwy(kwh/100km) | \n",
+ " fuelconsumption_comb(kwh/100km) | \n",
+ " fuelconsumption_city(le/100km) | \n",
+ " fuelconsumption_hwy(le/100km) | \n",
+ " fuelconsumption_comb(le/100km) | \n",
+ " range_(km) | \n",
+ " hybrid_in_fuel | \n",
+ " hybrid_in_electric | \n",
+ " aggregate_levels | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
+ " fuel-only_1 | \n",
+ " full-size | \n",
" acura | \n",
+ " integra | \n",
+ " 2023 | \n",
+ " 4.0 | \n",
+ " 7.9 | \n",
+ " 6.3 | \n",
+ " 7.2 | \n",
+ " 167 | \n",
+ " ... | \n",
+ " 0.0 | \n",
" 0.0 | \n",
- " 121.0 | \n",
" 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 0 | \n",
"
\n",
" \n",
" 1 | \n",
- " alfa romeo | \n",
+ " fuel-only_2 | \n",
+ " full-size | \n",
+ " acura | \n",
+ " integra a-spec | \n",
+ " 2023 | \n",
+ " 4.0 | \n",
+ " 8.1 | \n",
+ " 6.5 | \n",
+ " 7.4 | \n",
+ " 172 | \n",
+ " ... | \n",
" 0.0 | \n",
- " 49.0 | \n",
" 0.0 | \n",
- "
\n",
- " \n",
- " 2 | \n",
- " aston martin | \n",
" 0.0 | \n",
- " 80.0 | \n",
" 0.0 | \n",
- "
\n",
- " \n",
- " 3 | \n",
- " audi | \n",
- " 18.0 | \n",
- " 495.0 | \n",
- " 11.0 | \n",
- "
\n",
- " \n",
- " 4 | \n",
- " bentley | \n",
" 0.0 | \n",
- " 85.0 | \n",
- " 5.0 | \n",
- "
\n",
- " \n",
- " 5 | \n",
- " bmw | \n",
- " 36.0 | \n",
- " 842.0 | \n",
- " 53.0 | \n",
- "
\n",
- " \n",
- " 6 | \n",
- " bugatti | \n",
" 0.0 | \n",
- " 13.0 | \n",
" 0.0 | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 0 | \n",
"
\n",
" \n",
- " 7 | \n",
- " buick | \n",
+ " 2 | \n",
+ " fuel-only_3 | \n",
+ " full-size | \n",
+ " acura | \n",
+ " integra a-spec | \n",
+ " 2023 | \n",
+ " 4.0 | \n",
+ " 8.9 | \n",
+ " 6.5 | \n",
+ " 7.8 | \n",
+ " 181 | \n",
+ " ... | \n",
" 0.0 | \n",
- " 166.0 | \n",
" 0.0 | \n",
- "
\n",
- " \n",
- " 8 | \n",
- " cadillac | \n",
- " 2.0 | \n",
- " 286.0 | \n",
- " 5.0 | \n",
- "
\n",
- " \n",
- " 9 | \n",
- " chevrolet | \n",
- " 12.0 | \n",
- " 1019.0 | \n",
- " 8.0 | \n",
- "
\n",
- " \n",
- " 10 | \n",
- " chrysler | \n",
" 0.0 | \n",
- " 149.0 | \n",
- " 7.0 | \n",
- "
\n",
- " \n",
- " 11 | \n",
- " dodge | \n",
" 0.0 | \n",
- " 385.0 | \n",
" 0.0 | \n",
- "
\n",
- " \n",
- " 12 | \n",
- " fiat | \n",
" 0.0 | \n",
- " 86.0 | \n",
" 0.0 | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 0 | \n",
"
\n",
" \n",
- " 13 | \n",
- " ford | \n",
- " 33.0 | \n",
- " 1068.0 | \n",
- " 17.0 | \n",
- "
\n",
- " \n",
- " 14 | \n",
- " genesis | \n",
- " 4.0 | \n",
- " 51.0 | \n",
+ " 3 | \n",
+ " fuel-only_4 | \n",
+ " suv - small | \n",
+ " acura | \n",
+ " mdx sh-awd | \n",
+ " 2023 | \n",
+ " 6.0 | \n",
+ " 12.6 | \n",
+ " 9.4 | \n",
+ " 11.2 | \n",
+ " 263 | \n",
+ " ... | \n",
" 0.0 | \n",
- "
\n",
- " \n",
- " 15 | \n",
- " gmc | \n",
" 0.0 | \n",
- " 628.0 | \n",
" 0.0 | \n",
- "
\n",
- " \n",
- " 16 | \n",
- " honda | \n",
" 0.0 | \n",
- " 333.0 | \n",
- " 4.0 | \n",
- "
\n",
- " \n",
- " 17 | \n",
- " hyundai | \n",
- " 20.0 | \n",
- " 351.0 | \n",
- " 12.0 | \n",
- "
\n",
- " \n",
- " 18 | \n",
- " infiniti | \n",
" 0.0 | \n",
- " 164.0 | \n",
" 0.0 | \n",
- "
\n",
- " \n",
- " 19 | \n",
- " jaguar | \n",
- " 4.0 | \n",
- " 232.0 | \n",
" 0.0 | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 0 | \n",
"
\n",
" \n",
- " 20 | \n",
- " jeep | \n",
+ " 4 | \n",
+ " fuel-only_5 | \n",
+ " suv - standard | \n",
+ " acura | \n",
+ " mdx sh-awd type s | \n",
+ " 2023 | \n",
+ " 6.0 | \n",
+ " 13.8 | \n",
+ " 11.2 | \n",
+ " 12.4 | \n",
+ " 291 | \n",
+ " ... | \n",
" 0.0 | \n",
- " 393.0 | \n",
- " 5.0 | \n",
- "
\n",
- " \n",
- " 21 | \n",
- " karma | \n",
" 0.0 | \n",
" 0.0 | \n",
- " 7.0 | \n",
- "
\n",
- " \n",
- " 22 | \n",
- " kia | \n",
- " 26.0 | \n",
- " 364.0 | \n",
- " 12.0 | \n",
- "
\n",
- " \n",
- " 23 | \n",
- " lamborghini | \n",
" 0.0 | \n",
- " 81.0 | \n",
" 0.0 | \n",
- "
\n",
- " \n",
- " 24 | \n",
- " land rover | \n",
" 0.0 | \n",
- " 174.0 | \n",
" 0.0 | \n",
- "
\n",
- " \n",
- " 25 | \n",
- " lexus | \n",
- " 2.0 | \n",
- " 301.0 | \n",
- " 2.0 | \n",
- "
\n",
- " \n",
- " 26 | \n",
- " lincoln | \n",
+ " 0 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ "
\n",
+ " \n",
+ " 13091 | \n",
+ " electric_420 | \n",
+ " suv - small | \n",
+ " volkswagen | \n",
+ " id.4 | \n",
+ " 2023 | \n",
" 0.0 | \n",
- " 140.0 | \n",
- " 7.0 | \n",
- "
\n",
- " \n",
- " 27 | \n",
- " lucid | \n",
- " 15.0 | \n",
" 0.0 | \n",
" 0.0 | \n",
+ " 0.0 | \n",
+ " 0 | \n",
+ " ... | \n",
+ " 18.2 | \n",
+ " 21.2 | \n",
+ " 19.6 | \n",
+ " 2.0 | \n",
+ " 2.4 | \n",
+ " 2.2 | \n",
+ " 336.0 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 0 | \n",
"
\n",
" \n",
- " 28 | \n",
- " maserati | \n",
+ " 13092 | \n",
+ " electric_421 | \n",
+ " suv - small | \n",
+ " volkswagen | \n",
+ " id.4 pro | \n",
+ " 2023 | \n",
" 0.0 | \n",
- " 108.0 | \n",
" 0.0 | \n",
- "
\n",
- " \n",
- " 29 | \n",
- " mazda | \n",
- " 2.0 | \n",
- " 298.0 | \n",
" 0.0 | \n",
- "
\n",
- " \n",
- " 30 | \n",
- " mercedes-benz | \n",
- " 8.0 | \n",
- " 744.0 | \n",
- " 9.0 | \n",
- "
\n",
- " \n",
- " 31 | \n",
- " mini | \n",
- " 4.0 | \n",
- " 340.0 | \n",
- " 6.0 | \n",
- "
\n",
- " \n",
- " 32 | \n",
- " mitsubishi | \n",
- " 6.0 | \n",
- " 150.0 | \n",
- " 6.0 | \n",
- "
\n",
- " \n",
- " 33 | \n",
- " nissan | \n",
- " 20.0 | \n",
- " 408.0 | \n",
" 0.0 | \n",
+ " 0 | \n",
+ " ... | \n",
+ " 18.2 | \n",
+ " 21.3 | \n",
+ " 19.6 | \n",
+ " 2.0 | \n",
+ " 2.4 | \n",
+ " 2.2 | \n",
+ " 443.0 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 0 | \n",
"
\n",
" \n",
- " 34 | \n",
- " polestar | \n",
- " 7.0 | \n",
+ " 13093 | \n",
+ " electric_422 | \n",
+ " suv - small | \n",
+ " volkswagen | \n",
+ " id.4 awd pro | \n",
+ " 2023 | \n",
" 0.0 | \n",
- " 1.0 | \n",
- "
\n",
- " \n",
- " 35 | \n",
- " porsche | \n",
- " 21.0 | \n",
- " 665.0 | \n",
- " 22.0 | \n",
- "
\n",
- " \n",
- " 36 | \n",
- " ram | \n",
" 0.0 | \n",
- " 164.0 | \n",
" 0.0 | \n",
- "
\n",
- " \n",
- " 37 | \n",
- " rivian | \n",
- " 10.0 | \n",
" 0.0 | \n",
+ " 0 | \n",
+ " ... | \n",
+ " 20.1 | \n",
+ " 22.6 | \n",
+ " 21.2 | \n",
+ " 2.3 | \n",
+ " 2.5 | \n",
+ " 2.4 | \n",
+ " 410.0 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " 13094 | \n",
+ " electric_423 | \n",
+ " suv - small | \n",
+ " volvo | \n",
+ " c40 recharge twin | \n",
+ " 2023 | \n",
" 0.0 | \n",
- "
\n",
- " \n",
- " 38 | \n",
- " rolls-royce | \n",
" 0.0 | \n",
- " 90.0 | \n",
" 0.0 | \n",
+ " 0.0 | \n",
+ " 0 | \n",
+ " ... | \n",
+ " 22.2 | \n",
+ " 26.1 | \n",
+ " 23.9 | \n",
+ " 2.5 | \n",
+ " 2.9 | \n",
+ " 2.7 | \n",
+ " 364.0 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 0 | \n",
"
\n",
" \n",
- " 39 | \n",
- " scion | \n",
+ " 13095 | \n",
+ " electric_424 | \n",
+ " suv - small | \n",
+ " volvo | \n",
+ " xc40 recharge twin | \n",
+ " 2023 | \n",
" 0.0 | \n",
- " 38.0 | \n",
" 0.0 | \n",
- "
\n",
- " \n",
- " 40 | \n",
- " smart | \n",
- " 10.0 | \n",
- " 11.0 | \n",
" 0.0 | \n",
- "
\n",
- " \n",
- " 41 | \n",
- " smart eq | \n",
- " 2.0 | \n",
- " 0.0 | \n",
- " 0.0 | \n",
- "
\n",
- " \n",
- " 42 | \n",
- " srt | \n",
- " 0.0 | \n",
- " 4.0 | \n",
- " 0.0 | \n",
- "
\n",
- " \n",
- " 43 | \n",
- " subaru | \n",
- " 1.0 | \n",
- " 233.0 | \n",
- " 4.0 | \n",
- "
\n",
- " \n",
- " 44 | \n",
- " suzuki | \n",
- " 0.0 | \n",
- " 24.0 | \n",
- " 0.0 | \n",
- "
\n",
- " \n",
- " 45 | \n",
- " tesla | \n",
- " 143.0 | \n",
- " 0.0 | \n",
- " 0.0 | \n",
- "
\n",
- " \n",
- " 46 | \n",
- " toyota | \n",
- " 2.0 | \n",
- " 571.0 | \n",
- " 13.0 | \n",
- "
\n",
- " \n",
- " 47 | \n",
- " volkswagen | \n",
- " 11.0 | \n",
- " 328.0 | \n",
- " 0.0 | \n",
- "
\n",
- " \n",
- " 48 | \n",
- " volvo | \n",
- " 5.0 | \n",
- " 191.0 | \n",
- " 33.0 | \n",
+ " 0.0 | \n",
+ " 0 | \n",
+ " ... | \n",
+ " 22.8 | \n",
+ " 26.6 | \n",
+ " 24.5 | \n",
+ " 2.6 | \n",
+ " 3.0 | \n",
+ " 2.8 | \n",
+ " 359.0 | \n",
+ " 1 | \n",
+ " 0 | \n",
+ " 0 | \n",
"
\n",
" \n",
"
\n",
+ "13096 rows × 38 columns
\n",
""
],
"text/plain": [
- "vehicle_type make_ electric fuel-only hybrid\n",
- "0 acura 0.0 121.0 0.0\n",
- "1 alfa romeo 0.0 49.0 0.0\n",
- "2 aston martin 0.0 80.0 0.0\n",
- "3 audi 18.0 495.0 11.0\n",
- "4 bentley 0.0 85.0 5.0\n",
- "5 bmw 36.0 842.0 53.0\n",
- "6 bugatti 0.0 13.0 0.0\n",
- "7 buick 0.0 166.0 0.0\n",
- "8 cadillac 2.0 286.0 5.0\n",
- "9 chevrolet 12.0 1019.0 8.0\n",
- "10 chrysler 0.0 149.0 7.0\n",
- "11 dodge 0.0 385.0 0.0\n",
- "12 fiat 0.0 86.0 0.0\n",
- "13 ford 33.0 1068.0 17.0\n",
- "14 genesis 4.0 51.0 0.0\n",
- "15 gmc 0.0 628.0 0.0\n",
- "16 honda 0.0 333.0 4.0\n",
- "17 hyundai 20.0 351.0 12.0\n",
- "18 infiniti 0.0 164.0 0.0\n",
- "19 jaguar 4.0 232.0 0.0\n",
- "20 jeep 0.0 393.0 5.0\n",
- "21 karma 0.0 0.0 7.0\n",
- "22 kia 26.0 364.0 12.0\n",
- "23 lamborghini 0.0 81.0 0.0\n",
- "24 land rover 0.0 174.0 0.0\n",
- "25 lexus 2.0 301.0 2.0\n",
- "26 lincoln 0.0 140.0 7.0\n",
- "27 lucid 15.0 0.0 0.0\n",
- "28 maserati 0.0 108.0 0.0\n",
- "29 mazda 2.0 298.0 0.0\n",
- "30 mercedes-benz 8.0 744.0 9.0\n",
- "31 mini 4.0 340.0 6.0\n",
- "32 mitsubishi 6.0 150.0 6.0\n",
- "33 nissan 20.0 408.0 0.0\n",
- "34 polestar 7.0 0.0 1.0\n",
- "35 porsche 21.0 665.0 22.0\n",
- "36 ram 0.0 164.0 0.0\n",
- "37 rivian 10.0 0.0 0.0\n",
- "38 rolls-royce 0.0 90.0 0.0\n",
- "39 scion 0.0 38.0 0.0\n",
- "40 smart 10.0 11.0 0.0\n",
- "41 smart eq 2.0 0.0 0.0\n",
- "42 srt 0.0 4.0 0.0\n",
- "43 subaru 1.0 233.0 4.0\n",
- "44 suzuki 0.0 24.0 0.0\n",
- "45 tesla 143.0 0.0 0.0\n",
- "46 toyota 2.0 571.0 13.0\n",
- "47 volkswagen 11.0 328.0 0.0\n",
- "48 volvo 5.0 191.0 33.0"
+ " vehicle_id vehicleclass_ make_ model.1_ \\\n",
+ "0 fuel-only_1 full-size acura integra \n",
+ "1 fuel-only_2 full-size acura integra a-spec \n",
+ "2 fuel-only_3 full-size acura integra a-spec \n",
+ "3 fuel-only_4 suv - small acura mdx sh-awd \n",
+ "4 fuel-only_5 suv - standard acura mdx sh-awd type s \n",
+ "... ... ... ... ... \n",
+ "13091 electric_420 suv - small volkswagen id.4 \n",
+ "13092 electric_421 suv - small volkswagen id.4 pro \n",
+ "13093 electric_422 suv - small volkswagen id.4 awd pro \n",
+ "13094 electric_423 suv - small volvo c40 recharge twin \n",
+ "13095 electric_424 suv - small volvo xc40 recharge twin \n",
+ "\n",
+ " model_year cylinders_ fuelconsumption_city(l/100km) \\\n",
+ "0 2023 4.0 7.9 \n",
+ "1 2023 4.0 8.1 \n",
+ "2 2023 4.0 8.9 \n",
+ "3 2023 6.0 12.6 \n",
+ "4 2023 6.0 13.8 \n",
+ "... ... ... ... \n",
+ "13091 2023 0.0 0.0 \n",
+ "13092 2023 0.0 0.0 \n",
+ "13093 2023 0.0 0.0 \n",
+ "13094 2023 0.0 0.0 \n",
+ "13095 2023 0.0 0.0 \n",
+ "\n",
+ " fuelconsumption_hwy(l/100km) fuelconsumption_comb(l/100km) \\\n",
+ "0 6.3 7.2 \n",
+ "1 6.5 7.4 \n",
+ "2 6.5 7.8 \n",
+ "3 9.4 11.2 \n",
+ "4 11.2 12.4 \n",
+ "... ... ... \n",
+ "13091 0.0 0.0 \n",
+ "13092 0.0 0.0 \n",
+ "13093 0.0 0.0 \n",
+ "13094 0.0 0.0 \n",
+ "13095 0.0 0.0 \n",
+ "\n",
+ " co2emissions_(g/km) ... consumption_city(kwh/100km) \\\n",
+ "0 167 ... 0.0 \n",
+ "1 172 ... 0.0 \n",
+ "2 181 ... 0.0 \n",
+ "3 263 ... 0.0 \n",
+ "4 291 ... 0.0 \n",
+ "... ... ... ... \n",
+ "13091 0 ... 18.2 \n",
+ "13092 0 ... 18.2 \n",
+ "13093 0 ... 20.1 \n",
+ "13094 0 ... 22.2 \n",
+ "13095 0 ... 22.8 \n",
+ "\n",
+ " fuelconsumption_hwy(kwh/100km) fuelconsumption_comb(kwh/100km) \\\n",
+ "0 0.0 0.0 \n",
+ "1 0.0 0.0 \n",
+ "2 0.0 0.0 \n",
+ "3 0.0 0.0 \n",
+ "4 0.0 0.0 \n",
+ "... ... ... \n",
+ "13091 21.2 19.6 \n",
+ "13092 21.3 19.6 \n",
+ "13093 22.6 21.2 \n",
+ "13094 26.1 23.9 \n",
+ "13095 26.6 24.5 \n",
+ "\n",
+ " fuelconsumption_city(le/100km) fuelconsumption_hwy(le/100km) \\\n",
+ "0 0.0 0.0 \n",
+ "1 0.0 0.0 \n",
+ "2 0.0 0.0 \n",
+ "3 0.0 0.0 \n",
+ "4 0.0 0.0 \n",
+ "... ... ... \n",
+ "13091 2.0 2.4 \n",
+ "13092 2.0 2.4 \n",
+ "13093 2.3 2.5 \n",
+ "13094 2.5 2.9 \n",
+ "13095 2.6 3.0 \n",
+ "\n",
+ " fuelconsumption_comb(le/100km) range_(km) hybrid_in_fuel \\\n",
+ "0 0.0 0.0 0 \n",
+ "1 0.0 0.0 0 \n",
+ "2 0.0 0.0 0 \n",
+ "3 0.0 0.0 0 \n",
+ "4 0.0 0.0 0 \n",
+ "... ... ... ... \n",
+ "13091 2.2 336.0 1 \n",
+ "13092 2.2 443.0 1 \n",
+ "13093 2.4 410.0 1 \n",
+ "13094 2.7 364.0 1 \n",
+ "13095 2.8 359.0 1 \n",
+ "\n",
+ " hybrid_in_electric aggregate_levels \n",
+ "0 1 0 \n",
+ "1 1 0 \n",
+ "2 1 0 \n",
+ "3 1 0 \n",
+ "4 1 0 \n",
+ "... ... ... \n",
+ "13091 0 0 \n",
+ "13092 0 0 \n",
+ "13093 0 0 \n",
+ "13094 0 0 \n",
+ "13095 0 0 \n",
+ "\n",
+ "[13096 rows x 38 columns]"
]
},
- "execution_count": 77,
+ "execution_count": 108,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "vehicle_type_count = master_df.groupby('make_')['vehicle_type'].value_counts().unstack().reset_index().fillna(0)\n",
- "\n",
- "# Display the dataframe\n",
- "vehicle_type_count\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 89,
- "metadata": {},
- "outputs": [],
- "source": [
- "make_total_avg_score_u = pd.DataFrame(master_df.groupby([\"make_\"])['predicted_co2_rating'].mean()).reset_index().rename(columns={'predicted_co2_rating':'avg_predicted_co2_rating_by_make'})\n",
- "\n",
- "make_total_avg_score_u.sort_values(by='avg_predicted_co2_rating_by_make', ascending=False, inplace=True)\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 68,
- "metadata": {},
- "outputs": [],
- "source": [
- "import numpy as np\n",
- "\n",
- "# Merge this with your current dataframe\n",
- "master_df_d = pd.merge(master_df, total_models_df, on='make_', how='left')\n",
- "\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 85,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Then you can use numpy's average function to compute the weighted average\n",
- "make_total_avg_score = master_df_d.groupby('make_').apply(lambda x: np.average(x['predicted_co2_rating'], \n",
- " weights=x['total_models'])).reset_index().rename(columns={0:'weighted_avg_predicted_co2_rating_by_make'})\n",
- "make_total_avg_score.sort_values(by='weighted_avg_predicted_co2_rating_by_make', ascending=False, inplace=True)\n",
- "\n"
+ "master_df"
]
},
{
"cell_type": "code",
- "execution_count": 88,
+ "execution_count": 140,
"metadata": {},
"outputs": [
{
"data": {
- "text/html": [
- "\n",
- "\n",
- "
\n",
- " \n",
- " \n",
- " | \n",
- " make_ | \n",
- " total_models | \n",
- " weighted_avg_predicted_co2_rating_by_make | \n",
- "
\n",
- " \n",
- " \n",
- " \n",
- " 37 | \n",
- " rivian | \n",
- " 10 | \n",
- " 10.000000 | \n",
- "
\n",
- " \n",
- " 41 | \n",
- " smart eq | \n",
- " 2 | \n",
- " 10.000000 | \n",
- "
\n",
- " \n",
- " 27 | \n",
- " lucid | \n",
- " 15 | \n",
- " 10.000000 | \n",
- "
\n",
- " \n",
- " 34 | \n",
- " polestar | \n",
- " 6 | \n",
- " 10.000000 | \n",
- "
\n",
- " \n",
- " 21 | \n",
- " karma | \n",
- " 5 | \n",
- " 10.000000 | \n",
- "
\n",
- " \n",
- " 45 | \n",
- " tesla | \n",
- " 61 | \n",
- " 10.000000 | \n",
- "
\n",
- " \n",
- " 40 | \n",
- " smart | \n",
- " 4 | \n",
- " 9.238095 | \n",
- "
\n",
- " \n",
- " 12 | \n",
- " fiat | \n",
- " 13 | \n",
- " 6.627907 | \n",
- "
\n",
- " \n",
- " 16 | \n",
- " honda | \n",
- " 44 | \n",
- " 6.560831 | \n",
- "
\n",
- " \n",
- " 31 | \n",
- " mini | \n",
- " 35 | \n",
- " 6.451429 | \n",
- "
\n",
- " \n",
- " 17 | \n",
- " hyundai | \n",
- " 64 | \n",
- " 6.441253 | \n",
- "
\n",
- " \n",
- " 22 | \n",
- " kia | \n",
- " 55 | \n",
- " 6.395522 | \n",
- "
\n",
- " \n",
- " 32 | \n",
- " mitsubishi | \n",
- " 18 | \n",
- " 6.370370 | \n",
- "
\n",
- " \n",
- " 39 | \n",
- " scion | \n",
- " 6 | \n",
- " 6.342105 | \n",
- "
\n",
- " \n",
- " 29 | \n",
- " mazda | \n",
- " 45 | \n",
- " 6.306667 | \n",
- "
\n",
- " \n",
- " 47 | \n",
- " volkswagen | \n",
- " 45 | \n",
- " 6.032448 | \n",
- "
\n",
- " \n",
- " 46 | \n",
- " toyota | \n",
- " 97 | \n",
- " 5.880546 | \n",
+ "application/vnd.plotly.v1+json": {
+ "config": {
+ "plotlyServerURL": "https://plot.ly"
+ },
+ "data": [
+ {
+ "alignmentgroup": "True",
+ "hovertemplate": "vehicle_type=%{x}
count=%{y}",
+ "legendgroup": "",
+ "marker": {
+ "color": "#636efa",
+ "pattern": {
+ "shape": ""
+ }
+ },
+ "name": "",
+ "offsetgroup": "",
+ "orientation": "v",
+ "showlegend": false,
+ "textposition": "auto",
+ "type": "bar",
+ "x": [
+ "fuel-only",
+ "electric",
+ "hybrid"
+ ],
+ "xaxis": "x",
+ "y": [
+ 12423,
+ 424,
+ 249
+ ],
+ "yaxis": "y"
+ }
+ ],
+ "layout": {
+ "barmode": "relative",
+ "legend": {
+ "tracegroupgap": 0
+ },
+ "template": {
+ "data": {
+ "bar": [
+ {
+ "error_x": {
+ "color": "#2a3f5f"
+ },
+ "error_y": {
+ "color": "#2a3f5f"
+ },
+ "marker": {
+ "line": {
+ "color": "#E5ECF6",
+ "width": 0.5
+ },
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "bar"
+ }
+ ],
+ "barpolar": [
+ {
+ "marker": {
+ "line": {
+ "color": "#E5ECF6",
+ "width": 0.5
+ },
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "barpolar"
+ }
+ ],
+ "carpet": [
+ {
+ "aaxis": {
+ "endlinecolor": "#2a3f5f",
+ "gridcolor": "white",
+ "linecolor": "white",
+ "minorgridcolor": "white",
+ "startlinecolor": "#2a3f5f"
+ },
+ "baxis": {
+ "endlinecolor": "#2a3f5f",
+ "gridcolor": "white",
+ "linecolor": "white",
+ "minorgridcolor": "white",
+ "startlinecolor": "#2a3f5f"
+ },
+ "type": "carpet"
+ }
+ ],
+ "choropleth": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "type": "choropleth"
+ }
+ ],
+ "contour": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "contour"
+ }
+ ],
+ "contourcarpet": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "type": "contourcarpet"
+ }
+ ],
+ "heatmap": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "heatmap"
+ }
+ ],
+ "heatmapgl": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "heatmapgl"
+ }
+ ],
+ "histogram": [
+ {
+ "marker": {
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "histogram"
+ }
+ ],
+ "histogram2d": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "histogram2d"
+ }
+ ],
+ "histogram2dcontour": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "histogram2dcontour"
+ }
+ ],
+ "mesh3d": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "type": "mesh3d"
+ }
+ ],
+ "parcoords": [
+ {
+ "line": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "parcoords"
+ }
+ ],
+ "pie": [
+ {
+ "automargin": true,
+ "type": "pie"
+ }
+ ],
+ "scatter": [
+ {
+ "fillpattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ },
+ "type": "scatter"
+ }
+ ],
+ "scatter3d": [
+ {
+ "line": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scatter3d"
+ }
+ ],
+ "scattercarpet": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scattercarpet"
+ }
+ ],
+ "scattergeo": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scattergeo"
+ }
+ ],
+ "scattergl": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scattergl"
+ }
+ ],
+ "scattermapbox": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scattermapbox"
+ }
+ ],
+ "scatterpolar": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scatterpolar"
+ }
+ ],
+ "scatterpolargl": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scatterpolargl"
+ }
+ ],
+ "scatterternary": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scatterternary"
+ }
+ ],
+ "surface": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "surface"
+ }
+ ],
+ "table": [
+ {
+ "cells": {
+ "fill": {
+ "color": "#EBF0F8"
+ },
+ "line": {
+ "color": "white"
+ }
+ },
+ "header": {
+ "fill": {
+ "color": "#C8D4E3"
+ },
+ "line": {
+ "color": "white"
+ }
+ },
+ "type": "table"
+ }
+ ]
+ },
+ "layout": {
+ "annotationdefaults": {
+ "arrowcolor": "#2a3f5f",
+ "arrowhead": 0,
+ "arrowwidth": 1
+ },
+ "autotypenumbers": "strict",
+ "coloraxis": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "colorscale": {
+ "diverging": [
+ [
+ 0,
+ "#8e0152"
+ ],
+ [
+ 0.1,
+ "#c51b7d"
+ ],
+ [
+ 0.2,
+ "#de77ae"
+ ],
+ [
+ 0.3,
+ "#f1b6da"
+ ],
+ [
+ 0.4,
+ "#fde0ef"
+ ],
+ [
+ 0.5,
+ "#f7f7f7"
+ ],
+ [
+ 0.6,
+ "#e6f5d0"
+ ],
+ [
+ 0.7,
+ "#b8e186"
+ ],
+ [
+ 0.8,
+ "#7fbc41"
+ ],
+ [
+ 0.9,
+ "#4d9221"
+ ],
+ [
+ 1,
+ "#276419"
+ ]
+ ],
+ "sequential": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "sequentialminus": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ]
+ },
+ "colorway": [
+ "#636efa",
+ "#EF553B",
+ "#00cc96",
+ "#ab63fa",
+ "#FFA15A",
+ "#19d3f3",
+ "#FF6692",
+ "#B6E880",
+ "#FF97FF",
+ "#FECB52"
+ ],
+ "font": {
+ "color": "#2a3f5f"
+ },
+ "geo": {
+ "bgcolor": "white",
+ "lakecolor": "white",
+ "landcolor": "#E5ECF6",
+ "showlakes": true,
+ "showland": true,
+ "subunitcolor": "white"
+ },
+ "hoverlabel": {
+ "align": "left"
+ },
+ "hovermode": "closest",
+ "mapbox": {
+ "style": "light"
+ },
+ "paper_bgcolor": "white",
+ "plot_bgcolor": "#E5ECF6",
+ "polar": {
+ "angularaxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ },
+ "bgcolor": "#E5ECF6",
+ "radialaxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ }
+ },
+ "scene": {
+ "xaxis": {
+ "backgroundcolor": "#E5ECF6",
+ "gridcolor": "white",
+ "gridwidth": 2,
+ "linecolor": "white",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "white"
+ },
+ "yaxis": {
+ "backgroundcolor": "#E5ECF6",
+ "gridcolor": "white",
+ "gridwidth": 2,
+ "linecolor": "white",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "white"
+ },
+ "zaxis": {
+ "backgroundcolor": "#E5ECF6",
+ "gridcolor": "white",
+ "gridwidth": 2,
+ "linecolor": "white",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "white"
+ }
+ },
+ "shapedefaults": {
+ "line": {
+ "color": "#2a3f5f"
+ }
+ },
+ "ternary": {
+ "aaxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ },
+ "baxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ },
+ "bgcolor": "#E5ECF6",
+ "caxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ }
+ },
+ "title": {
+ "x": 0.05
+ },
+ "xaxis": {
+ "automargin": true,
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": "",
+ "title": {
+ "standoff": 15
+ },
+ "zerolinecolor": "white",
+ "zerolinewidth": 2
+ },
+ "yaxis": {
+ "automargin": true,
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": "",
+ "title": {
+ "standoff": 15
+ },
+ "zerolinecolor": "white",
+ "zerolinewidth": 2
+ }
+ }
+ },
+ "title": {
+ "text": "Vehicle Type Count"
+ },
+ "xaxis": {
+ "anchor": "y",
+ "domain": [
+ 0,
+ 1
+ ],
+ "title": {
+ "text": "vehicle_type"
+ }
+ },
+ "yaxis": {
+ "anchor": "x",
+ "domain": [
+ 0,
+ 1
+ ],
+ "title": {
+ "text": "count"
+ }
+ }
+ }
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "vehicle_type_count = master_df['vehicle_type'].value_counts().reset_index()\n",
+ "vehicle_type_count.columns = ['vehicle_type', 'count']\n",
+ "\n",
+ "\n",
+ "\n",
+ "vehicle_type_count\n",
+ "\n",
+ "px.bar(vehicle_type_count, x='vehicle_type', y='count', title='Vehicle Type Count')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 117,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "0"
+ ]
+ },
+ "execution_count": 117,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# count total number of electric vehicles\n",
+ "electric_vehicles = master_df[master_df['fuel_type'] == 'Electricity']\n",
+ "electric_vehicles_count = electric_vehicles['fuel_type'].count()\n",
+ "\n",
+ "electric_vehicles_count"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 89,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "make_total_avg_score_u = pd.DataFrame(master_df.groupby([\"make_\"])['predicted_co2_rating'].mean()).reset_index().rename(columns={'predicted_co2_rating':'avg_predicted_co2_rating_by_make'})\n",
+ "\n",
+ "make_total_avg_score_u.sort_values(by='avg_predicted_co2_rating_by_make', ascending=False, inplace=True)\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 68,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import numpy as np\n",
+ "\n",
+ "# Merge this with your current dataframe\n",
+ "master_df_d = pd.merge(master_df, total_models_df, on='make_', how='left')\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 85,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Then you can use numpy's average function to compute the weighted average\n",
+ "make_total_avg_score = master_df_d.groupby('make_').apply(lambda x: np.average(x['predicted_co2_rating'], \n",
+ " weights=x['total_models'])).reset_index().rename(columns={0:'weighted_avg_predicted_co2_rating_by_make'})\n",
+ "make_total_avg_score.sort_values(by='weighted_avg_predicted_co2_rating_by_make', ascending=False, inplace=True)\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 103,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "weighted_avg_df = pd.merge(total_models_df, make_total_avg_score, on='make_', how='left')\n",
+ "\n",
+ "# sort the dataframe by the weighted average\n",
+ "weighted_avg_df.sort_values(by='weighted_avg_predicted_co2_rating_by_make', ascending=False, inplace=True)\n",
+ "\n",
+ "df = pd.merge(weighted_avg_df, vehicle_type_count, on='make_', how='left').sort_values(by='weighted_avg_predicted_co2_rating_by_make', ascending=False)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 107,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " vehicle_type | \n",
+ " make_ | \n",
+ " electric | \n",
+ " fuel-only | \n",
+ " hybrid | \n",
"
\n",
+ " \n",
+ " \n",
" \n",
- " 48 | \n",
- " volvo | \n",
- " 95 | \n",
- " 5.855895 | \n",
+ " 0 | \n",
+ " acura | \n",
+ " 0.0 | \n",
+ " 121.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
- " 44 | \n",
- " suzuki | \n",
- " 15 | \n",
- " 5.833333 | \n",
+ " 1 | \n",
+ " alfa romeo | \n",
+ " 0.0 | \n",
+ " 49.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
- " 43 | \n",
- " subaru | \n",
- " 23 | \n",
- " 5.672269 | \n",
+ " 2 | \n",
+ " aston martin | \n",
+ " 0.0 | \n",
+ " 80.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
- " 33 | \n",
- " nissan | \n",
- " 53 | \n",
- " 5.464953 | \n",
+ " 3 | \n",
+ " audi | \n",
+ " 18.0 | \n",
+ " 495.0 | \n",
+ " 11.0 | \n",
"
\n",
" \n",
- " 7 | \n",
- " buick | \n",
- " 28 | \n",
- " 5.234940 | \n",
+ " 4 | \n",
+ " bentley | \n",
+ " 0.0 | \n",
+ " 85.0 | \n",
+ " 5.0 | \n",
"
\n",
" \n",
- " 0 | \n",
- " acura | \n",
- " 31 | \n",
- " 5.190083 | \n",
+ " 5 | \n",
+ " bmw | \n",
+ " 36.0 | \n",
+ " 842.0 | \n",
+ " 53.0 | \n",
"
\n",
" \n",
- " 25 | \n",
- " lexus | \n",
- " 67 | \n",
- " 5.157377 | \n",
+ " 6 | \n",
+ " bugatti | \n",
+ " 0.0 | \n",
+ " 13.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
- " 1 | \n",
- " alfa romeo | \n",
- " 11 | \n",
- " 5.061224 | \n",
+ " 7 | \n",
+ " buick | \n",
+ " 0.0 | \n",
+ " 166.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
- " 5 | \n",
- " bmw | \n",
- " 265 | \n",
- " 4.980666 | \n",
+ " 8 | \n",
+ " cadillac | \n",
+ " 2.0 | \n",
+ " 286.0 | \n",
+ " 5.0 | \n",
+ "
\n",
+ " \n",
+ " 9 | \n",
+ " chevrolet | \n",
+ " 12.0 | \n",
+ " 1019.0 | \n",
+ " 8.0 | \n",
"
\n",
" \n",
" 10 | \n",
" chrysler | \n",
- " 31 | \n",
- " 4.916667 | \n",
+ " 0.0 | \n",
+ " 149.0 | \n",
+ " 7.0 | \n",
"
\n",
" \n",
- " 3 | \n",
- " audi | \n",
- " 155 | \n",
- " 4.916031 | \n",
+ " 11 | \n",
+ " dodge | \n",
+ " 0.0 | \n",
+ " 385.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " 12 | \n",
+ " fiat | \n",
+ " 0.0 | \n",
+ " 86.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
" 13 | \n",
" ford | \n",
- " 155 | \n",
- " 4.635957 | \n",
+ " 33.0 | \n",
+ " 1068.0 | \n",
+ " 17.0 | \n",
"
\n",
" \n",
- " 35 | \n",
- " porsche | \n",
- " 114 | \n",
- " 4.615819 | \n",
+ " 14 | \n",
+ " genesis | \n",
+ " 4.0 | \n",
+ " 51.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
- " 26 | \n",
- " lincoln | \n",
- " 24 | \n",
- " 4.605442 | \n",
+ " 15 | \n",
+ " gmc | \n",
+ " 0.0 | \n",
+ " 628.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " 16 | \n",
+ " honda | \n",
+ " 0.0 | \n",
+ " 333.0 | \n",
+ " 4.0 | \n",
+ "
\n",
+ " \n",
+ " 17 | \n",
+ " hyundai | \n",
+ " 20.0 | \n",
+ " 351.0 | \n",
+ " 12.0 | \n",
"
\n",
" \n",
" 18 | \n",
" infiniti | \n",
- " 46 | \n",
- " 4.573171 | \n",
+ " 0.0 | \n",
+ " 164.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " 19 | \n",
+ " jaguar | \n",
+ " 4.0 | \n",
+ " 232.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
" 20 | \n",
" jeep | \n",
- " 66 | \n",
- " 4.572864 | \n",
+ " 0.0 | \n",
+ " 393.0 | \n",
+ " 5.0 | \n",
"
\n",
" \n",
- " 14 | \n",
- " genesis | \n",
- " 11 | \n",
- " 4.454545 | \n",
+ " 21 | \n",
+ " karma | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ " 7.0 | \n",
"
\n",
" \n",
- " 8 | \n",
- " cadillac | \n",
- " 52 | \n",
- " 4.453925 | \n",
+ " 22 | \n",
+ " kia | \n",
+ " 26.0 | \n",
+ " 364.0 | \n",
+ " 12.0 | \n",
+ "
\n",
+ " \n",
+ " 23 | \n",
+ " lamborghini | \n",
+ " 0.0 | \n",
+ " 81.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " 24 | \n",
+ " land rover | \n",
+ " 0.0 | \n",
+ " 174.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " 25 | \n",
+ " lexus | \n",
+ " 2.0 | \n",
+ " 301.0 | \n",
+ " 2.0 | \n",
+ "
\n",
+ " \n",
+ " 26 | \n",
+ " lincoln | \n",
+ " 0.0 | \n",
+ " 140.0 | \n",
+ " 7.0 | \n",
+ "
\n",
+ " \n",
+ " 27 | \n",
+ " lucid | \n",
+ " 15.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " 28 | \n",
+ " maserati | \n",
+ " 0.0 | \n",
+ " 108.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " 29 | \n",
+ " mazda | \n",
+ " 2.0 | \n",
+ " 298.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " 30 | \n",
+ " mercedes-benz | \n",
+ " 8.0 | \n",
+ " 744.0 | \n",
+ " 9.0 | \n",
+ "
\n",
+ " \n",
+ " 31 | \n",
+ " mini | \n",
+ " 4.0 | \n",
+ " 340.0 | \n",
+ " 6.0 | \n",
+ "
\n",
+ " \n",
+ " 32 | \n",
+ " mitsubishi | \n",
+ " 6.0 | \n",
+ " 150.0 | \n",
+ " 6.0 | \n",
+ "
\n",
+ " \n",
+ " 33 | \n",
+ " nissan | \n",
+ " 20.0 | \n",
+ " 408.0 | \n",
+ " 0.0 | \n",
+ "
\n",
+ " \n",
+ " 34 | \n",
+ " polestar | \n",
+ " 7.0 | \n",
+ " 0.0 | \n",
+ " 1.0 | \n",
"
\n",
" \n",
- " 19 | \n",
- " jaguar | \n",
- " 89 | \n",
- " 4.394068 | \n",
+ " 35 | \n",
+ " porsche | \n",
+ " 21.0 | \n",
+ " 665.0 | \n",
+ " 22.0 | \n",
"
\n",
" \n",
- " 9 | \n",
- " chevrolet | \n",
- " 128 | \n",
- " 4.353224 | \n",
+ " 36 | \n",
+ " ram | \n",
+ " 0.0 | \n",
+ " 164.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
- " 30 | \n",
- " mercedes-benz | \n",
- " 291 | \n",
- " 4.254928 | \n",
+ " 37 | \n",
+ " rivian | \n",
+ " 10.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
- " 11 | \n",
- " dodge | \n",
- " 56 | \n",
- " 4.093506 | \n",
+ " 38 | \n",
+ " rolls-royce | \n",
+ " 0.0 | \n",
+ " 90.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
- " 24 | \n",
- " land rover | \n",
- " 77 | \n",
- " 3.724138 | \n",
+ " 39 | \n",
+ " scion | \n",
+ " 0.0 | \n",
+ " 38.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
- " 36 | \n",
- " ram | \n",
- " 28 | \n",
- " 3.676829 | \n",
+ " 40 | \n",
+ " smart | \n",
+ " 10.0 | \n",
+ " 11.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
- " 15 | \n",
- " gmc | \n",
- " 79 | \n",
- " 3.371019 | \n",
+ " 41 | \n",
+ " smart eq | \n",
+ " 2.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
- " 28 | \n",
- " maserati | \n",
- " 32 | \n",
- " 3.101852 | \n",
+ " 42 | \n",
+ " srt | \n",
+ " 0.0 | \n",
+ " 4.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
- " 2 | \n",
- " aston martin | \n",
- " 22 | \n",
- " 2.675000 | \n",
+ " 43 | \n",
+ " subaru | \n",
+ " 1.0 | \n",
+ " 233.0 | \n",
+ " 4.0 | \n",
"
\n",
" \n",
- " 4 | \n",
- " bentley | \n",
- " 21 | \n",
- " 2.533333 | \n",
+ " 44 | \n",
+ " suzuki | \n",
+ " 0.0 | \n",
+ " 24.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
- " 42 | \n",
- " srt | \n",
- " 4 | \n",
- " 2.000000 | \n",
+ " 45 | \n",
+ " tesla | \n",
+ " 143.0 | \n",
+ " 0.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
- " 23 | \n",
- " lamborghini | \n",
- " 39 | \n",
- " 1.567901 | \n",
+ " 46 | \n",
+ " toyota | \n",
+ " 2.0 | \n",
+ " 571.0 | \n",
+ " 13.0 | \n",
"
\n",
" \n",
- " 38 | \n",
- " rolls-royce | \n",
- " 15 | \n",
- " 1.533333 | \n",
+ " 47 | \n",
+ " volkswagen | \n",
+ " 11.0 | \n",
+ " 328.0 | \n",
+ " 0.0 | \n",
"
\n",
" \n",
- " 6 | \n",
- " bugatti | \n",
- " 5 | \n",
- " 1.000000 | \n",
+ " 48 | \n",
+ " volvo | \n",
+ " 5.0 | \n",
+ " 191.0 | \n",
+ " 33.0 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
- " make_ total_models weighted_avg_predicted_co2_rating_by_make\n",
- "37 rivian 10 10.000000\n",
- "41 smart eq 2 10.000000\n",
- "27 lucid 15 10.000000\n",
- "34 polestar 6 10.000000\n",
- "21 karma 5 10.000000\n",
- "45 tesla 61 10.000000\n",
- "40 smart 4 9.238095\n",
- "12 fiat 13 6.627907\n",
- "16 honda 44 6.560831\n",
- "31 mini 35 6.451429\n",
- "17 hyundai 64 6.441253\n",
- "22 kia 55 6.395522\n",
- "32 mitsubishi 18 6.370370\n",
- "39 scion 6 6.342105\n",
- "29 mazda 45 6.306667\n",
- "47 volkswagen 45 6.032448\n",
- "46 toyota 97 5.880546\n",
- "48 volvo 95 5.855895\n",
- "44 suzuki 15 5.833333\n",
- "43 subaru 23 5.672269\n",
- "33 nissan 53 5.464953\n",
- "7 buick 28 5.234940\n",
- "0 acura 31 5.190083\n",
- "25 lexus 67 5.157377\n",
- "1 alfa romeo 11 5.061224\n",
- "5 bmw 265 4.980666\n",
- "10 chrysler 31 4.916667\n",
- "3 audi 155 4.916031\n",
- "13 ford 155 4.635957\n",
- "35 porsche 114 4.615819\n",
- "26 lincoln 24 4.605442\n",
- "18 infiniti 46 4.573171\n",
- "20 jeep 66 4.572864\n",
- "14 genesis 11 4.454545\n",
- "8 cadillac 52 4.453925\n",
- "19 jaguar 89 4.394068\n",
- "9 chevrolet 128 4.353224\n",
- "30 mercedes-benz 291 4.254928\n",
- "11 dodge 56 4.093506\n",
- "24 land rover 77 3.724138\n",
- "36 ram 28 3.676829\n",
- "15 gmc 79 3.371019\n",
- "28 maserati 32 3.101852\n",
- "2 aston martin 22 2.675000\n",
- "4 bentley 21 2.533333\n",
- "42 srt 4 2.000000\n",
- "23 lamborghini 39 1.567901\n",
- "38 rolls-royce 15 1.533333\n",
- "6 bugatti 5 1.000000"
+ "vehicle_type make_ electric fuel-only hybrid\n",
+ "0 acura 0.0 121.0 0.0\n",
+ "1 alfa romeo 0.0 49.0 0.0\n",
+ "2 aston martin 0.0 80.0 0.0\n",
+ "3 audi 18.0 495.0 11.0\n",
+ "4 bentley 0.0 85.0 5.0\n",
+ "5 bmw 36.0 842.0 53.0\n",
+ "6 bugatti 0.0 13.0 0.0\n",
+ "7 buick 0.0 166.0 0.0\n",
+ "8 cadillac 2.0 286.0 5.0\n",
+ "9 chevrolet 12.0 1019.0 8.0\n",
+ "10 chrysler 0.0 149.0 7.0\n",
+ "11 dodge 0.0 385.0 0.0\n",
+ "12 fiat 0.0 86.0 0.0\n",
+ "13 ford 33.0 1068.0 17.0\n",
+ "14 genesis 4.0 51.0 0.0\n",
+ "15 gmc 0.0 628.0 0.0\n",
+ "16 honda 0.0 333.0 4.0\n",
+ "17 hyundai 20.0 351.0 12.0\n",
+ "18 infiniti 0.0 164.0 0.0\n",
+ "19 jaguar 4.0 232.0 0.0\n",
+ "20 jeep 0.0 393.0 5.0\n",
+ "21 karma 0.0 0.0 7.0\n",
+ "22 kia 26.0 364.0 12.0\n",
+ "23 lamborghini 0.0 81.0 0.0\n",
+ "24 land rover 0.0 174.0 0.0\n",
+ "25 lexus 2.0 301.0 2.0\n",
+ "26 lincoln 0.0 140.0 7.0\n",
+ "27 lucid 15.0 0.0 0.0\n",
+ "28 maserati 0.0 108.0 0.0\n",
+ "29 mazda 2.0 298.0 0.0\n",
+ "30 mercedes-benz 8.0 744.0 9.0\n",
+ "31 mini 4.0 340.0 6.0\n",
+ "32 mitsubishi 6.0 150.0 6.0\n",
+ "33 nissan 20.0 408.0 0.0\n",
+ "34 polestar 7.0 0.0 1.0\n",
+ "35 porsche 21.0 665.0 22.0\n",
+ "36 ram 0.0 164.0 0.0\n",
+ "37 rivian 10.0 0.0 0.0\n",
+ "38 rolls-royce 0.0 90.0 0.0\n",
+ "39 scion 0.0 38.0 0.0\n",
+ "40 smart 10.0 11.0 0.0\n",
+ "41 smart eq 2.0 0.0 0.0\n",
+ "42 srt 0.0 4.0 0.0\n",
+ "43 subaru 1.0 233.0 4.0\n",
+ "44 suzuki 0.0 24.0 0.0\n",
+ "45 tesla 143.0 0.0 0.0\n",
+ "46 toyota 2.0 571.0 13.0\n",
+ "47 volkswagen 11.0 328.0 0.0\n",
+ "48 volvo 5.0 191.0 33.0"
]
},
- "execution_count": 88,
+ "execution_count": 107,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "vehicle_type_count"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 106,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.plotly.v1+json": {
+ "config": {
+ "plotlyServerURL": "https://plot.ly"
+ },
+ "data": [
+ {
+ "marker": {
+ "color": "rgb(26, 118, 255)"
+ },
+ "name": "Electric",
+ "type": "bar",
+ "x": [
+ "bmw"
+ ],
+ "y": [
+ 36
+ ]
+ },
+ {
+ "marker": {
+ "color": "rgb(55, 83, 109)"
+ },
+ "name": "Fuel-only",
+ "type": "bar",
+ "x": [
+ "bmw"
+ ],
+ "y": [
+ 842
+ ]
+ },
+ {
+ "marker": {
+ "color": "rgb(26, 188, 156)"
+ },
+ "name": "Hybrid",
+ "type": "bar",
+ "x": [
+ "bmw"
+ ],
+ "y": [
+ 53
+ ]
+ }
+ ],
+ "layout": {
+ "barmode": "stack",
+ "font": {
+ "color": "white"
+ },
+ "paper_bgcolor": "#003f5c",
+ "plot_bgcolor": "#003f5c",
+ "template": {
+ "data": {
+ "bar": [
+ {
+ "error_x": {
+ "color": "#2a3f5f"
+ },
+ "error_y": {
+ "color": "#2a3f5f"
+ },
+ "marker": {
+ "line": {
+ "color": "#E5ECF6",
+ "width": 0.5
+ },
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "bar"
+ }
+ ],
+ "barpolar": [
+ {
+ "marker": {
+ "line": {
+ "color": "#E5ECF6",
+ "width": 0.5
+ },
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "barpolar"
+ }
+ ],
+ "carpet": [
+ {
+ "aaxis": {
+ "endlinecolor": "#2a3f5f",
+ "gridcolor": "white",
+ "linecolor": "white",
+ "minorgridcolor": "white",
+ "startlinecolor": "#2a3f5f"
+ },
+ "baxis": {
+ "endlinecolor": "#2a3f5f",
+ "gridcolor": "white",
+ "linecolor": "white",
+ "minorgridcolor": "white",
+ "startlinecolor": "#2a3f5f"
+ },
+ "type": "carpet"
+ }
+ ],
+ "choropleth": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "type": "choropleth"
+ }
+ ],
+ "contour": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "contour"
+ }
+ ],
+ "contourcarpet": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "type": "contourcarpet"
+ }
+ ],
+ "heatmap": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "heatmap"
+ }
+ ],
+ "heatmapgl": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "heatmapgl"
+ }
+ ],
+ "histogram": [
+ {
+ "marker": {
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "histogram"
+ }
+ ],
+ "histogram2d": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "histogram2d"
+ }
+ ],
+ "histogram2dcontour": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "histogram2dcontour"
+ }
+ ],
+ "mesh3d": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "type": "mesh3d"
+ }
+ ],
+ "parcoords": [
+ {
+ "line": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "parcoords"
+ }
+ ],
+ "pie": [
+ {
+ "automargin": true,
+ "type": "pie"
+ }
+ ],
+ "scatter": [
+ {
+ "fillpattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ },
+ "type": "scatter"
+ }
+ ],
+ "scatter3d": [
+ {
+ "line": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scatter3d"
+ }
+ ],
+ "scattercarpet": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scattercarpet"
+ }
+ ],
+ "scattergeo": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scattergeo"
+ }
+ ],
+ "scattergl": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scattergl"
+ }
+ ],
+ "scattermapbox": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scattermapbox"
+ }
+ ],
+ "scatterpolar": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scatterpolar"
+ }
+ ],
+ "scatterpolargl": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scatterpolargl"
+ }
+ ],
+ "scatterternary": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scatterternary"
+ }
+ ],
+ "surface": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "surface"
+ }
+ ],
+ "table": [
+ {
+ "cells": {
+ "fill": {
+ "color": "#EBF0F8"
+ },
+ "line": {
+ "color": "white"
+ }
+ },
+ "header": {
+ "fill": {
+ "color": "#C8D4E3"
+ },
+ "line": {
+ "color": "white"
+ }
+ },
+ "type": "table"
+ }
+ ]
+ },
+ "layout": {
+ "annotationdefaults": {
+ "arrowcolor": "#2a3f5f",
+ "arrowhead": 0,
+ "arrowwidth": 1
+ },
+ "autotypenumbers": "strict",
+ "coloraxis": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "colorscale": {
+ "diverging": [
+ [
+ 0,
+ "#8e0152"
+ ],
+ [
+ 0.1,
+ "#c51b7d"
+ ],
+ [
+ 0.2,
+ "#de77ae"
+ ],
+ [
+ 0.3,
+ "#f1b6da"
+ ],
+ [
+ 0.4,
+ "#fde0ef"
+ ],
+ [
+ 0.5,
+ "#f7f7f7"
+ ],
+ [
+ 0.6,
+ "#e6f5d0"
+ ],
+ [
+ 0.7,
+ "#b8e186"
+ ],
+ [
+ 0.8,
+ "#7fbc41"
+ ],
+ [
+ 0.9,
+ "#4d9221"
+ ],
+ [
+ 1,
+ "#276419"
+ ]
+ ],
+ "sequential": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "sequentialminus": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ]
+ },
+ "colorway": [
+ "#636efa",
+ "#EF553B",
+ "#00cc96",
+ "#ab63fa",
+ "#FFA15A",
+ "#19d3f3",
+ "#FF6692",
+ "#B6E880",
+ "#FF97FF",
+ "#FECB52"
+ ],
+ "font": {
+ "color": "#2a3f5f"
+ },
+ "geo": {
+ "bgcolor": "white",
+ "lakecolor": "white",
+ "landcolor": "#E5ECF6",
+ "showlakes": true,
+ "showland": true,
+ "subunitcolor": "white"
+ },
+ "hoverlabel": {
+ "align": "left"
+ },
+ "hovermode": "closest",
+ "mapbox": {
+ "style": "light"
+ },
+ "paper_bgcolor": "white",
+ "plot_bgcolor": "#E5ECF6",
+ "polar": {
+ "angularaxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ },
+ "bgcolor": "#E5ECF6",
+ "radialaxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ }
+ },
+ "scene": {
+ "xaxis": {
+ "backgroundcolor": "#E5ECF6",
+ "gridcolor": "white",
+ "gridwidth": 2,
+ "linecolor": "white",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "white"
+ },
+ "yaxis": {
+ "backgroundcolor": "#E5ECF6",
+ "gridcolor": "white",
+ "gridwidth": 2,
+ "linecolor": "white",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "white"
+ },
+ "zaxis": {
+ "backgroundcolor": "#E5ECF6",
+ "gridcolor": "white",
+ "gridwidth": 2,
+ "linecolor": "white",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "white"
+ }
+ },
+ "shapedefaults": {
+ "line": {
+ "color": "#2a3f5f"
+ }
+ },
+ "ternary": {
+ "aaxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ },
+ "baxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ },
+ "bgcolor": "#E5ECF6",
+ "caxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ }
+ },
+ "title": {
+ "x": 0.05
+ },
+ "xaxis": {
+ "automargin": true,
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": "",
+ "title": {
+ "standoff": 15
+ },
+ "zerolinecolor": "white",
+ "zerolinewidth": 2
+ },
+ "yaxis": {
+ "automargin": true,
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": "",
+ "title": {
+ "standoff": 15
+ },
+ "zerolinecolor": "white",
+ "zerolinewidth": 2
+ }
+ }
+ },
+ "title": {
+ "text": "Number of Vehicle Types for BMW",
+ "x": 0.5
+ },
+ "xaxis": {
+ "showgrid": false,
+ "title": {
+ "text": "Make"
+ }
+ },
+ "yaxis": {
+ "showgrid": false,
+ "title": {
+ "text": "Number of Vehicles"
+ }
+ }
+ }
+ }
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "make = 'bmw'\n",
+ "colors = {\n",
+ " 'background': '#003f5c',\n",
+ " 'text': 'white'\n",
+ "}\n",
+ "\n",
+ "df_filtered = df[df['make_']==make]\n",
+ "\n",
+ "fig = go.Figure(data=[\n",
+ " go.Bar(name='Electric', x=df_filtered['make_'], y=df_filtered['electric'], marker_color='rgb(26, 118, 255)'),\n",
+ " go.Bar(name='Fuel-only', x=df_filtered['make_'], y=df_filtered['fuel-only'], marker_color='rgb(55, 83, 109)'),\n",
+ " go.Bar(name='Hybrid', x=df_filtered['make_'], y=df_filtered['hybrid'], marker_color='rgb(26, 188, 156)')\n",
+ " ])\n",
+ "\n",
+ "# Change the bar mode\n",
+ "fig.update_layout(\n",
+ " barmode='stack',\n",
+ " title=f'Number of Vehicle Types for {make.upper()}',\n",
+ " title_x=0.5,\n",
+ " xaxis=dict(title='Make'),\n",
+ " yaxis=dict(title='Number of Vehicles'),\n",
+ " plot_bgcolor=colors['background'],\n",
+ " paper_bgcolor=colors['background'],\n",
+ " font_color=colors['text'],\n",
+ " xaxis_showgrid=False,\n",
+ " yaxis_showgrid=False\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 98,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.plotly.v1+json": {
+ "config": {
+ "plotlyServerURL": "https://plot.ly"
+ },
+ "data": [
+ {
+ "alignmentgroup": "True",
+ "hovertemplate": "make_=%{x}
weighted_avg_predicted_co2_rating_by_make=%{text}",
+ "legendgroup": "rivian",
+ "marker": {
+ "color": "rgb(251,180,174)",
+ "pattern": {
+ "shape": ""
+ }
+ },
+ "name": "rivian",
+ "offsetgroup": "rivian",
+ "orientation": "v",
+ "showlegend": true,
+ "text": [
+ 10
+ ],
+ "textposition": "auto",
+ "type": "bar",
+ "x": [
+ "rivian"
+ ],
+ "xaxis": "x",
+ "y": [
+ 10
+ ],
+ "yaxis": "y"
+ },
+ {
+ "alignmentgroup": "True",
+ "hovertemplate": "make_=%{x}
weighted_avg_predicted_co2_rating_by_make=%{text}",
+ "legendgroup": "smart eq",
+ "marker": {
+ "color": "rgb(179,205,227)",
+ "pattern": {
+ "shape": ""
+ }
+ },
+ "name": "smart eq",
+ "offsetgroup": "smart eq",
+ "orientation": "v",
+ "showlegend": true,
+ "text": [
+ 10
+ ],
+ "textposition": "auto",
+ "type": "bar",
+ "x": [
+ "smart eq"
+ ],
+ "xaxis": "x",
+ "y": [
+ 10
+ ],
+ "yaxis": "y"
+ },
+ {
+ "alignmentgroup": "True",
+ "hovertemplate": "make_=%{x}
weighted_avg_predicted_co2_rating_by_make=%{text}",
+ "legendgroup": "lucid",
+ "marker": {
+ "color": "rgb(204,235,197)",
+ "pattern": {
+ "shape": ""
+ }
+ },
+ "name": "lucid",
+ "offsetgroup": "lucid",
+ "orientation": "v",
+ "showlegend": true,
+ "text": [
+ 10
+ ],
+ "textposition": "auto",
+ "type": "bar",
+ "x": [
+ "lucid"
+ ],
+ "xaxis": "x",
+ "y": [
+ 10
+ ],
+ "yaxis": "y"
+ },
+ {
+ "alignmentgroup": "True",
+ "hovertemplate": "make_=%{x}
weighted_avg_predicted_co2_rating_by_make=%{text}",
+ "legendgroup": "polestar",
+ "marker": {
+ "color": "rgb(222,203,228)",
+ "pattern": {
+ "shape": ""
+ }
+ },
+ "name": "polestar",
+ "offsetgroup": "polestar",
+ "orientation": "v",
+ "showlegend": true,
+ "text": [
+ 10
+ ],
+ "textposition": "auto",
+ "type": "bar",
+ "x": [
+ "polestar"
+ ],
+ "xaxis": "x",
+ "y": [
+ 10
+ ],
+ "yaxis": "y"
+ },
+ {
+ "alignmentgroup": "True",
+ "hovertemplate": "make_=%{x}
weighted_avg_predicted_co2_rating_by_make=%{text}",
+ "legendgroup": "karma",
+ "marker": {
+ "color": "rgb(254,217,166)",
+ "pattern": {
+ "shape": ""
+ }
+ },
+ "name": "karma",
+ "offsetgroup": "karma",
+ "orientation": "v",
+ "showlegend": true,
+ "text": [
+ 10
+ ],
+ "textposition": "auto",
+ "type": "bar",
+ "x": [
+ "karma"
+ ],
+ "xaxis": "x",
+ "y": [
+ 10
+ ],
+ "yaxis": "y"
+ },
+ {
+ "alignmentgroup": "True",
+ "hovertemplate": "make_=%{x}
weighted_avg_predicted_co2_rating_by_make=%{text}",
+ "legendgroup": "tesla",
+ "marker": {
+ "color": "rgb(255,255,204)",
+ "pattern": {
+ "shape": ""
+ }
+ },
+ "name": "tesla",
+ "offsetgroup": "tesla",
+ "orientation": "v",
+ "showlegend": true,
+ "text": [
+ 10
+ ],
+ "textposition": "auto",
+ "type": "bar",
+ "x": [
+ "tesla"
+ ],
+ "xaxis": "x",
+ "y": [
+ 10
+ ],
+ "yaxis": "y"
+ },
+ {
+ "alignmentgroup": "True",
+ "hovertemplate": "make_=%{x}
weighted_avg_predicted_co2_rating_by_make=%{text}",
+ "legendgroup": "smart",
+ "marker": {
+ "color": "rgb(229,216,189)",
+ "pattern": {
+ "shape": ""
+ }
+ },
+ "name": "smart",
+ "offsetgroup": "smart",
+ "orientation": "v",
+ "showlegend": true,
+ "text": [
+ 9.238095238095237
+ ],
+ "textposition": "auto",
+ "type": "bar",
+ "x": [
+ "smart"
+ ],
+ "xaxis": "x",
+ "y": [
+ 9.238095238095237
+ ],
+ "yaxis": "y"
+ },
+ {
+ "alignmentgroup": "True",
+ "hovertemplate": "make_=%{x}
weighted_avg_predicted_co2_rating_by_make=%{text}",
+ "legendgroup": "fiat",
+ "marker": {
+ "color": "rgb(253,218,236)",
+ "pattern": {
+ "shape": ""
+ }
+ },
+ "name": "fiat",
+ "offsetgroup": "fiat",
+ "orientation": "v",
+ "showlegend": true,
+ "text": [
+ 6.627906976744186
+ ],
+ "textposition": "auto",
+ "type": "bar",
+ "x": [
+ "fiat"
+ ],
+ "xaxis": "x",
+ "y": [
+ 6.627906976744186
+ ],
+ "yaxis": "y"
+ },
+ {
+ "alignmentgroup": "True",
+ "hovertemplate": "make_=%{x}
weighted_avg_predicted_co2_rating_by_make=%{text}",
+ "legendgroup": "honda",
+ "marker": {
+ "color": "rgb(242,242,242)",
+ "pattern": {
+ "shape": ""
+ }
+ },
+ "name": "honda",
+ "offsetgroup": "honda",
+ "orientation": "v",
+ "showlegend": true,
+ "text": [
+ 6.560830860534125
+ ],
+ "textposition": "auto",
+ "type": "bar",
+ "x": [
+ "honda"
+ ],
+ "xaxis": "x",
+ "y": [
+ 6.560830860534125
+ ],
+ "yaxis": "y"
+ },
+ {
+ "alignmentgroup": "True",
+ "hovertemplate": "make_=%{x}
weighted_avg_predicted_co2_rating_by_make=%{text}",
+ "legendgroup": "mini",
+ "marker": {
+ "color": "rgb(251,180,174)",
+ "pattern": {
+ "shape": ""
+ }
+ },
+ "name": "mini",
+ "offsetgroup": "mini",
+ "orientation": "v",
+ "showlegend": true,
+ "text": [
+ 6.451428571428571
+ ],
+ "textposition": "auto",
+ "type": "bar",
+ "x": [
+ "mini"
+ ],
+ "xaxis": "x",
+ "y": [
+ 6.451428571428571
+ ],
+ "yaxis": "y"
+ }
+ ],
+ "layout": {
+ "barmode": "relative",
+ "legend": {
+ "title": {
+ "text": "make_"
+ },
+ "tracegroupgap": 0
+ },
+ "template": {
+ "data": {
+ "bar": [
+ {
+ "error_x": {
+ "color": "#2a3f5f"
+ },
+ "error_y": {
+ "color": "#2a3f5f"
+ },
+ "marker": {
+ "line": {
+ "color": "#E5ECF6",
+ "width": 0.5
+ },
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "bar"
+ }
+ ],
+ "barpolar": [
+ {
+ "marker": {
+ "line": {
+ "color": "#E5ECF6",
+ "width": 0.5
+ },
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "barpolar"
+ }
+ ],
+ "carpet": [
+ {
+ "aaxis": {
+ "endlinecolor": "#2a3f5f",
+ "gridcolor": "white",
+ "linecolor": "white",
+ "minorgridcolor": "white",
+ "startlinecolor": "#2a3f5f"
+ },
+ "baxis": {
+ "endlinecolor": "#2a3f5f",
+ "gridcolor": "white",
+ "linecolor": "white",
+ "minorgridcolor": "white",
+ "startlinecolor": "#2a3f5f"
+ },
+ "type": "carpet"
+ }
+ ],
+ "choropleth": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "type": "choropleth"
+ }
+ ],
+ "contour": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "contour"
+ }
+ ],
+ "contourcarpet": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "type": "contourcarpet"
+ }
+ ],
+ "heatmap": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "heatmap"
+ }
+ ],
+ "heatmapgl": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "heatmapgl"
+ }
+ ],
+ "histogram": [
+ {
+ "marker": {
+ "pattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ }
+ },
+ "type": "histogram"
+ }
+ ],
+ "histogram2d": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "histogram2d"
+ }
+ ],
+ "histogram2dcontour": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "histogram2dcontour"
+ }
+ ],
+ "mesh3d": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "type": "mesh3d"
+ }
+ ],
+ "parcoords": [
+ {
+ "line": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "parcoords"
+ }
+ ],
+ "pie": [
+ {
+ "automargin": true,
+ "type": "pie"
+ }
+ ],
+ "scatter": [
+ {
+ "fillpattern": {
+ "fillmode": "overlay",
+ "size": 10,
+ "solidity": 0.2
+ },
+ "type": "scatter"
+ }
+ ],
+ "scatter3d": [
+ {
+ "line": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scatter3d"
+ }
+ ],
+ "scattercarpet": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scattercarpet"
+ }
+ ],
+ "scattergeo": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scattergeo"
+ }
+ ],
+ "scattergl": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scattergl"
+ }
+ ],
+ "scattermapbox": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scattermapbox"
+ }
+ ],
+ "scatterpolar": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scatterpolar"
+ }
+ ],
+ "scatterpolargl": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scatterpolargl"
+ }
+ ],
+ "scatterternary": [
+ {
+ "marker": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "type": "scatterternary"
+ }
+ ],
+ "surface": [
+ {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ },
+ "colorscale": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "type": "surface"
+ }
+ ],
+ "table": [
+ {
+ "cells": {
+ "fill": {
+ "color": "#EBF0F8"
+ },
+ "line": {
+ "color": "white"
+ }
+ },
+ "header": {
+ "fill": {
+ "color": "#C8D4E3"
+ },
+ "line": {
+ "color": "white"
+ }
+ },
+ "type": "table"
+ }
+ ]
+ },
+ "layout": {
+ "annotationdefaults": {
+ "arrowcolor": "#2a3f5f",
+ "arrowhead": 0,
+ "arrowwidth": 1
+ },
+ "autotypenumbers": "strict",
+ "coloraxis": {
+ "colorbar": {
+ "outlinewidth": 0,
+ "ticks": ""
+ }
+ },
+ "colorscale": {
+ "diverging": [
+ [
+ 0,
+ "#8e0152"
+ ],
+ [
+ 0.1,
+ "#c51b7d"
+ ],
+ [
+ 0.2,
+ "#de77ae"
+ ],
+ [
+ 0.3,
+ "#f1b6da"
+ ],
+ [
+ 0.4,
+ "#fde0ef"
+ ],
+ [
+ 0.5,
+ "#f7f7f7"
+ ],
+ [
+ 0.6,
+ "#e6f5d0"
+ ],
+ [
+ 0.7,
+ "#b8e186"
+ ],
+ [
+ 0.8,
+ "#7fbc41"
+ ],
+ [
+ 0.9,
+ "#4d9221"
+ ],
+ [
+ 1,
+ "#276419"
+ ]
+ ],
+ "sequential": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ],
+ "sequentialminus": [
+ [
+ 0,
+ "#0d0887"
+ ],
+ [
+ 0.1111111111111111,
+ "#46039f"
+ ],
+ [
+ 0.2222222222222222,
+ "#7201a8"
+ ],
+ [
+ 0.3333333333333333,
+ "#9c179e"
+ ],
+ [
+ 0.4444444444444444,
+ "#bd3786"
+ ],
+ [
+ 0.5555555555555556,
+ "#d8576b"
+ ],
+ [
+ 0.6666666666666666,
+ "#ed7953"
+ ],
+ [
+ 0.7777777777777778,
+ "#fb9f3a"
+ ],
+ [
+ 0.8888888888888888,
+ "#fdca26"
+ ],
+ [
+ 1,
+ "#f0f921"
+ ]
+ ]
+ },
+ "colorway": [
+ "#636efa",
+ "#EF553B",
+ "#00cc96",
+ "#ab63fa",
+ "#FFA15A",
+ "#19d3f3",
+ "#FF6692",
+ "#B6E880",
+ "#FF97FF",
+ "#FECB52"
+ ],
+ "font": {
+ "color": "#2a3f5f"
+ },
+ "geo": {
+ "bgcolor": "white",
+ "lakecolor": "white",
+ "landcolor": "#E5ECF6",
+ "showlakes": true,
+ "showland": true,
+ "subunitcolor": "white"
+ },
+ "hoverlabel": {
+ "align": "left"
+ },
+ "hovermode": "closest",
+ "mapbox": {
+ "style": "light"
+ },
+ "paper_bgcolor": "white",
+ "plot_bgcolor": "#E5ECF6",
+ "polar": {
+ "angularaxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ },
+ "bgcolor": "#E5ECF6",
+ "radialaxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ }
+ },
+ "scene": {
+ "xaxis": {
+ "backgroundcolor": "#E5ECF6",
+ "gridcolor": "white",
+ "gridwidth": 2,
+ "linecolor": "white",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "white"
+ },
+ "yaxis": {
+ "backgroundcolor": "#E5ECF6",
+ "gridcolor": "white",
+ "gridwidth": 2,
+ "linecolor": "white",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "white"
+ },
+ "zaxis": {
+ "backgroundcolor": "#E5ECF6",
+ "gridcolor": "white",
+ "gridwidth": 2,
+ "linecolor": "white",
+ "showbackground": true,
+ "ticks": "",
+ "zerolinecolor": "white"
+ }
+ },
+ "shapedefaults": {
+ "line": {
+ "color": "#2a3f5f"
+ }
+ },
+ "ternary": {
+ "aaxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ },
+ "baxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ },
+ "bgcolor": "#E5ECF6",
+ "caxis": {
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": ""
+ }
+ },
+ "title": {
+ "x": 0.05
+ },
+ "xaxis": {
+ "automargin": true,
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": "",
+ "title": {
+ "standoff": 15
+ },
+ "zerolinecolor": "white",
+ "zerolinewidth": 2
+ },
+ "yaxis": {
+ "automargin": true,
+ "gridcolor": "white",
+ "linecolor": "white",
+ "ticks": "",
+ "title": {
+ "standoff": 15
+ },
+ "zerolinecolor": "white",
+ "zerolinewidth": 2
+ }
+ }
+ },
+ "title": {
+ "text": "Weighted Average Predicted CO2 Rating by Make"
+ },
+ "xaxis": {
+ "anchor": "y",
+ "categoryarray": [
+ "rivian",
+ "smart eq",
+ "lucid",
+ "polestar",
+ "karma",
+ "tesla",
+ "smart",
+ "fiat",
+ "honda",
+ "mini"
+ ],
+ "categoryorder": "array",
+ "domain": [
+ 0,
+ 1
+ ],
+ "title": {
+ "text": "make_"
+ }
+ },
+ "yaxis": {
+ "anchor": "x",
+ "domain": [
+ 0,
+ 1
+ ],
+ "title": {
+ "text": "weighted_avg_predicted_co2_rating_by_make"
+ }
+ }
+ }
+ }
+ },
"metadata": {},
- "output_type": "execute_result"
+ "output_type": "display_data"
}
],
"source": [
- "weighted_avg_df = pd.merge(total_models_df, make_total_avg_score, on='make_', how='left')\n",
- "\n",
- "# sort the dataframe by the weighted average\n",
- "weighted_avg_df.sort_values(by='weighted_avg_predicted_co2_rating_by_make', ascending=False, inplace=True)\n",
- "\n",
- "# Display the dataframe\n",
- "weighted_avg_df"
+ "px.bar(df, x='make_', y='weighted_avg_predicted_co2_rating_by_make', \n",
+ " color='make_', title='Weighted Average Predicted CO2 Rating by Make', \n",
+ " text='weighted_avg_predicted_co2_rating_by_make', color_discrete_sequence=px.colors.qualitative.Pastel1)"
]
},
{
diff --git a/src/visualization/dashboard.py b/src/visualization/dashboard.py
index fe99add..884ec3f 100644
--- a/src/visualization/dashboard.py
+++ b/src/visualization/dashboard.py
@@ -67,7 +67,7 @@ def display_top_vehicle_scores(dataframe, view='top'):
])
fig.update_layout(
- title=f"{title_str}
Score is taken by computing the average CO2 score of all models in a make, weighted by the total number of models the make has",
+ title=f"{title_str}Score is taken by computing the average CO2 score of all models in a make, weighted by the total number of models the make has",
font=dict(
color="white"
),