How to Conduct a One Sample T-Test in Python Last Updated : 20 Feb, 2022 Comments Improve Suggest changes Like Article Like Report In this article, we are going to see how to conduct a one sample T-Test in Python. One Sample T-Test in Python The one-sample t-test is a statistical hypothesis test that can be used to see if the mean of an unknown population differs from a given or known value. In this article let's learn how to perform a one-sample t-test. null hypothesis: the mean of the areas is 5000. alternative hypothesis: the mean of the areas is not 5000. CSV Used: Create a Dataframe for demonestration Python3 # import packages import scipy.stats as stats import pandas as pd # loading the csv file data = pd.read_csv('areas.csv') data.head() Output: Conduct a One Sample T-Test in Python To perform one-sample t-test we will use the scipy.stats.ttest_1samp() function to perform one- sample t-test. The T-test is calculated for the mean of one set of values. The null hypothesis is that the expected mean of a sample of independent observations is equal to the specified population mean, popmean. Syntax: scipy.stats.ttest_1samp(a, popmean, axis=0). parameters: a : an array or iterable object of sample observations.popmean : expected mean in the null hypothesis.axis : its an optional parameter. represents axis. returns : t statistic and two tailed p value. Python3 # import packages import scipy.stats as stats import pandas as pd # loading the csv file data = pd.read_csv('areas.csv') # perform one sample t-test t_statistic, p_value = stats.ttest_1samp(a=data, popmean=5000) print(t_statistic , p_value) Output: [-0.79248301] [0.44346471] Here t_statistic is -0.79248301 p-value is 0.44346471 As the p_value for the given problem is more than 0.05 which is the alpha value, we accept the null hypothesis and the alternative hypothesis is rejected. Comment More infoAdvertise with us Next Article How to Conduct a One Sample T-Test in Python I isitapol2002 Follow Improve Article Tags : Machine Learning Geeks Premier League AI-ML-DS Geeks-Premier-League-2022 python Practice Tags : Machine Learningpython Similar Reads How to Conduct a Two Sample T-Test in Python In this article, we are going to see how to conduct a two-sample T-test in Python. This test has another name as the independent samples t-test. It is basically used to check whether the unknown population means of given pair of groups are equal. tt allows one to test the null hypothesis that the me 7 min read How to Conduct a Paired Samples T-Test in Python Paired sample T-test: This test is also known as the dependent sample t-test. It is a statistical concept and is used to check whether the mean difference between the two sets of observation is equal to zero.  Each entity is measured is two times in this test that results in the pairs of observation 3 min read How to Conduct a Wilcoxon Signed-Rank Test in Python? Prerequisites: Parametric and Non-Parametric Methods, Hypothesis Testing In this article, we are going to see how to conduct a Wilcoxon signed-Rank test in the Python programming language. Wilcoxon signed-rank test, also known as Wilcoxon matched pair test is a non-parametric hypothesis test that c 3 min read How to Perform Dunnâs Test in Python Dunn's test is a statistical procedure used for multiple comparisons following a Kruskal-Wallis test. Here's a breakdown of what it does and when it's used: Table of Content Dunnâs TestWhat is the Kruskal-Wallis test?Key points about Dunn's testHow to Perform Dunnâs Test with PythonStep-by-Step Guid 6 min read How to Perform an F-Test in Python In statistics, Many tests are used to compare the different samples or groups and draw conclusions about populations. These techniques are commonly known as Statistical Tests or hypothesis Tests. It focuses on analyzing the likelihood or probability of obtaining the observed data that they are rando 10 min read Like