I have a following problem. My database returns a list:
[Order(id=22617, frm=datetime.datetime(2020, 6, 1, 8, 0), to=datetime.datetime(2020, 6, 1, 10, 0), loc=Location(lat=14.491272455461, lng=50.130463596998), address='Makedonska 619/11, Praha', duration=600), datetime.datetime(2020, 6, 1, 11, 38, 46), Order(id=22615, frm=datetime.datetime(2020, 6, 1, 8, 0), to=datetime.datetime(2020, 6, 1, 14, 0), loc=Location(lat=14.681866313487, lng=50.007439571346), address='Výhledová 256, Říčany', duration=600), datetime.datetime(2020, 6, 1, 10, 33, 33)]
Every output from the database is a type routes_data_loading.data_structures.Order and datetime.datetime. I would like to save it as a pandas dataframe.
Desired output for the first row is:
id;frm;to;lat;lng;address;duration;time
22617;2020-06-01 08:00;2020-06-01 10:00;14.491272455461;50.130463596998;Makedonska 619/11, Praha;600;2020-06-01 11:38:46
Semicolumn stands for a new column. Note that the last column time has to be created, because its name is not in the original list.
Can you help me how to convert this list into pandas df, please? I know how to convert simple list into df, but not this complicated one. Thanks a lot.
lst[0].__dict__return something.