I have the following data table, and I want to get the count by putting some conditions on the existing columns, It'll be really great help if I can get the solution for the same.
Input:
Key1 id1-age id2-age id3-age id4-age id5-age id1-gender id2-gender id3-gender id4-gender id5-gender
0 a 6 32 61 22 23 M F M F F
1 b 36 25 52 16 33 M M F F M
2 c 12 21 45 15 66 F M M M F
Problem Statement
A single key as multiple age of Individuals and Gender for that specific Key w.r.t. Age id, & I want make columns which will have counts of age groups for each row in python w.r.t. to its gender.
following output is expected:
Output Expected:
Key1 id1-age id2-age id3-age id4-age id5-age age(02-15) age(16-21) age(21-30) age(31-40) age(41-50) age(51-60) age(61+)
0 a 6 32 61 22 23 1 0 2 1 0 0 1
1 b 36 25 52 16 33 0 1 1 2 0 1 0
2 c 12 21 45 15 66 2 1 0 0 1 0 1
I hope I'm able to give the proper explanation to my problem statement. waiting for the positive responses Thanks in Advance