Improve serializing
This commit is contained in:
parent
5182cdeb84
commit
c735ec0ce3
|
@ -1,6 +1,8 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
import os
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from latecomers.parse import find_table, get_details
|
||||
from latecomers.serializer import to_excel
|
||||
|
||||
|
@ -14,3 +16,7 @@ for f in flights:
|
|||
data.append(get_details(f, os.environ.get("DEBUG") is not None))
|
||||
|
||||
print(to_excel(data))
|
||||
|
||||
colonne = {"th_arrival": "Arrivo teorico", "real_arrival": "Arrivo reale",
|
||||
"code": "Codice volo", "origin": "Aeroporto di partenza", "status": "Stato"}
|
||||
df = pd.DataFrame(data, columns=colonne)
|
||||
|
|
|
@ -27,6 +27,8 @@ def to_excel(data: T.List[Details]) -> bytes:
|
|||
"status": "Stato",
|
||||
}
|
||||
df = pd.DataFrame(data, columns=mapping)
|
||||
df["status"] = df["status"].map(lambda x: x.value)
|
||||
df.set_index("th_arrival", inplace=True)
|
||||
|
||||
with NamedTemporaryFile() as tmp:
|
||||
df.to_excel(tmp)
|
||||
|
|
Loading…
Reference in New Issue
Block a user