I have a dataframe with a list of string dates, and the length of each list:
data = [['a', ['8/5/2021'], 1], ['b', ['12/21/2021', '12/28/2021'], 2], ['c', ['8/10/2021', '8/27/2021', '9/3/2021', '9/10/2021', '9/17/2021'], 5], ['d', ['8/23/2021', '9/23/2021', '10/23/2021'], 3], ['e', ['8/10/2021', '9/27/2021', '10/3/2021', '11/10/2021', '11/17/2021', '12/27/2021'], 6]]
df = pd.DataFrame(data, columns=['Name', 'Dates', 'Total Weeks'])
I want to count the number of consecutive weeks in each list, and it'll be "one period". No matter how long it'll be, it'll be one period. One week on its own would also be considered "one period". I want to append this to a new column of the dataframe.
Finally, I'll like to count only the "periods" that are at least 2 weeks long or more. This would be appended to the dataframe as a new column. The end result should look like this:
I was thinking of using datetime.timedelta and groupby but can't seem to figure it out. Thank you in advance!
