In Fares page, the pivoted fare rules API call errors out when it encounters fare_rules entries that don't have origin_id and destination_id values. (example: if a bus service charges a flat rate for all trips)
ERROR:tornado.application:Uncaught exception GET /API/fareRulesPivoted (::1)
HTTPServerRequest(protocol='http', host='localhost:5000', method='GET', uri='/API/fareRulesPivoted', version='HTTP/1.1', remote_ip='::1')
Traceback (most recent call last):
File "/mnt/STUFF/py36/lib/python3.6/site-packages/tornado/web.py", line 1590, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "GTFSManager.py", line 247, in get
columns='destination_id', values='fare_id')\
File "/mnt/STUFF/py36/lib/python3.6/site-packages/pandas/core/frame.py", line 5194, in pivot
return pivot(self, index=index, columns=columns, values=values)
File "/mnt/STUFF/py36/lib/python3.6/site-packages/pandas/core/reshape/reshape.py", line 415, in pivot
return indexed.unstack(columns)
File "/mnt/STUFF/py36/lib/python3.6/site-packages/pandas/core/series.py", line 2899, in unstack
return unstack(self, level, fill_value)
File "/mnt/STUFF/py36/lib/python3.6/site-packages/pandas/core/reshape/reshape.py", line 501, in unstack
constructor=obj._constructor_expanddim)
File "/mnt/STUFF/py36/lib/python3.6/site-packages/pandas/core/reshape/reshape.py", line 137, in __init__
self._make_selectors()
File "/mnt/STUFF/py36/lib/python3.6/site-packages/pandas/core/reshape/reshape.py", line 175, in _make_selectors
raise ValueError('Index contains duplicate entries, '
ValueError: Index contains duplicate entries, cannot reshape
ERROR:tornado.access:500 GET /API/fareRulesPivoted (::1) 257.19ms
Prior to running pivot function, filter out all table entries that don't have either origin_id or destination_id columns filled.
These entries will show up in the simple table view of fare rules
In case after filtering there are no entries left, then quit gracefully, and on frontend, inform user that there are no station pair model entries in fare_rules.
Also inform user in simple fare rules table page that to see any changes done on pivoted side, please save to DB and refresh page.
There are other fare_rules models besides station-pairs : https://code.google.com/archive/p/googletransitdatafeed/wikis/FareExamples.wiki
In Fares page, the pivoted fare rules API call errors out when it encounters fare_rules entries that don't have origin_id and destination_id values. (example: if a bus service charges a flat rate for all trips)