答案 0 :(得分:1)
尝试一下:
#Create input dataframe:
df = pd.DataFrame({'a.day_id':np.random.choice(pd.date_range('2020-07-10', periods=5, freq='D').strftime('%Y%m%d'),50),
'q_color':np.random.choice('red green yellow'.split(), 50) })
#Convert to datetime, reshape and plot:
df['Date'] = pd.to_datetime(df['a.day_id']).dt.date
df.groupby(['Date','q_color']).count()['a.day_id'].unstack().plot.bar(color=[*'gry'])
输出: