How do I go about adding a new column in a pandas dataframe, where I want the column to have a counter based on anothers column criteria, for example (desired output shown):
WeekCounter DayofWeeek
1 Monday
1 Monday
1 Tuesday
1 Sunday
2 Monday
2 Wednesday
2 Thursday
2 Sunday
3 Monday
3 Monday
3 Monday
How do I create a column that acts as a counter whenever the column value changes from Sunday to Monday? My original attempt would be a for loop with a nested if statement, but is there a more pandas-native manner in accomplishing this?