i am trying to count the number of occurrences of the same packet in my dataframe, a packet is the same if it has these matching fields:
['SourceIP', 'SourcePort', 'DestinationIP', 'DestinationPort', 'Protocol']
I want to make a new column in my dataframe with the occurrence values and have this column be called 'PerSec'
I have tried to implement the solution to this problem found here Pandas create new column with count from groupby
However when I run:
df['PerSec'] = df.groupby(['SourceIP', 'SourcePort', 'DestinationIP', 'DestinationPort', 'Protocol']['SourceIP', 'SourcePort', 'DestinationIP', 'DestinationPort', 'Protocol'].transform('PerSec'))
with pd.option_context('display.max_rows', None, 'display.max_columns', None):
print(df)
I receive this error:
TypeError: list indices must be integers or slices, not tuple
Does this mean the groupby method will only work upon one column?