In [1]:
import numpy as np
import pandas as pd
import pylab as pl
import matplotlib.pyplot as plt
%matplotlib inline
df = pd.read_csv('tmp/session_a.csv')
In [2]:
df.dtypes
Out[2]:
In [15]:
df['DstPortCls0'] =df['DstPort']/4096+1024
df['DstPortCls0']=np.floor(df['DstPortCls0'])
df['DstPortCls0']= df['DstPortCls0'].where(df['DstPort']>=1024,df['DstPort'])
df['DstPortCls1'] =df['DstPort']/1024+1024
df['DstPortCls1']=np.floor(df['DstPortCls1'])
df['DstPortCls1']= df['DstPortCls1'].where(df['DstPort']>=1024,df['DstPort'])
df['DstPortCls2'] =df['DstPort']/256+1024
df['DstPortCls2']=np.floor(df['DstPortCls2'])
df['DstPortCls2']= df['DstPortCls2'].where(df['DstPort']>=1024,df['DstPort'])
df['DstPortCls3'] =df['DstPort']/128+1024
df['DstPortCls3']=np.floor(df['DstPortCls3'])
df['DstPortCls3']= df['DstPortCls3'].where(df['DstPort']>=1024,df['DstPort'])
df['DstPortCls4'] =df['DstPort']/64+1024
df['DstPortCls4']=np.floor(df['DstPortCls4'])
df['DstPortCls4']= df['DstPortCls4'].where(df['DstPort']>=1024,df['DstPort'])
df['DstPortCls5'] =df['DstPort']/32+1024
df['DstPortCls5']=np.floor(df['DstPortCls5'])
df['DstPortCls5']= df['DstPortCls5'].where(df['DstPort']>=1024,df['DstPort'])
In [16]:
pl.figure(figsize=(12, 6))
p = df.groupby('DstPort')['DstPort'].count().plot.bar(width=2)
p.tick_params(labelbottom='off',top='off',bottom='off')
fig = p.get_figure()
fig.savefig('tmp/dstport001.png')
In [19]:
pl.figure(figsize=(12, 6))
p = df.groupby('DstPortCls0')['DstPortCls0'].count().plot.bar()
#p.tick_params(labelbottom='off',top='off',bottom='off')
p.tick_params(labelbottom='on',top='off',bottom='off')
fig = p.get_figure()
fig.savefig('tmp/dstport002.png')
In [20]:
pl.figure(figsize=(12, 6))
p = df.groupby('DstPortCls1')['DstPortCls1'].count().plot.bar()
p.tick_params(labelbottom='off',top='off',bottom='off')
fig = p.get_figure()
fig.savefig('tmp/dstport003.png')
In [26]:
pl.figure(figsize=(12, 6))
p = df.groupby('DstPortCls2')['DstPortCls2'].count().plot.bar()
p.tick_params(labelbottom='off',top='off',bottom='off')
fig = p.get_figure()
fig.savefig('tmp/dstport004.png')
In [27]:
pl.figure(figsize=(12, 6))
p = df.groupby('DstPortCls3')['DstPortCls3'].count().plot.bar()
p.tick_params(labelbottom='off',top='off',bottom='off')
fig = p.get_figure()
fig.savefig('tmp/dstport005.png')
In [28]:
pl.figure(figsize=(12, 6))
p = df.groupby('DstPortCls4')['DstPortCls4'].count().plot.bar()
p.tick_params(labelbottom='off',top='off',bottom='off')
fig = p.get_figure()
fig.savefig('tmp/dstport006.png')
In [29]:
pl.figure(figsize=(12, 6))
p = df.groupby('DstPortCls5')['DstPortCls5'].count().plot.bar()
p.tick_params(labelbottom='off',top='off',bottom='off')
fig = p.get_figure()
fig.savefig('tmp/dstport007.png')
In [25]:
df.to_csv("tmp/session_b.csv")
In [ ]: