I'm using version 0.18.0 of pandas and 1.5.1 of matplotlib.
When attempting to create a boxplot, I receive KeyError: 0L.
df = df[(df['colA'] > 1000) & (df['colA'] < 5000)]
plt.boxplot(df['ColA'])
when I do not perform a filter on the df
, the code runs and a boxplot is created without any issues.
When I use the filtered df
to plot a histogram, this works without any errors.
plt.hist(df['ColA'], range(1000,5000,500))
What is causing the error when trying to create the boxplot? Any help appreciated.
In case you missed it while Googling (like I almost did), the answer is in the comments on the question:
.values
: plt.boxplot(df['ColA'].values)
..values
or reseting the index will solve this.Kudos to @ayhan for this information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With