Jul-22-2018, 11:53 AM
(This post was last modified: Jul-22-2018, 11:55 AM by tryingtolearnpython.)
def most_murderous(year): # Assign most to a table of the most murderous states this year in ascending order. data_for_year = murder_rates('Year', are.equal_to(year)) sorted_data = data_for_year.sort('Murder Rate', descending=True) top_5 = sorted_data.take(np.arange(0,5)) top_5.barh('State', 'Murder Rate') return top_5.column('State') most_murderous(1990) # California, Mississippi, ...,I get an error saying
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-46-7e6222b8c39b> in <module>() 7 return top_5.column('State') 8 ----> 9 most_murderous(1990) # California, Mississippi, ..., <ipython-input-46-7e6222b8c39b> in most_murderous(x) 1 def most_murderous(x): 2 # Assign most to a table of the most murderous states this year in ascending order. ----> 3 data_for_year = murder_rates('Year', are.equal_to(x)) 4 sorted_data = data_for_year.sort('Murder Rate', descending=True) 5 top_5 = sorted_data.take(np.arange(0,5)) TypeError: 'Table' object is not callableWhat is wrong here?
It seems:
data_for_year = murder_rates('Year', are.equal_to(year))
is wrong but I can't figure out what is wrong with it.
nevermind. I see that I'm missing a .where