I have csv data and trying to plot graph rtt overtime for each IP address in the data.
Here is the code to plot the graphs. There is a “KeyError” being raised when trying to plot the data. Any recommendations?
data.csv
time,ip,rtt,jitter
2023-02-17 12:01:00,192.168.1.1,25,100
2023-02-17 12:02:00,192.168.1.1,27,110
2023-02-17 12:03:00,192.168.1.1,28,110
2023-02-17 12:04:00,192.168.1.2,25,100
2023-02-17 12:05:00,192.168.1.2,28,110
from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource
from bokeh.palettes import Category10
from bokeh.transform import factor_cmap
import pandas as pd
data = pd.read_csv('data.csv', parse_dates=['time'])
factors = data['ip'].unique().tolist()
source = ColumnDataSource(data)
p = figure(x_axis_type='datetime', plot_width=800, plot_height=400, title='RTT over time by IP address')
colors = factor_cmap('ip', palette=Category10[2], factors=factors)
p.multi_line(xs='time', ys='rtt', source=source, line_width=2, line_color=colors, legend_field='ip')
p.xaxis.axis_label = 'Time'
p.yaxis.axis_label = 'RTT (ms)'
p.legend.title = 'IP Address'
show(p)