Open nitsrek opened 5 years ago
currently used workaround
adj_w_vec = pd.Series() countries = [153, 75, 230 ,210, 82, 1] for c in countries: w_vec = dataset[dataset.take({'country': c}), 'weight'] valid_counts = dataset['weight'].count() if not c == 230: ratio = 1/float(len(countries)) * w_vec else: # add factor if weighted and unweighted bases differ ratio = (1212.0/1208.1) * (1/float(len(countries)) * w_vec) scale_factor = len(w_vec.index) / float(valid_counts) ratio = ratio / scale_factor adj_w_vec = adj_w_vec.append(ratio).dropna() dataset['w_all'] = adj_w_vec
currently used workaround