= pd.read_csv('https://bcdanl.github.io/data/cereals_oatmeal.csv') cereal
Classwork 13
Group Operation I
Direction
The dataset ,cereals_oatmeal.csv
,(with its pathname https://bcdanl.github.io/data/cereals_oatmeal.csv
) is a listing of 77 popular breakfast cereals and oatmeal.
Question 1
Group the data by Manufacturer, and determine the number of groups and the number of cereals per group.
Answer:
Question 2
Calculate the mean of the Calories
, Fiber
, and Sugars
for every manufacturer.
Answer:
Question 3
Create a new DataFrame that includes the maximum Sugars
and the minimum Fiber
per manufacturer.
Answer:
Question 4
Add a Normalized_Sugars
variable to the cereal
DataFrame that standardizes each cereal’s sugar content within its manufacturer group.
\[ \text{Normalized\_Sugars} = \frac{\text{Sugars} - \text{mean(Sugars)}}{\text{std(Sugars)}} \]
This formula adjusts the sugar content of each product by subtracting the mean sugar content of its manufacturer and then dividing by the standard deviation of the sugar content within its manufacturer.
Answer:
Question 5
Put the two highest-sugar cereals for every manufacturer in a new DataFrame.
Answer:
Question 6
- Compute the correlation between
Calories
andSugars
for each manufacturer.corr()
calculates the correlation betweenSERIES_1
andSERIES_2
.
"Calories"].corr( cereal["Sugars"] ) # returns a correlation value
cereal["Calories", "Sugars"]].corr() # returns a DataFrame of correlation matrix
cereal[["Calories", "Sugars", "Fiber"]].corr() # returns a DataFrame of correlation matrix cereal[[
Answer:
Discussion
Welcome to our Classwork 13 Discussion Board! đź‘‹
This space is designed for you to engage with your classmates about the material covered in Classwork 13.
Whether you are looking to delve deeper into the content, share insights, or have questions about the content, this is the perfect place for you.
If you have any specific questions for Byeong-Hak (@bcdanl) regarding the Classwork 13 materials or need clarification on any points, don’t hesitate to ask here.
Let’s collaborate and learn from each other!