Ich habe einen Datenrahmen:Alias für die Spalte in Pandas
df = pd.DataFrame({"by_week": list_1, "by_month": list_2})
Jetzt brauche ich eine HTML-Tabelle erhalten html = df.to_html()
wo Spalten erzeugt werden, wie:
<tr>
<th></th>
<th>by_month</th>
<th>by_week</th>
</tr>
Aber ich bin für menschlichere suchen lesbares Kopfspalte wie:
<tr>
<th></th>
<th>Last 7 days</th>
<th>Last 30 days</th>
</tr>
ich habe zwei Optionen für die Lösung es: Option 1
html = html.replace("by_week", "Last 7 days").replace("by_month", "Last 30 days")
Aber Code ist etwas chaotisch
Option 2
df = pd.DataFrame({"Last 7 days": list_1, "Last 30 days": list_2})
aber es ist schwer zu schreiben/Zugriff auf eine bestimmte Spalte jedes Mal.
also ... Existiert ein Alias für Spalten?