Where is the error in the following code?
First of all, since you only seem to want to know about the Python error, your question is probably better suited for Stack Overflow.

Secondly, this is not fun to answer with the information you've provided.  This is certainly not a minimal working example (MWE) - I can't copy your code as is, and run it myself.  I'm left to guess many things:


Are you importing matplotlib?
Did you rename matplotlib.pyplot as plt?
Are you importing numpy and did you rename it np?
Does your traceback literally end in KeyError is 0 or is it KeyError: 0 or KeyError: False?  Can you show the full traceback?  The traceback for a MWE is typically not long.


In the positional argument (movieDF[movieDF['%s'%genre]==1].year) on your problematic line, you ask for a key (movieDF['%s'%genre]==1) that looks like it should evaluate to a Boolean.  Is this never 0?  I'm forced to grasp at straws because you haven't provided a sample dataset; I shouldn't have to download from IMDb myself.

Edit:

Just to troubleshoot, can you place x = movieDF[movieDF['%s'%genre]==1].year on a line by itself and tell me what x[0] is?  What type would that x be?  Is it a dictionary, where the .hist() method is expecting a list or other array?  This documentation makes it sound like the method will not accept a dictionary...what type is movieDF.year?