diff options
| author | Alex Schofield <git@ajschof.me> | 2026-04-27 09:37:15 +0100 |
|---|---|---|
| committer | Alex Schofield <git@ajschof.me> | 2026-04-27 09:37:15 +0100 |
| commit | 79e8f8e76fd18a45a7f513b952261cc7d1a4fee9 (patch) | |
| tree | c490d19262a8decd11415ada4838fcbcf7f5f1d9 /main.py | |
| parent | d787c2d720c1cd732ca7efcece93588504eab3a6 (diff) | |
| download | fuelnearme-79e8f8e76fd18a45a7f513b952261cc7d1a4fee9.tar.gz fuelnearme-79e8f8e76fd18a45a7f513b952261cc7d1a4fee9.zip | |
improve sort function to handle N/A fuel prices
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -67,13 +67,16 @@ def filter_df(dframe, arguments, loc): "e10_price": round(e10_price / 100, 2), "diesel_price": round(diesel_price / 100, 2), } - near_stations.append(station_dict) + na_dict = { + k: (v if v != 0.00 else "N/A") for (k, v) in station_dict.items() + } + near_stations.append(na_dict) return near_stations def sort_stations(stations: list[dict], sort: str) -> list[dict]: sort_key = SORT_KV.get(sort) - return sorted(stations, key=lambda d: d[sort_key]) + return sorted(stations, key=lambda d: d[sort_key] if d[sort_key] != "N/A" else 999) def output_stations(stations): |
