6

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'

1 Answer 1

6

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')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.