I have a pandas data frame which is a pandas data frame type as shown below
type(df)
Out[176]:
pandas.core.frame.DataFrame
But when I try to use any plotting functions on this data frame like bar graph it gives an error as follows;
df.plot.bar()
AttributeError: 'function' object has no attribute 'bar'
Not other function like box plot or hist is also not working. Any idea why?
If you have specific columns in mind that you want to plot, you can try:
df.plot(x='x', y='y', kind='bar')
Interesting, for me it works very well:
df = pd.DataFrame({'ab': {0: 31196, 1: 18804}})
print df
ab
0 31196
1 18804
#New in version 0.17.0.
df.plot.bar()
Another option:
df.plot(kind='bar')

EDIT (by discussion in chat):
I think you need boxplot:
#filter columns
df = df.drop(['city','last_trip_date','phone','signup_date','user_red'], axis=1)
print df
Retained avg_dist avg_increase avg_price avg_value pct \
0 1 3.67 1.1 5.0 4.7 15.4
1 0 8.26 1.0 5.0 5.0 0.0
2 0 0.77 1.0 5.0 4.3 0.0
trips_in_first_30_days weekday_pct
0 4.0 46.2
1 0.0 50.0
2 3.0 100.0
df.boxplot(by='Retained', layout=(7,1), figsize=(5,15))

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With