python3 coding Problem 17 You create a dictionary and then turn that into a Pandas dataframe. Suppose you have three lists that contain the height in meter, the corresponding weight in kilogram, and the body mass index (bmi) of the height and weight as follow: height = [1.47, 1.5, 1.52, 1.55, 1.57, 1.6, 1.63, 1.65, 1.68, 1.7, 1.73, 1.75, 1.78, 1.8, 1.83] weight = [52.21, 53.12, 54.48, 55.84, 57.2, 58.57, 59.93, 61.29, 63.11, 64.47, 66.28, 68.1, 69.92, 72.19, 74.46] bmi = [24.16, 23.61, 23.58, 23.24, 23.21, 22.88, 22.56, 22.51, 22.36, 22.31, 22.15, 22.24, 22.07, 22.28, 22.23] Store the three lists in a pandas DataFrame. Call the DataFrame bmi_table. Call the columns height, weight, bmi. Show the first 6 rows of the table   2) You will use the dataframe you created in Problem 17 (more Pandas this shows me if you are good enough in basic Python At this point that you actually can tackle something new and not fall apart). Write a function get_sample_mean that takes in two input arguments: the desired sample_size and a dataframe called data.  In the function pull a random sample of the specified sample_size of rows and save those as another dataframe. Now  Calculate and return the mean of the sample dataframe. Call your function on the height column with a sample size of 5 and print the mean Call your function on the weight column with a sample size of 5 and print the mean Call your function on the bmi column with a sample size of 5 and print the mean.   Hint: you can call the function with bmi_table.height, 5 Hint: you can call the function with bmi_table.weight, 5 Hint: you can call the function with bmi_table.bmi, 5  Hint: in the function you can pull a random 5 rows using data.sample(n=5) Ie sampledata = data.sample(n=5) Hint: in the function to get the mean you can do samplemean = sampledata.mean() Or sum(sample) / len(sample) Hint: you can look in my pandas folder in class notes or just search google for examples on how to pull a specific column from a data frame, how to get a sample (a random number of rows pulled out) and get the mean etc.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

python3 coding

Problem 17

You create a dictionary and then turn that into a Pandas dataframe.

Suppose you have three lists that contain the height in meter, the corresponding weight in kilogram, and the body mass index (bmi) of the

height and weight as follow:

height = [1.47, 1.5, 1.52, 1.55, 1.57, 1.6, 1.63, 1.65, 1.68, 1.7, 1.73, 1.75, 1.78, 1.8, 1.83]

weight = [52.21, 53.12, 54.48, 55.84, 57.2, 58.57, 59.93, 61.29, 63.11, 64.47, 66.28, 68.1, 69.92, 72.19, 74.46]

bmi = [24.16, 23.61, 23.58, 23.24, 23.21, 22.88, 22.56, 22.51, 22.36, 22.31, 22.15, 22.24, 22.07, 22.28, 22.23]

Store the three lists in a pandas DataFrame. Call the DataFrame bmi_table. Call the columns height, weight, bmi.

Show the first 6 rows of the table

 

2)

You will use the dataframe you created in Problem 17 (more Pandas this shows me if you are good enough in basic Python At this point that you actually can tackle something new and not fall apart).

Write a function get_sample_mean that takes in two input arguments: the desired sample_size and a dataframe called data.  In the function pull a random sample of the specified sample_size of rows and save those as another dataframe. Now  Calculate and return the mean of the sample dataframe.

Call your function on the height column with a sample size of 5 and print the mean

Call your function on the weight column with a sample size of 5 and print the mean

Call your function on the bmi column with a sample size of 5 and print the mean.

 

Hint: you can call the function with bmi_table.height, 5

Hint: you can call the function with bmi_table.weight, 5

Hint: you can call the function with bmi_table.bmi, 5 

Hint: in the function you can pull a random 5 rows using data.sample(n=5)

Ie sampledata = data.sample(n=5)

Hint: in the function to get the mean you can do

samplemean = sampledata.mean()

Or

sum(sample) / len(sample)

Hint: you can look in my pandas folder in class notes or just search google for examples on how to pull a specific column from a data frame, how to get a sample (a random number of rows pulled out) and get the mean etc.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Map
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education