In [51]:
import pandas as pd
import matplotlib.pyplot as plt
%pylab inline
%cd "C:\Users\eshatiw\Documents\IPython Notebooks\a"


Populating the interactive namespace from numpy and matplotlib
C:\Users\eshatiw\Documents\IPython Notebooks\a

In [52]:
headers = ["year", "visitors"]
v = pd.read_csv("visitors.csv", skiprows = 5, names = headers)
v.head()


Out[52]:
year visitors
0 2015-02-09 59
1 2015-02-08 79
2 2015-02-07 73
3 2015-02-06 89
4 2015-02-05 80

In [53]:
headers2 = ["year", "visitors_new"]
v1 = pd.read_csv("visitors-new.csv", skiprows = 5, names = headers2)
v1.head()


Out[53]:
year visitors_new
0 2015-02-09 55
1 2015-02-08 64
2 2015-02-07 61
3 2015-02-06 79
4 2015-02-05 60

In [54]:
headers3 = ["year", "visitors_uni"]
v2 = pd.read_csv("visitors-unique.csv", skiprows = 5, names = headers3)
v2.head()


Out[54]:
year visitors_uni
0 2015-02-09 59
1 2015-02-08 72
2 2015-02-07 67
3 2015-02-06 84
4 2015-02-05 71

In [55]:
comb1 = pd.merge(v, v1)
comb1.head()


Out[55]:
year visitors visitors_new
0 2015-02-09 59 55
1 2015-02-08 79 64
2 2015-02-07 73 61
3 2015-02-06 89 79
4 2015-02-05 80 60

In [56]:
comb = pd.merge(comb1, v2)
comb.head()


Out[56]:
year visitors visitors_new visitors_uni
0 2015-02-09 59 55 59
1 2015-02-08 79 64 72
2 2015-02-07 73 61 67
3 2015-02-06 89 79 84
4 2015-02-05 80 60 71

In [57]:
comb.sort(['year'], inplace=True)
comb.head()


Out[57]:
year visitors visitors_new visitors_uni
210 2014-07-14 5 4 4
209 2014-07-15 58 55 55
208 2014-07-16 18 15 18
207 2014-07-17 14 10 13
206 2014-07-18 11 9 11

In [58]:
comb.set_index(['year'], inplace=True)
comb.head()


Out[58]:
visitors visitors_new visitors_uni
year
2014-07-14 5 4 4
2014-07-15 58 55 55
2014-07-16 18 15 18
2014-07-17 14 10 13
2014-07-18 11 9 11

In [59]:
comb.plot()
plt.show()



In [62]:
#pd.to_datetime(comb.index) > pd.to_datetime('2014-11-1')
comb_new = comb[pd.to_datetime(comb.index) > pd.to_datetime('2014-11-1')]
comb_new.head()


Out[62]:
visitors visitors_new visitors_uni
year
2014-11-02 6 3 6
2014-11-03 15 11 13
2014-11-04 11 9 11
2014-11-05 23 18 20
2014-11-06 20 13 18

In [64]:
comb_new.plot()
plt.show()



In [60]: