Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dx = da[["SMQ020x", "RIAGENDRx"]].dropna()
- pd.crosstab(dx.SMQ020x, dx.RIAGENDRx)
- # Recode SMQ020x from Yes/No to 1/0 into existing variable SMQ020x
- dx["SMQ020x"] = dx.SMQ020x.replace({"Yes": 1, "No": 0})
- dz = dx.groupby("RIAGENDRx").agg({"SMQ020x": [np.sum, np.mean, np.size]}) # np.mean in this case is about smokers proportion
- dz.columns = ["Proportion of smokers", "Total n"]
- dz
- ######################################################
- from statsmodels.stats import proportion
- females = proportion.proportion_confint(906,2972) # for 95% conf. interval
- females
Add Comment
Please, Sign In to add comment