# Load data

We load data from any `infile.csv` to a pandas DataFrame with the following method. All packets will be sorted by the column `timestamp`.

`Assignment.``load`(infile)

  Loads input .csv file.

  Parameters

    infile (string) – Path of input .csv file.

  Returns

    data – Pandas dataframe containing data loaded from csv file.

  Return type

    pd.DataFrame

For this assignment the data loaded from benign.csv and unknown.csv contain summaries of network packets from various TCP/UDP flows. We use the method `Assignment.flows()` to extract these flows. This method returns a list of `(flow-tuple, pd.DataFrame)` and a nunmpy array of labels for each flow. Where the `flow-tuple` consists of `(protocol, src, sport, dst, dport)`, and the dataframe contains all packets within the flow.

`Assignment.``flows`(dataframe)

  Group dataframe by flow tuple.

  Parameters

    dataframe (pd.DataFrame) – DataFrame to group by flow tuple, defined as the 5-tuple: (protocol, src, sport, dst, dport).

  Returns

    - flows (list) – List of (key, frame) tuple for each flow. Where key: 5-tuple (protocol, src, sport, dst, dport). And frame: pd.DataFrame().

    - labels (np.array of shape=(n_flows,)) – Label corresponding to each flow.