You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
efficiency = wp.weighting_efficiency(df_weighted[col_weights])
`
when run this code,show KeyError: "['gender', 'agecat', 'county'] not in index",how do I to fix it? Thanks!
The text was updated successfully, but these errors were encountered:
Hi,
This normally suggests that those columns do not exist in your data.
The first place to check is that "gender", "agecat" and "county" are columns in your pres_df.
Hi, I used Weightipy to cpmpute my data's weight,the code in below:
`age_targets = {'agecat':{1: 0.067468889, 2: 0.080224503, 3: 0.081368672, 4: 0.084373472, 5: 0.102660891
,6:0.094806186,7:0.090030135,8:0.090639452,9:0.088830485,10:0.077339418,11:0.136466392,98:0.005791506}}
gender_targets = {'gender':{1: 0.488588237, 2: 0.511411763}}
county_targets = {"county":{2:0.019395905,4:0.023782735,5:0.02292341,7:0.02292341,8:0.02088535,9:0.028729086,10:0.021700082
,13:0.034964756,14:0.009158398,15:0.013730506,16:0.004724007,17:0.015997925,18:0.018345312,20:0.011139324
,63:0.107256094,64:0.11836086,65:0.173914542,66:0.118862683,67:0.080211099,68:0.095929136,72:0.006447622}}
scheme = wp.Rim('gender_and_age_and_county')
scheme.set_targets(targets=[age_targets, gender_targets,county_targets])
pres_df["identity"] = range(len(pres_df))
engine = wp.WeightEngine(data=pres_df)
engine.add_scheme(scheme=scheme, key="identity", verbose=False)
engine.run()
df_weighted = engine.dataframe()
col_weights = f"weights_{scheme.name}"
efficiency = wp.weighting_efficiency(df_weighted[col_weights])
`
when run this code,show KeyError: "['gender', 'agecat', 'county'] not in index",how do I to fix it? Thanks!
The text was updated successfully, but these errors were encountered: