Maybe try to use the .values
attribute (this returns the data as a numpy array), so:
hist(df[df.TYPE=='SU4'].GVW.values, bins=50, range=(0,200))
I assume the reason this does not work is because the matplotlib hist
method tries to access the first 0
-index element of the input. But because the Series uses its integer index as label and not location, this gives a key error for a sliced Series (as the first element will not have index 0
anymore)
And indeed, as @AndyHayden says, you can also use the pandas hist
method:
df[df.TYPE=='SU4'].GVW.hist(bins=50)