Question: I need help creating a side by side box-and-whisker (so there is two box and whiskers) plot in Pandas PYHON, comparing the birth weights of
I need help creating a side by side "box-and-whisker" (so there is two box and whiskers) plot in Pandas PYHON, comparing the birth weights of babies whose mother "never" smoked and of those mothers who "does" smoke.
df = pd.read_csv("https://www.stat.berkeley.edu/~statlabs/data/babies.data", delim_whitespace=True) df.head(10)
# this is where all the data is pulled from.
https://www.stat.berkeley.edu/~statlabs/labs.html.
# this is a better link explaining the data.
Basically mothers who smoke is represented as 1 and mothers who don't smoke is 0. The label is "smoke", and "bwt".
bars = ("birth weight of babies with non-smoking mother", df.loc[df["smoke"] == 0]["bwt"], "birth weight of babies with smoker mother", df.loc[df["smoke"] == 1]["bwt"])
# this might help creating a list for both of them idk.
Thanks!!!
fig, ax = plt.subplots(figsize=(5,8))
bp = dfW.loc[(dfW["NAME"]=='GROSS RESERVOIR, CO US') | (dfW["NAME"]=='RALSTON RESERVOIR, CO US')].boxplot( column=["TMIN"], by="NAME", ax=ax, widths=[.25, .25], return_type="dict")
for box in column['boxes']: box.set(color='steelblue', linewidth=2) # Change properties of whiskers for whisker in column['whiskers']: whisker.set(color='gray', linewidth=2)
# Change properties of caps for cap in column['caps']: cap.set(color='gray', linewidth=2)
# Change properties of median for cap in column['medians']: cap.set(color='green', linewidth=2, alpha=0.5)
# Change properties of fliers (outliers) for cap in column['fliers']: cap.set(markerfacecolor='ste
These might help as a reference. Any way you can will work!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
