简体   繁体   中英

Compute Confidence Interval with Python

I tried to compute C.I. for NHANES dataset("BPXSY1") using two different ways with Python, but both gave me the answer of (nan, nan), anyone knows why?

sm.stats.DescrStatsW(da["BPXSY1"]).zconfint_mean()

and

st.norm.interval(alpha = 0.95, loc = np.mean(da["BPXSY1"]), scale = st.sem(da["BPXSY1"]))

Usually this is because there are some NaNs in the dataset. You can check if a pandas dataframe contains NaNs with df['your column name'].isnull().values.any() or check the number of NaNs with df['your column name'].isnull().sum()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM