Hi a have a dataframe with some user_id, the months that they are active, and the lead_month which they're active.I need to perform the calculation of column "active_months" shown at the bellow image, that counts how many consecutives month this user is active. So when it took more than 1 month to this user to be active again, we reset our count starting again at 1.
I can't groupby my data, I need to work as window function, because I have other operations to make at user_id level
Can anyone help me?
I tried a window function with Window().partitionBy(['account_id']).orderBy('reference_month').rowsBetween(Window.unboundedPreceding, Window.currentRow) but it doesn't rest the count to 1
