0

How can I get one colomn which is the results of df.groupy('src_mac').transform('nunique') but in every groups the value is from 0 to max?

For example:

df:

IP src_mac
192.168.0.1 abc
192.168.0.2 abc
192.168.0.3 abc
192.168.0.3 abc
192.168.0.4 666

I want to get a column as follows:

ip_num_per_mac
1
2
3
3
1

I have used counts = pd.get_dummies(df['src_mac']).cumsum() to get the cumulative count per 'src_mac' as many columns. Is there any methods to join every columns in one column?

0 Answers0