Understanding Seaborn Barplot - Error Bars meaning & calculation I am using Seaborn to create a barplot.
sns.barplot(df['City Group'], df['revenue']) #uses default mean estimator


I am a bit confused about the error bars. What is the statistics to calculate these error bars and what these error bars actually represent? As per documentation, these error bars define the confidence interval and uncertainty around the estimate.
In simple words, does it mean there is a 95% (default ci=95) chance that the mean will be falling in this range?
Can you explain in detail?
Also, when I change the value of ci='sd' (keeping the same estimator) as:`
sns.barplot(df['City Group'], df['revenue'], ci='sd')


The range of error bar increases for standard deviation. How this is calculated and what does it reflect?
Sample Data: (original source: Restaurant Revenue Prediction)

 A: By specifying ci='sd', you are indicating at what range you could be 95% sure that a sample of the population data contains the population standard deviation. From graphpad:
Interpreting the CI of the SD is straightforward. If you assume that your data were randomly and independently sampled from a Gaussian distribution, you can be 95% sure that the CI  contains the true population SD.
Also, with only 137 rows of data, you are going to have a wider range for the confidence interval of your standard deviation than if you had let's say 1,000 + rows; because, generally, with a lower size n -- the higher the variance of the data.
Seaborn uses a technique to make inferences about population statistics using "Bootstrapping" per the documentation:
This is a basic concept of bootstrapping.
"The basic idea of bootstrapping is that inference about a population from sample data (sample → population) can be modelled by resampling the sample data and performing inference about a sample from resampled data (resampled → sample). As the population is unknown, the true error in a sample statistic against its population value is unknown."
I hope this helps. I took stats in college and and understand the concept on a high-level, but I am not an expert in this space; so, I hope someone can offer some conclusions on how to interpret your results. If I were to make a conclusion (an extremely general one at that), you have a decent amount of variance in your data but also a small-medium sample size, which increases the range of your confidence interval. Finally, ci='95%' is a much more common way to analyze confidence rather than ci='sd' from some reading on the topic. For example, this article says "It's not done often, but it is certainly possible to compute a CI for a SD."
A: Confidence interval for mean of population is calculated as follow:

In the formula:
x_bar => mean of your sample
t => t-statistic. It changes according to your sample size. You can refer to t-table
For example for 90% confidence level if your sample size is 5; t-statistic is 2.015
On python it is calculated with below code :
import scipy.stats as st
st.t.ppf(confidence_level / 2 , len(sample)-1)

s => standard deviation of your sample
I guess seaborn uses the same formula.
Because when I make graph with this formula it gives the same result as seaborn.
