I have a dataframe which looks like this:
df = pd.DataFrame({'Pred': [10, 9.5, 9.8], 'Actual': [10.2, 9.9, 9.1], 'STD': [0.1, 0.2, 0.6]})
Pred Actual STD
0 10.0 10.2 0.1
1 9.5 9.9 0.2
2 9.8 9.1 0.6
I want to make a bar plot with error bars using STD only on the Pred column, and not on the Actual column. So far I have this:
df.plot.bar(yerr='STD', capsize=4)

but this adds the error bars on both Actual and Pred. Is there a straight forward way to tell Pandas to add the erorr bar to a single column?
You can do with
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
errors=df.STD.to_frame('Pred')
df[['Actual','Pred']].plot.bar(yerr=errors, ax=ax)

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