【问题标题】:How to barplot using seaborn? [closed]如何使用 seaborn 绘制条形图? [关闭]
【发布时间】:2021-02-06 06:34:10
【问题描述】:

我有一个数据框。

Store ID  Carwash
1            0
1            0
1            0
1            0
2            1
2            1
3            1
3            1
4            0
4            0

我想根据商店 ID 绘制洗车场。

【问题讨论】:

    标签: python matplotlib seaborn


    【解决方案1】:

    您可以在 pandas 中使用 groupbybarplot

    df2 = df.groupby(['Store ID']).count()
    car_wash = df.groupby(['Store ID']).apply(lambda x: x['Carwash'].unique())
    car_wash = [list(i) for i in car_wash]
    ax = df2.plot(kind='bar')
    for p in ax.patches:
        ax.annotate(str(car_wash.pop(0)), (p.get_x()*1.005, p.get_height()*1.005))
    

    【讨论】:

    • 有没有办法绘制值,即 1 或 0 而不是绘制频率?
    • 对不起,你能详细说明一下吗
    • 我想绘制 carwash 的值,即商店 ID 的 1 或 0。
    • 这就是你要找的吗?
    猜你喜欢
    • 2021-07-28
    • 2019-05-29
    • 2019-07-29
    • 2021-06-18
    • 1970-01-01
    • 2021-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多