I am trying to add a column to my dataframe that tells me the number of a product per group. My dataframe looks like this:
ID Product Time
6578 X ...
6574 Y
6439 X
6543 Y
6756 X
6756 X
What I want as an output is this:
ID Product Number_of_ID_per_Product Time
6578 X 1 ...
6574 Y 1
6439 X 2
6543 Y 2
6756 X 3
6756 X 4
I tried
df['ID_Number_per_Part']=vormessen.groupby(['Product'])['ID'].count()
which gives me only NaN values.