So to execute a z-test in python, I have seen people doing:
from statsmodels.stats.weightstats import ztest as ztest
# IQ levels of 20 patients post medication
data = [88, 92, 94, 94, 96, 97, 97, 97, 99, 99,
105, 109, 109, 109, 110, 112, 112, 113, 114, 115]
ztest(data, value=100) # value is mean
Why is the Population standard deviation (std) not required in the argument? How does the library apply the z-test formula without getting the population std?
If you examine the source code for the statsmodels ztest method (available at https://www.statsmodels.org/dev/\_modules/statsmodels/stats/weightstats.html#ztest) you will see that the sample variance, and hence standard deviation, is computed internally by that method.
The default method for computing the standard deviation is "pooled", where the standard deviation of the samples is assumed equal in the case of a two-sample z-test. You can set the usevar argument to "unequal" to have the ztest method compute the standard deviation of the samples separately.