mirror of
https://github.com/flobz/psa_car_controller.git
synced 2026-08-22 17:36:15 +00:00
fix ZeroDivisionError
This commit is contained in:
+4
-1
@@ -101,7 +101,10 @@ def get_figures(trips: List[Trip], charging: List[dict]):
|
||||
|
||||
# charging
|
||||
charging_data = DataFrame.from_records(charging)
|
||||
co2_per_kw = charging_data["co2"].sum() / charging_data["kw"].sum()
|
||||
try:
|
||||
co2_per_kw = charging_data["co2"].sum() / charging_data["kw"].sum()
|
||||
except ZeroDivisionError:
|
||||
co2_per_kw = 0
|
||||
co2_per_km = co2_per_kw * kw_per_km / 100
|
||||
charge_speed = 3600 * charging_data["kw"].mean() / \
|
||||
(charging_data["stop_at"] - charging_data["start_at"]).mean().total_seconds()
|
||||
|
||||
Reference in New Issue
Block a user