I would like to know if there is a way I can insert values into a new column of my dataframe based on using some sort of code which is similar to the df.groupby(['Col1','Col2']).agg({'Col2':'count'})
function.
My Df looks something like this:
ID Customer Connection Product_ID Count
10 AMXX Instant AAB NaN
11 JKXX Slow AAB NaN
12 LKXX Slow HJA NaN
13 AMXX Instant AAB NaN
14 RFXX Slow WRQ NaN
15 RFXX Instant WRQ NaN
df['Count'] is the new empty column I have created where I would like to store the counts of how many times each customer uses the product that has been recorded per row in the 'Product_ID' column. Instead of doing a group-by, I was hoping to use the same df and only fill in the 'Count' column.
I would like the df to look something like this:
ID Customer Connection Product_ID Count
10 AMXX Instant AAB 2
11 JKXX Slow AAB 1
12 LKXX Slow HJA 1
13 AMXX Instant AAB 2
14 RFXX Slow WRQ 2
15 RFXX Instant WRQ 2
Would anyone happen to know how I can possibly do this? Thank you :)