I have a pandas dataframe as below.
d = {'emp': ['a', 'a', 'a', 'b', 'b', 'b'], 'vendor': ['x', 'x', 'y', 'z', 'z', 'z'], 'date': [1,1,2,3,3,3], 'amount': [4.9, 4.8, 1, 6, 5.6, 5.4]}
df = pd.DataFrame(data=d)
df["rounds"]=np.ceil(df['amount'])
df
amount date emp vendor rounds
0 4.9 1 a x 5.0
1 4.8 1 a x 5.0
2 1.0 2 a y 1.0
3 6.0 3 b z 6.0
4 5.6 3 b z 6.0
5 5.4 3 b z 6.0
I want to create the example column which would have a unique number if the same emp has spent the same amount (column rounds) at the same vendor on the same day.
an employee could have multiple transactions matching this criteria or they could have 0 transactions matching this criteria
how could i proceed?
example
1
1
2
2
2
when a number is same in the example column, it indicates that all transactions that fall in one group
another example
if my dataframe is like below
d = {'emp': ['a', 'a', 'a', 'a', 'b', 'b'], 'vendor': ['x', 'x', 'y', 'y', 'z', 'z'], 'date': [1,1,2,2,3,3], 'amount': [4.9, 4.8, 1, 1, 5.6, 5.4]}
then column example should have values '1,1,2,2,3,3'