Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit dabe669

Browse files
committed
Error handling for SEUdb file
1 parent 9ce1aaa commit dabe669

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

vehicle_fuels.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,38 @@
77
upstream = None
88
product = {"nb": "output/pdo.ipynb", "data": "output/pdo.csv"}
99
# -
10-
##Vehicle
11-
vf_litres = [input("Enter the value of petrol, diesel and gasoil in litres")]
12-
vf_data = { 'TFC':[], 'TPER':[], 'CO2':[], 'Euro':[]}
10+
#Vehicle fuels
11+
12+
#User input for the fuels values in litres
13+
petrol_litres = int(input("Enter the value of petrol in litres"))
14+
diesel_litres = int(input("Enter the value of diesel in litres"))
15+
gasoil_litres = int(input("Enter the value of gasoil in litres"))
16+
17+
vf_litres = [petrol_litres, diesel_litres, gasoil_litres]
18+
column_names = ['fuels', 'litres']
1319
vehicles_fuels = ['Petrol', 'Diesel', 'Gasoil']
1420

15-
vehicles_df = pd.DataFrame(data = column_names, index= vehicles_fuels)
21+
list_tuples = list(zip(vehicles_fuels, vf_litres))
1622

17-
vehicles_df
23+
#Conversion Factors [petrol, diesel, gasoil]
24+
###multiplied per litre
25+
tfc_convf = [9.348, 10.130, 10.130]
26+
euro_convf = [1.24, 1.05, 0.56]
1827

19-
heating_fuels = ['kerosene', 'lpg']
28+
###multiplied per tfc
29+
tper_convf = [1.1, 1.1, 1.1]
30+
co2_convf = [0.252, 0.264, 0.264]
2031

21-
column_names = ['litres', 'TFC', 'TPER', 'CO2', 'Euro']
32+
##build dataframe
33+
vehicles_df = pd.DataFrame(list_tuples, columns= column_names)
34+
#vehicles_df['TFC_Conversion_factor'] = tfc_convf
35+
vehicles_df['TFC(kwh)'] = vehicles_df['litres'] * tfc_convf
36+
#vehicles_df['TPER_Conversion_factor'] = tper_convf
37+
vehicles_df['TPER(kwh)'] = vehicles_df['TFC(kwh)'] * tper_convf
38+
#vehicles_df['CO2_Conversion_factor'] = co2_convf
39+
vehicles_df['CO2(kg)'] = vehicles_df['TFC(kwh)'] * co2_convf
40+
#vehicles_df['Euro_Conversion_factor'] = euro_convf
41+
vehicles_df['Euros'] = vehicles_df['litres'] * euro_convf
2242

23-
heating_df = pd.DataFrame()
2443

44+
vehicles_df.append(vehicles_df.sum(numeric_only=True).rename('Total'))

0 commit comments

Comments
 (0)