netsec-lab/ex2/rep-12.py
2021-05-07 14:27:16 +02:00

15 lines
556 B
Python

import pandas as pd
df = pd.read_csv(r'../data/Ex2flows_team13.csv')
dataLength = len(df)
singleDestinationFilter = df['distinct(destinationIPAddress)'] == 1
moreThan10DestinationsFilter = df['distinct(destinationIPAddress)'] > 10
percentageOfSingleDst = len(df[singleDestinationFilter]) / dataLength * 100
percentageOfMoreThan10Dst = len(df[moreThan10DestinationsFilter]) / dataLength * 100
print("Single Destination: {} %".format(round(percentageOfSingleDst, 3)))
print("More than 10 destinations: {} %".format(round(percentageOfMoreThan10Dst, 3)))