This blog article shows you how to do two sample t-test using python. I got the python code from the link in my reference. In that article, the example first finds the variance. Unfortunately, the sample code is missing the np declaration. The code below added the line.
import numpy as np
import scipy.stats as stats
data_group1 = np.array([14, 15, 15, 16, 13, 8, 14,
17, 16, 14, 19, 20, 21, 15,
15, 16, 16, 13, 14, 12])
data_group2 = np.array([15, 17, 14, 17, 14, 8, 12,
19, 19, 14, 17, 22, 24, 16,
13, 16, 13, 18, 15, 13])
print(np.var(data_group1), np.var(data_group2))
You should get the variance if you run the code as follows.

The t-test code is good, but you may need to install pingouin using pip install like. pip install pingouin.
from statsmodels.stats.weightstats import ttest_ind
import numpy as np
import pingouin as pg
data_group1 = np.array([160, 150, 160, 156.12, 163.24,
160.56, 168.56, 174.12,
167.123, 165.12])
data_group2 = np.array([157.97, 146, 140.2, 170.15,
167.34, 176.123, 162.35, 159.123,
169.43, 148.123])
result = pg.ttest(data_group1,
data_group2,
correction=True)
print(result)
You should get the t-test if you run the code as follows.

You can download the Python code belong and test them.
Video: https://youtu.be/QjXJzEhRZIc?WT.mc_id=DP-MVP-36769
Source code download: https://github.com/chanmmn/python/tree/main/T-Test/?WT.mc_id=DP-MVP-36769
Reference: https://www.geeksforgeeks.org/how-to-conduct-a-two-sample-t-test-in-python/
Pingback: One sample T- Test using C# | Chanmingman's Blog