У меня есть датафрейм, а затем я вызываю метод pivot_table
и затем отображаю результат.
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame({'Date': ['2020-04-10', '2020-04-11', '2020-04-12', '2020-04-13','2020-04-10', '2020-04-11', '2020-04-12', '2020-04-13'],
'Station': ['Hogwarts', 'Hogwarts', 'Hogwarts', 'Hogwarts','Hogwarts', 'Hogwarts', 'Hogwarts', 'Hogwarts'],
'Direction': ['Southbound', 'Southbound', 'Southbound', 'Southbound','Northbound','Northbound','Northbound','Northbound'],
'Daily trains': [1,1,2,3,0,0,2,1]})
df['Date'] = pd.to_datetime(df['Date'],format="%Y-%m-%d")
df1 = df.pivot_table(index='Date', columns=['Station','Direction'],values=['Daily trains'])
fig, ax = plt.subplots(1)
df1.plot(ax=ax)
ax.figure.savefig('so.png',bbox_inches='tight')
Вот это результат:
Почему я получаю 'None'
в названии легенды?