[英]How to plot a grouped bar chart from a dataframe with several columns in x?
This is my first time trying to plot some data in Python. I have a dataframe like this one:这是我第一次尝试 plot Python 中的一些数据。我有一个像这样的 dataframe:
city![]() |
zone![]() |
category![]() |
searches_ok![]() |
searches_null ![]() |
---|---|---|---|---|
Buenos Aires![]() |
Zone1 ![]() |
Books![]() |
12 ![]() |
6 ![]() |
Buenos Aires![]() |
Zone1 ![]() |
Home![]() |
7 ![]() |
0 ![]() |
Buenos Aires![]() |
Zone2 ![]() |
Books![]() |
5 ![]() |
7 ![]() |
Rosario![]() |
Zone7 ![]() |
Home![]() |
25 ![]() |
1 ![]() |
Rio de Janeiro![]() |
Zone8 ![]() |
Tech![]() |
55 ![]() |
3 ![]() |
Rio de Janeiro![]() |
Zone9 ![]() |
Books![]() |
12 ![]() |
7 ![]() |
Sao Paulo![]() |
Zone15 ![]() |
Tech![]() |
34 ![]() |
8 ![]() |
How would go about plotting this in a grouped bar chart? go 如何将其绘制在分组条形图中? I would like for there to be 2 bars (searches_ok and searches_null) for each "combination" of city/zone/category.
我希望城市/区域/类别的每个“组合”都有 2 个条形图(searches_ok 和 searches_null)。
Using this:使用这个:
df_arg.set_index("zone")
df.plot(x="zone", y=["searches_ok","searches_null"]
I was able to plot a graph with both columns, but only for the "Zone" column... How would you go about doing that for each combination of city/zone/category?我能够 plot 绘制包含两列的图表,但仅限于“区域”列...您 go 如何针对城市/区域/类别的每个组合执行此操作?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.