Lets cay I have a pd.DataFrame() object that stores number of people that given age ang gender had stroke in the past. In mor visual way:
positive_by_gender.tail()
gives us:
gender | Female | Male |
---|---|---|
age | ||
78 | 9.0 | 12.0 |
79 | 13.0 | 4.0 |
80 | 10.0 | 7.0 |
81 | 8.0 | 6.0 |
82 | 4.0 | 5.0 |
So there are 9 females of age 78 that had stroke, 12 males of age 78 that had stroke etc.
What I want is to calculate a median for each gender of age taht they had stroke - in this excample it would be 79.5 for females, but I want it to be calculated by code not by me :-) - I guess I could make an array that for females would look like: [78 times 9, 79 times 13, 80 times 10, etc... ] and then find median this way but still - I dunno how to do even that. I'd really appreciate all help.