Python Forum
Fix: Series' object is not callable - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Fix: Series' object is not callable (/thread-11120.html)



Fix: Series' object is not callable - Jack_Sparrow - Jun-23-2018

Hello there
this is my data set

Vote_count vote_average
2000 4,5
500 5
3500 4
3000 3,5
2700 4,5
1500 3,5

I want to count how many people (vote_count) gave which rating in one bar chart (x axis: rating_vote and y axis: vote_count)

this is my code
df_star_trek['vote_average']('vote_count').sum().plot(kind='bar');
I get this error message
TypeError                                 Traceback (most recent call last)
<ipython-input-102-d361146a8034> in <module>()
      1 #what is the vote avarage for Star Wars and Star Treck?
----> 2 df_star_trek['vote_average']('vote_count').sum().plot(kind='bar');

TypeError: 'Series' object is not callable
Why? How can I fix it?


RE: Fix: Series' object is not callable - gontajones - Jun-23-2018

Could you provide how df_star_trek was instantiated?
And you use ('vote_count') with a key of this df_star_trek, the () is for callable instances.
Maybe if you change to ['vote_count'] your code will run ok.


RE: Fix: Series' object is not callable - Jack_Sparrow - Jun-23-2018

I just filtered my data set to the Film "Star Trek"
df_star_trek = df[df['original_title'].str.contains("Star Trek", na=False)]
I changed the brackets from () to []
Now I have this mistake

NameError: name 'df_star_trek' is not defined
In my opinion, it is defined, isn't it?


RE: Fix: Series' object is not callable - gontajones - Jun-23-2018

Quote:In my opinion, it is defined, isn't it?

I don't think so. For some reason this part of your code is not been executed.
df_star_trek = df[df['original_title'].str.contains("Star Trek", na=False)]