I have a dataframe of ID's and what months they were active that looks like:
ID MONTH LOCATION ACTIVE
1 2019-01-01 A 1
1 2019-02-01 A 1
1 2019-03-01 A 1
1 2019-04-01 A 1
2 2020-02-01 B 1
2 2020-03-01 B 1
I also have a dataframe of logins that are floored to the first of the month that looks like:
ID LOGIN LOCATION
1 2018-01-01 A
1 2018-02-01 A
2 2019-12-01 B
What I would like to do is add a column to the first dataframe which indicates if the user had a login within 12 months of that month. Which would look like:
ID MONTH LOCATION ACTIVE LOGIN_IN_PAST_12_MONTHS
1 2019-01-01 A 1 1
1 2019-02-01 A 1 1
1 2019-03-01 A 1
1 2019-04-01 A 1
2 2020-02-01 B 1 1
2 2020-03-01 B 1 1
2 2020-04-01 B 1 1