1

I need the index column name and the value column name to be on the same level:

index name | values column name

DataFrame:
dataframe

My code:

df = pd.DataFrame.from_dict(aqi_val_dct, orient='index', columns=['Индекс качества воздуха (AQI)'])
df.index.name = 'Станция'
print(df)
imxitiz
  • 3,920
  • 3
  • 9
  • 33
Kirysha
  • 25
  • 6
  • 1
    That's now how it works in pandas.... It's differentiated that way you can always distinguish between a name on the row index, a name on the column index, and column labels: https://stackoverflow.com/a/55028542/4333359 – ALollz Jun 02 '22 at 15:40
  • @ALollz, thank you! df.columns.name = 'Станция' - that helped! – Kirysha Jun 02 '22 at 15:43
  • 1
    Yes that would be one way to get it where you want, though if it's truly a label for the index values, and not columns, naming the columns could become misleading. – ALollz Jun 02 '22 at 15:45
  • Because your question is related to formatting and style: What environment and what output are you using, where do you need this style? Is it HTML and for jupyterlab? – creanion Jun 04 '22 at 15:53

0 Answers0