Can someone please help me understand how I can count people whose status changed from one specific value to another specific value in the next month in Python?
My goal is to count people whose status is currently "Inactive".
Further, of those people, I only want to count those whose status was "Active" in the month prior to it changing to "Inactive".
I do not want want to include people who are currently Inactive
but whose status was something other than Active
in the month prior to it changing to Inactive
.
I've attempted to share an example below.
In this example, I would want to count Alison but not Bill.
|--------|-----------|----------| |--------|-----------|-----------|
| Person | Month | Status | | Person | Month | Status |
|--------|-----------|----------| |--------|-----------|-----------|
| Alison | Jan 2023 | Active | | Bill | Jan 2023 | Active |
| Alison | Feb 2023 | Active | | Bill | Feb 2023 | Active |
| Alison | Mar 2023 | Active | | Bill | Mar 2023 | Active |
| Alison | Apr 2023 | Active | | Bill | Apr 2023 | Transient |
| Alison | May 2023 | Inactive | | Bill | May 2023 | Inactive |
| Alison | June 2023 | Inactive | | Bill | June 2023 | Inactive |
| Alison | Jul 2023 | Inactive | | Bill | Jul 2023 | Inactive |
|--------|-----------|----------| |--------|-----------|-----------|
I haven't figured out a way to attempt to solve this yet. I've Googled quite a bit but haven't found this type of scenario addressed (I'm likely not using correct terms).