# Exploring AirWire with Pandas – A Dashboard from Session Histroy

Last week received my internet bill and my wife wondered how much data we are using and if someone was snooping at our wifi?

Assured her, this isn’t the case but her doubt lingered.

Went to the ISP website, downloaded the session data and showed her. Still not convinced, so imported the data into pandas.

And that exploration.. produced the above PDF. A dashboard of information mined from the csv file. My wife loved it.

Here’s the script that will produce this pdf. Will be directly useful to anyone using airwire services and for other’s it’s a good starting point.

```&quot;&quot;&quot;
Script to generate PDF dashboard from airwire session history
Sukhbinder
&quot;&quot;&quot;
from __future__ import division
import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
import datetime
import matplotlib.pyplot as plt
%matplotlib inline

data= data.drop(data.tail(1).index)

def convert2mb(x):
if x[-2:]==&quot;GB&quot;:
x=float(x[:-2])*1024
elif x[-2:]==&quot;KB&quot;:
x=float(x[:-2])/1024.
else:
x=float(x[:-2])
return x

def converttime(x): # to hours
d=x.split(&quot;:&quot;)
x=int(d[0])*24+int(d[1])+int(d[2])/60.0
return x

data[&quot;total&quot;]= data[&quot;total&quot;].apply(convert2mb)
data[&quot;duration&quot;]= data[&quot;duration&quot;].apply(converttime)
data[&quot;date&quot;]=pd.to_datetime(data[&quot;date&quot;], dayfirst=True)
gd = pd.DatetimeIndex(data[&quot;date&quot;], )

matplotlib.rc('figure', figsize=(20, 50))
fig, ax = plt.subplots(11,1)

a=data[[&quot;duration&quot;]].groupby([gd.month]).sum().plot(kind=&quot;bar&quot;,color=[&quot;purple&quot;],title=&quot;Monthly Hours&quot;,ax=ax[1])

d=data[[&quot;duration&quot;]].groupby([gd.week]).sum().plot(kind=&quot;bar&quot;,color=[&quot;lightpink&quot;],title=&quot;Weekly Duration in Hrs&quot;,ax=ax[4])
e=data[[&quot;total&quot;]].groupby([gd.week]).sum().plot(kind=&quot;bar&quot;,color=[&quot;lightpink&quot;],title=&quot;Total Weekly&quot;,ax=ax[5])

labels = [&quot;Sun&quot;,&quot;Mon&quot;,&quot;Tue&quot;,&quot;Wed&quot;,&quot;Thu&quot;,&quot;Fri&quot;,&quot;Sat&quot;]
d=ax[6].set_xticklabels(labels)

c=data[[&quot;duration&quot;]].groupby([gd.month,gd.hour]).sum().cumsum().plot(kind=&quot;bar&quot;,color=[&quot;lightyellow&quot;],ax=ax[9])

c=data[[&quot;duration&quot;]].groupby([gd.month,gd.day]).sum().plot(kind=&quot;bar&quot;,color=[&quot;lightblue&quot;],ax=ax[10])

#print total.columns,total.values[:,0]
ax[0].text(.2,.1,int(total.values[0]),size=40)
ax[0].text(.1,.1,&quot;Hours :&quot;,size=15,color=&quot;lightgrey&quot;)

ax[0].text(.4,.1,int(total.values[1]/1024),size=40)
ax[0].text(.3,.1,&quot;Total (GB) :&quot;,size=15,color=&quot;lightgrey&quot;)

ax[0].text(.64,.1,int(total.values[2]/1024),size=40)

ax[0].text(.8,.65,datetime.datetime.now(),size=12,color=&quot;lightgrey&quot;)
ax[0].text(.02,.8,&quot;AirWire Internet Usage&quot;,size=100,color=&quot;Grey&quot;)
ax[0].axis(&quot;off&quot;)