Question: In the following, you will be using the cats dataframe: name = [' zoe', 'sadie', 'linus', 'sophie', 'heidi', 'tobey', 'jasper'] sex = [' female', 'female',

![= [' zoe', 'sadie', 'linus', 'sophie', 'heidi', 'tobey', 'jasper'] sex = ['](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/10/670f9d701485f_591670f9d6fe9164.jpg)
![female', 'female', 'male', 'female', 'female', 'male', 'male' ] shy = [True, False,](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/10/670f9d70821aa_592670f9d7061112.jpg)
![True, False, False, False , False] meow volume = [10, 10 ,](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/10/670f9d70e8ce9_592670f9d70c3db0.jpg)
In the following, you will be using the cats dataframe: name = [' zoe', 'sadie', 'linus', 'sophie', 'heidi', 'tobey', 'jasper'] sex = [' female', 'female', 'male', 'female', 'female', 'male', 'male' ] shy = [True, False, True, False, False, False , False] meow volume = [10, 10 , 8, 4, 12, 6, 10] # 0=unknown, 1=january, 2=february, ... and so on birth month = [3, 0, 6, 0, 0, 9, 4] cats = pd . DataFrame ( { 'name ' : name, 'sex ' : sex, 'shy' : shy, 'meow volume' :meow_volume, 'birth month' :birth month }) Your task is to implement two functions that retrieve specific quantities from this dataframe. 1. Implement function get_min_by_sex ( df , s, col ) which returns the minimum value of column col for cats that are of sex s. Note that col and s are strings and df is a pandas dataframe. 2. Implement function get_mean_by_birth_month ( df , gt, col ) which returns the mean value of column col for cats with a birth_month greater than gt. Note that col is a string, gt is a number, and df is a pandas dataframe. Your implementations will only be tested on columns having integer or floating point values. 265616.1535472 LAB ACTIVITY 19.8.1: Final Exam Problem 8 0/7 main.py Load default template...main.py Load default template... 1 import pandas as pd W N 3 # returns the minimum value of column col for sex s 4 def get_min_by_sex(df , s, col) : # complete this function pass 7 8 # returns the mean of column col for rows with a birth_month > gt 9 def get_mean_by_birth_month(df , gt, col) : 10 # complete this function 11 pass 12 13 if __name___ == '__main__' : 14 # the data frame stores animal information for a local shelter 15 name = ['zoe' , 'sadie', 'linus', 'sophie', 'heidi', 'tobey', 'jasper'] 16 sex = ['female' , 'female', 'male', 'female' , 'female' , 'male' , 'male' ] 17 shy = [True, False, True, False, False, False , False] 18 meow_volume = [10, 10, 8, 4, 12, 6, 10] Develop mode Submit mode Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box.main.py Load default template... 10 # complete this function 11 pass 12 13 if __name_ == '__main__' : 14 # the data frame stores animal information for a local shelter 15 name = ['zoe' , 'sadie', 'linus', 'sophie', 'heidi', 'tobey', 'jasper'] 16 sex = ['female' , 'female' , 'male', 'female' , 'female' , 'male' , 'male'] 17 shy = [True, False, True, False, False, False , False] 18 meow_volume = [10, 10, 8, 4, 12, 6, 10] 19 # 0=unknown, 1=january, 2=february, ... and so on 20 birth_month = [3,0,6,0,0,9,4] 21 22 cats = pd. DataFrame({ 23 'name ' : name , 24 ' sex' : sex, 25 'shy' : shy, 26 'meow_volume ' : meow_volume, 27 'birth_month' : birth_month Develop mode Submit mode Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box.main.py Load default template... 13 if __name_ == '_main_ _' : 14 # the data frame stores animal information for a local shelter 15 name = ['zoe', 'sadie', 'linus', 'sophie', 'heidi', 'tobey', 'jasper'] 16 sex = ['female' , 'female', 'male', 'female' , 'female', 'male', 'male' ] 17 shy = [True, False, True, False, False, False , False] 18 meow_volume = [10, 10, 8, 4, 12, 6, 10] 19 # 0=unknown, 1=january, 2=february, . . . and so on 20 birth_month = [3,0,6,0,0,9,4] 21 22 cats = pd. DataFrame({ 23 name ' : name , 24 'sex' : sex, 25 'shy' : shy, 26 'meow_volume ' : meow_volume, 27 'birth_month' : birth_month 28 29 print(get_min_by_sex(cats, 'male', 'meow_volume' )) 30 print(get_mean_by_birth_month(cats, 0, 'meow_volume' )) Develop mode Submit mode Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
