1

I am trying to create a grouped bar plot based on a pandas dataframe (named df). Can someone explain how to reference each column so I can do something similar to this SO post?

In R I would have done something like:

ggplot(df, aes(factor(live1), bbhome1)) + 
  geom_bar(stat="identity", position = "dodge") 

Heres my python 3.6 code:

In [19]: df.groupby(['live1'])['bbhome1'].value_counts()

Out[19]:
live1  bbhome1
1      2          479
       3           104
       1           27
2      2          606
       3            53
       1           10
Rilcon42
  • 9,584
  • 18
  • 83
  • 167
  • Could you provide a [reproducible example](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) for testing? – fuglede Dec 12 '17 at 20:48
  • I'd be happy to, but Im an R user making his first foray into Python and Im not quite sure how to export data structures. Any suggestions? – Rilcon42 Dec 12 '17 at 20:51
  • 1
    did you try `.plot(kind='bar')` – DJK Dec 13 '17 at 00:03
  • 1
    adding to the comment by [djk47463](https://stackoverflow.com/users/5514476/djk47463) -- if you're using a jupyter notebook then use the magic ````%matplotlib inline```` command to actually see plotted output – Ido S Dec 13 '17 at 00:45

0 Answers0