I have fed some data into a TravelTime (https://github.com/traveltime-dev/traveltime-python-sdk) API which calculates the time it takes to drive between 2 locations. The result of this (called out) is a dictionary with that looks like this:
{'results': [{'search_id': 'arrival_one_to_many',
'locations': [{'id': 'KA8 0EU', 'properties': {'travel_time': 2646}},
{'id': 'KA21 5DT', 'properties': {'travel_time': 392}}],
'unreachable': []}]}
However, I need a table that would look a bit like this:
search_id | id | Travel Time |
---|---|---|
arrival_one_to_many | KA21 5DT | 2646 |
arrival_one_to_many | KA21 5DT | 392 |
I've tried converting this dictionary to a dataframe using
out_2 = pd.DataFrame.from_dict(out)
This shows as a dataframe with one column called results, so I tried use out_2['results'].str.split(',', expand=True)
to split this into multiple columns at the comma delimiters but got an error:
0 | |
---|---|
0 | NaN |
Is anyone able to help me to get this dictionary to a readable and useable dataframe/table?
Thanks