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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started