I am trying to create a function which creates a new column that identifies the oldest member of a household. The data looks something like this:
Household_id | Person | Date_of_birth |
---|---|---|
1234 | 1 | 12/09/1994 |
1234 | 2 | 04/01/1967 |
1234 | 3 | 21/10/1953 |
4321 | 1 | 11/04/1981 |
4321 | 2 | 18/06/1988 |
and I want to create this:
Household_id | Person | Date_of_birth | Oldest_member |
---|---|---|---|
1234 | 1 | 12/09/1994 | 0 |
1234 | 2 | 04/01/1967 | 0 |
1234 | 3 | 21/10/1953 | 1 |
4321 | 1 | 11/04/1981 | 1 |
4321 | 2 | 18/06/1988 | 0 |
Where the oldest member is assigned 1 and everyone else in the household is assigned 0.
Any suggestions on how to tackle this or functions I could look up would be greatly appreciative, I’m still new to python and I’m quite stuck on this.