Statistics in Python
This is a brief overview of statistics in python. In data science we always inspect our data using descriptive statistics and descriptive plots. Such statistics can be used of course for visualisations or dashboards as well. The statistical analysis can be done with a number of tests, depending on the characteristics of the data and the research question to be answered. Statistical analysis consists of three parts
Practical: Descriptive statistics
Graphical: Descriptive plots
Analytical: Statistical analysis
Descriptive statistics
Let us create some data for demonstration purpose. We will put the data in a pandas dataframe since pandas has some nice numpy methods built ins, like mean()
, sum()
, max()
,min()
etc. It can even deliver the descriptive statistics at once with describe()
Most of the time you just want a nice table with the descriptives
count
5.00000
5.000000
mean
8.70000
0.200000
std
11.09955
0.079057
min
1.00000
0.100000
25%
2.50000
0.150000
50%
4.00000
0.200000
75%
8.00000
0.250000
max
28.00000
0.300000
Which you can modify like every other dataframe
measurement
5.0
8.7
11.10
weights
5.0
0.2
0.08
Descriptive plots
We can also use the built in plots for our exploratory data analyses. Like boxplot()
, hist()
, plot.kde()
or just plot()
Analytical statistics
Normality check with Shapiro-Wilk Test
It is good practice to check for normality. The Shapiro-Wilk Test is a good test for checking normality
source: https://machinelearningmastery.com/statistical-hypothesis-tests-in-python-cheat-sheet/
More statistics
There are a number of cheatsheets and tutorials on the internet. The next overview is a compact overview of tutorials
Last updated
Was this helpful?