I am using a network trace dataset, and have loaded the initial data into a pandas dataframe, which looks like this:
I have created a python dict with common port numbers and applications names like
port_dict = {80: 'http', 20: 'ftp', 21: 'ftp'}
and I want to modify my dataframe by adding additional columns whose names will be the unique values of the ports_dict
and if either of sport
or dport
contains the relevant key, the newly added column should have a value True
, False
otherwise, like this:
In the above picture, the column https
should have True
as the sport is 443
.
How would I go about accomplishing this?