Question: I need help creating a new DataFrame in PYTHON PANDAS. df = pd.read_csv(https://www.stat.berkeley.edu/~statlabs/data/babies.data, delim_whitespace=True) df.head(10) #This is where I am extracting the data bars =
I need help creating a new DataFrame in PYTHON PANDAS.
df = pd.read_csv("https://www.stat.berkeley.edu/~statlabs/data/babies.data", delim_whitespace=True) df.head(10) #This is where I am extracting the data
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 is what I will be displaying on stacked histogram
In order to create a "stacked histogram " with the above properties, I need help creating a "new data frame" first then create a stacked histogram.
I tried something like new_fram_data = pd.DataFrame(bars), but I get the error saying "setting an array element with a sequence" . If you have any other way, please feel free.
Thanks
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
