Python Forum
Fix: Series' object is not callable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fix: Series' object is not callable
#1
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?
Reply
#2
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.
Reply
#3
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?
Reply
#4
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)]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  error in class: TypeError: 'str' object is not callable akbarza 2 497 Dec-30-2023, 04:35 PM
Last Post: deanhystad
  TypeError: 'NoneType' object is not callable akbarza 4 982 Aug-24-2023, 05:14 PM
Last Post: snippsat
  [NEW CODER] TypeError: Object is not callable iwantyoursec 5 1,334 Aug-23-2023, 06:21 PM
Last Post: deanhystad
  Need help with 'str' object is not callable error. Fare 4 822 Jul-23-2023, 02:25 PM
Last Post: Fare
  TypeError: 'float' object is not callable #1 isdito2001 1 1,074 Jan-21-2023, 12:43 AM
Last Post: Yoriz
  'SSHClient' object is not callable 3lnyn0 1 1,166 Dec-15-2022, 03:40 AM
Last Post: deanhystad
  TypeError: 'float' object is not callable TimofeyKolpakov 3 1,434 Dec-04-2022, 04:58 PM
Last Post: TimofeyKolpakov
  API Post issue "TypeError: 'str' object is not callable" makeeley 2 1,895 Oct-30-2022, 12:53 PM
Last Post: makeeley
  Merge htm files with shutil library (TypeError: 'module' object is not callable) Melcu54 5 1,574 Aug-28-2022, 07:11 AM
Last Post: Melcu54
  [split] TypeError: 'int' object is not callable flash77 4 2,748 Mar-21-2022, 09:44 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020