Formulas exist for means and proportions, but not for every statistic. The bootstrap gets an interval for anything:
- Draw a sample of the same size from your data with replacement, so some values repeat and some drop out.
- Compute the statistic (a median, say) on it.
- Repeat a few thousand times, and take the 2.5th and 97.5th percentiles of the results as a 95% interval.
Sampling without replacement just reshuffles the same values, so every resample gives the same median. Fix the random seed (np.random.default_rng(42)) so the result can be reproduced.
The bootstrap assumes your sample represents the population; it can't fix a biased sample, and it is rough with very small ones.