Plotting confidence intervals
For the following dataframe, I am trying to plot the means of a sample of 5 random rows . And also plot their respective confidence intervals using errorbars. I am unable to figure how to plot the confidence intervals using errorbars.
col0 col1 col2 col3 col4 col5 col6 col7
0 0 1 2 3 4 5 6 7
1 8 9 10 11 12 13 14 15
2 16 17 18 19 20 21 22 23
3 24 25 26 27 28 29 30 31
4 32 33 34 35 36 37 38 39
5 40 41 42 43 44 45 46 47
6 48 49 50 51 52 53 54 55
7 56 57 58 59 60 61 62 63
Here is my code:
confidenceInterval_percent = 0.95
sample_size=5
mean_list=[]
df = pd.DataFrame(np.arange(64).reshape(8,8)).add_prefix('col')
sample_df= df.sample(n=sample_size, random_state=10)
for i in df.columns:
mean = df[i].mean()
mean_list.append(mean)
stdError = df[i].std() / np.sqrt(sample_size)
confidence_intervals = sp.stats.norm.interval(
confidenceInterval_percent, loc = mean,
scale = stdError)
temporary_Df=pd.DataFrame(mean_list)
temporary_Df.plot.bar()
plt.show()
Topic confidence python statistics
Category Data Science