I have a DataFrame which is structurally similar to the following:
from datetime import datetime
import pandas as pd
from mpu.datetime import generate # pip install mpu
mind, maxd = datetime(2018, 1, 1), datetime(2018, 12, 30)
df = pd.DataFrame({'datetime': [generate(mind, maxd) for _ in range(10)]})
I want to understand how this data is distributed over hours of the day and days of the week. I can get them via:
df['weekday'] = df['datetime'].dt.weekday
df['hour'] = df['datetime'].dt.hour
And finally I have the plot:
ax = df.groupby(['weekday', 'hour'])['datetime'].count().plot(kind='line', color='blue')
ax.set_ylabel("#")
ax.set_xlabel("time")
plt.show()
which gives me:
But you can notice that it is hard to distinguish the weekdays and the hours are not even noticeable. How can I get two-level labels similar to the following?