I want to create a column that displays a count of how many times 2 parameters in a column are met in each row. For example, in the below image, the "n" column is what I need to display. It is a number that is duplicated based on if the row meets each parameter. I want it to give a count as the "n" which displays the number of times that the unit/month are the same.
Not sure how to tackle this without using group_by... any thoughts!?
Here is a script to build out the dataframe:
lst = [['unit_1', 1], ['unit_1', 1],
['unit_1', 1], ['unit_1', 1],
['unit_1', 1], ['unit_2', 1],
['unit_2', 1], ['unit_2', 1],
['unit_2', 1], ['unit_4', 2],
['unit_8', 4], ['unit_5', 2]]
df = pd.DataFrame(lst, columns =['unit', 'month'])