Can we change the estimated population mean in Hypothesis Testing? My goal is to learn hypothesis testing. My understanding is that we do not have the population data. Therefore, we do not know the estimated population mean. So, we guess the population mean. If that so, can we change the population mean until the p-value is below 0.05, so we have enough evidence to reject the null hypothesis?
The code
import pandas as pd
from scipy import stats

sample = pd.Series([1,2,3,4,5,6,7,8,9,10])

# Hypothesis Testing:
#
# H0: μ <= 3.5 (previously it was μ <= 5.5, 
#               then 5, then 4.5, I change it until I get p value less than 0.05)
# H1: μ > 3.5

t_stat, p_value = stats.ttest_1samp(a = sample, popmean=3.5, alternative="greater")

print("sample mean:", sample.mean())
print("t-statistic: {0:.2f} p-value: {1:.2f}".format(t_stat, p_value))

print("since we do not have the population data, "
      "popmean=3.5 is not meaningful, "
      "we can change it until we get enough evidence to reject the null hypothesis")

print("critical value: 5%, therefore confidence interval: 90%")

print("because p-value is below 0.05, we have enough evidence to reject the null hypothesis. "
      "therefore, we can conclude that the mean population is more than 3.5")

print("population standard deviation {0:.2f}".format(sample.std(ddof=0)))

print("if we imagine the sample as the weight of waste, the conclusion is, "
      "90% of population data is between population mean + 3 * population standard deviation, "
      "in this case 3.5 +- 3 * 2.87")
```


The idea of hypothesis testing is that you are interested in testing a particular hypothesis before having seen the data. If you change the hypothesis based on the data, the data will not address the hypothesis you were interested in before.
There is also another problem, which is that the theory behind the hypothesis tests assumes that the hypothesis is not chosen based on the same data on which it is tested. This means that testing a hypothesis chosen based on the data is invalid.
