Reputation: 359
I was following this tutorial https://www.kaggle.com/residentmario/univariate-plotting-with-pandas and trying to do the exercise mentioned with the pokemon database but whenever I try to implement the code below I get the error mentioned below and don't understand what to do. I am using matplotlib.use('agg') because I was getting an error related to Tkinter. I am using pycharm, python 3.6 and I am on ubuntu 18.04
Here is my code:
import pandas as pd
import matplotlib
matplotlib.use('agg')
from matplotlib.pyplot import plot
df=pd.read_csv("/home/mv/PycharmProjects/visualization/pokemon.csv")
df['type1'].value_counts.plot(kind='bar')
error
Traceback (most recent call last):
File "/home/mv/PycharmProjects/visualization/univariate plotting.py",
line 9, in <module>
df['type1'].value_counts.plot(kind='bar')
AttributeError: 'function' object has no attribute 'plot'
Upvotes: 6
Views: 13219
Reputation: 5783
The error states that df['type1'].value_counts
is a function.
To plot the result of the function change:
df['type1'].value_counts.plot(kind='bar')
into
df['type1'].value_counts().plot(kind='bar')
Upvotes: 6