如何在熊猫中按列绘制?

时间:2020-05-11 13:51:51

标签: pandas matplotlib data-visualization seaborn

我按如下所示制作一个DataFrame

enter image description here

我想像这样将其绘制为计数图

enter image description here

色相应作为我数据框的列

1 个答案:

答案 0 :(得分:0)

不太清楚表格的格式,如果使用如下所示的pd.crosstab,则可以轻松地调用plot.bar()来提供所需的绘图:

import seaborn as sns
tab = pd.crosstab(np.random.choice(["very useful","somewhat useful","not useful"],1000),
                  np.random.choice(["test","kaggle"],1000))
tab.plot.barh()

enter image description here