Home /
Expert Answers /
Computer Science /
problem-17-all-in-python-please-this-problem-aims-to-test-your-ability-to-learn-and-apply-a-new-pyt-pa651

Problem 17 All in python please This problem aims to test your ability to learn and apply a new Python library called Pandas using your basic Python skills. You can refer to the class notes in the Pandas directory, specifically the Dataframes document, for an example. The task involves creating a dictionary and converting it into a Pandas DataFrame. You are given three lists representing height (in meters), weight (in kilograms), and body mass index (BMI) as follows: python Copy code 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] Your task is to store these lists in a Pandas DataFrame named bmi_table with columns named height, weight, and bmi. Display the first 6 rows of the table. Problem 18 Two additional individuals have been added to the height and weight lists (new values in red): python Copy code 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, 1.81, 2.20] 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, 49.12, 85.65] Calculate the BMI for the last and the second-to-last individuals added using the formula: BMI = weight (kg) / (height (m))^2. Hints: Use the index -1 to access the last element. Use the index -2 to access the second-to-last element. Problem 19 Using the DataFrame created in Problem 17, write a function get_sample_mean that takes two arguments: sample_size and a DataFrame data. The function should: Pull a random sample of rows of the specified sample_size from the DataFrame. Calculate and return the mean of the sample. Test your function on the height, weight, and bmi columns with a sample size of 5, and print the means. Hints: Use data.sample(n=sample_size) to pull a random sample. Calculate the mean using sample_data.mean() or sum(sample_data) / len(sample_data). Problem 20 Given two sets: python Copy code set1 = {1, 2, 3, 4, 5} set2 = {4, 5, 6, 7, 8} Perform and print the result of the following set operations, and briefly explain each: Union Intersection Difference Symmetric Difference Explanation should include what each operation does to the sets.