Calculating Bootsrap (Mean and Variance) if samples has non equal weight How to calculating Bootsrap (Mean and Variance) if samples have not equal weight?
 A: Suppose you have the following 100 observations (simulated in R), of which the first 50 have weight $2/3$ and the last 50 have weight $1/3.$
set.seed(524)
x = c(rnorm(50, 100, 10), rnorm(50, 100, 20))
a.obs = (2/3)*mean(x[1:50]) + (1/3)*mean(x[51:100])
a.obs
[1] 99.41525

Now I want to make a nonparametric 95% CI for the population mean. (Weights need not sum to $1.$ R adjusts them.)
set.seed(2020)
w = rep(2:1, each=50)    
d.re = replicate(3000, 
         mean(sample(x,100,rep=T,p=w))-a.obs)
UL = quantile(d.re, c(.975,.025))
a.obs-UL
    97.5%      2.5% 
 96.85066 102.00621 

So the 95% CI based on weighted resampling is
$(96.85, 102.01).$
A similar nonparametric 95% bootstrap CI for $\mu$ is
$(95.78, 101.67).$ It is little longer and centered
a little lower than the weighted version because
the weighed version puts less emphasis on more variable observations.
A: You can try something like this:
import numpy as np
data = np.random.uniform(0,1,100)
# make up some weights
wts = np.random.uniform(0,1,100)
wts = wts/wts.sum()

If your data is not huge, you can just make a matrix and get the mean and variance like this
B = 1000

xb = np.random.choice(data,replace=True,p=wts,size=(B,len(data)))
boot_mean = xb.mean(axis=1)
boot_var = xb.var(axis=1)

Otherwise maybe like this:
def func(x):
    return [x.mean(),x.var()]

[func(np.random.choice(data,replace=True,p=wts,size=len(data))) for i in range(B)]

