In [1]:
import matplotlib.pyplot as plt
import numpy as np
# Generate Data
data = np.random.rand(10,6)
rows = list('ZYXWVUTSRQ')
columns = list('ABCDEF')

In [2]:
%matplotlib inline

In [3]:
plt.rc('figure', figsize=(8, 6))

In [4]:
plt.pcolor(data)
plt.xticks(np.arange(0,6)+0.5,columns)
plt.yticks(np.arange(0,10)+0.5,rows)
plt.show()
plt.close()



In [5]:
plt.pcolor(data,cmap=plt.cm.Reds,edgecolors='k')
plt.xticks(np.arange(0,6)+0.5,columns)
plt.yticks(np.arange(0,10)+0.5,rows)
plt.show()
plt.close()



In [6]:
f_data = open('ts_data.txt', 'r').readlines()

In [7]:
import datetime

data_dt = [datetime.datetime.fromtimestamp(float(f_data[i])) for i in range(1, len(f_data))]

In [8]:
import pandas as pd
pd.set_option('display.notebook_repr_html', False)
pd.set_option('display.max_columns', 20)
pd.set_option('display.max_rows', 25)

In [9]:
df = pd.Series(data_dt, index=data_dt)

In [10]:
df


Out[10]:
2015-02-10 20:14:36   2015-02-10 20:14:36
2015-02-10 20:17:01   2015-02-10 20:17:01
2015-02-10 07:23:45   2015-02-10 07:23:45
2015-02-10 19:27:34   2015-02-10 19:27:34
2015-02-10 08:33:33   2015-02-10 08:33:33
2015-02-10 21:40:01   2015-02-10 21:40:01
2015-02-10 09:44:16   2015-02-10 09:44:16
2015-02-10 03:46:50   2015-02-10 03:46:50
2015-02-10 15:53:13   2015-02-10 15:53:13
2015-02-10 05:57:02   2015-02-10 05:57:02
...
2015-02-22 01:34:49   2015-02-22 01:34:49
2015-02-22 18:41:38   2015-02-22 18:41:38
2015-02-22 17:46:33   2015-02-22 17:46:33
2015-02-22 05:48:37   2015-02-22 05:48:37
2015-02-22 22:50:23   2015-02-22 22:50:23
2015-02-22 02:57:55   2015-02-22 02:57:55
2015-02-22 23:05:58   2015-02-22 23:05:58
2015-02-22 12:07:48   2015-02-22 12:07:48
2015-02-22 22:11:55   2015-02-22 22:11:55
2015-02-22 14:17:04   2015-02-22 14:17:04
2015-02-22 11:20:02   2015-02-22 11:20:02
Length: 33275

In [11]:
a = df.groupby([df.index.day, df.index.hour]).count()
a


Out[11]:
10  0    162
    1    177
    2    171
    3    162
    4    153
    5    157
    6    160
    7    154
    8    154
    9    162
...
22  13    136
    14    115
    15    145
    16    142
    17    129
    18    121
    19    137
    20    141
    21    145
    22    136
    23    124
Length: 312, dtype: int64

In [12]:
df.groupby([df.index.hour]).count().plot()


Out[12]:
<matplotlib.axes._subplots.AxesSubplot at 0x10cdb0890>

In [13]:
x_data = pd.DataFrame(a)
x_data.reset_index(inplace=True)
x_data.columns= ['Day', 'Hour', 'Count']

In [14]:
p_data = x_data.pivot(index='Hour', columns='Day', values='Count')

n_data = pd.DataFrame(p_data, columns=range(11, 21), index=range(0,23))

In [15]:
p_data


Out[15]:
Day    10  11  12   13   14  15   16  17   18   19   20   21   22
Hour                                                             
0     162  70  19   82  127  59  145  55  130  103  163  136  122
1     177  63  15  102  125  61  137  48  117   88  155  162  133
2     171  76  21   83  131  66  125  44  114   98  152  142  149
3     162  72  17   81  109  53  150  47  120   90  144  153  130
4     153  81  20   90  114  57  151  47  137   77  143  169  141
5     157  66  21   90  106  55  158  40  141   82  165  155  123
6     160  66  10   96  129  53  153  39  131   87  166  167  127
7     154  72  27   82  130  52  163  40  133   85  156  159  144
8     154  43  17   87  117  67  146  56  125   97  157  174  137
9     162  70  18   93  103  61  124  52  142   72  160  157  129
10    165  80  19   96  124  59  135  52  140   91  160  168  151
11    158  61  23   86  130  66  144  62  121   78  155  171  159
12    164  79  18   83  129  65  146  56  144   91  136  148  140
13    188  68  16   74  142  72  148  53  143   90  157  156  136
14    157  61  18   88  131  67  137  60  111   87  170  164  115
15    199  70  26   93  116  71  146  55  105  100  154  150  145
16    132  80  15   84  113  61  152  46  135   96  137  161  142
17    147  68  17  112  137  60  150  63  132   78  146  142  129
18    167  51  24   82  130  53  151  40  127  101  148  173  121
19    176  63  20   97  121  64  128  48  122   90  136  181  137
20    172  57  24   88  125  61  158  41  128   97  155  158  141
21    170  59  24  109  108  60  130  58  127   94  139  162  145
22    147  78  19   92   94  43  155  56  118   83  147  204  136
23    165  48  17   92  135  62  165  58  156   89  151  177  124

In [16]:
plt.pcolor(n_data, cmap=plt.cm.Reds,edgecolors='k')
plt.yticks(np.arange(0.5, len(n_data.index), 1), n_data.index)
plt.xticks(np.arange(0.5, len(n_data.columns), 1), n_data.columns)
plt.show()