In [2]:
import plotly.plotly as py
import cufflinks as cf
import pandas as pd
import json

with open("/Users/chunqingxu/.plotly/.credentials", 'rb') as fi:
    cred= json.load(fi, encoding='utf-8')
myapi = cred['api_key']
username = cred['username']
py.sign_in(username, myapi)

In [13]:
df = pd.read_csv("/Users/chunqingxu/Downloads/jan_hour.csv.csv")

In [33]:
for line in df.line.unique():
    tmp = df[df.line == line]['count'].values
    if len(tmp) != 24:
        print line
    else:
        d.loc[:,line] = tmp


C
G
GS
S

In [43]:
df[df.line == "C"]


Out[43]:
line hour count
192 C 6 215
193 C 7 255
194 C 8 270
195 C 9 416
196 C 10 418
197 C 11 488
198 C 12 482
199 C 13 566
200 C 14 459
201 C 15 520
202 C 16 424
203 C 17 423
204 C 18 556
205 C 19 461
206 C 20 424
207 C 21 409
208 C 22 351
209 C 23 322

In [44]:
df[df.line == "G"] ##6


Out[44]:
line hour count
282 G 0 14
283 G 1 13
284 G 2 8
285 G 3 6
286 G 4 4
287 G 5 3
288 G 7 4
289 G 8 3
290 G 9 3
291 G 10 4
292 G 11 2
293 G 12 4
294 G 13 1
295 G 14 5
296 G 15 3
297 G 16 1
298 G 17 4
299 G 18 2
300 G 19 7
301 G 20 3
302 G 21 4
303 G 22 3
304 G 23 4

In [45]:
df[df.line == "GS"] ## 34


Out[45]:
line hour count
305 GS 0 11
306 GS 1 5
307 GS 2 4
308 GS 5 1
309 GS 6 3
310 GS 7 3
311 GS 8 10
312 GS 9 16
313 GS 10 6
314 GS 11 21
315 GS 12 10
316 GS 13 10
317 GS 14 16
318 GS 15 11
319 GS 16 11
320 GS 17 6
321 GS 18 5
322 GS 19 8
323 GS 20 6
324 GS 21 6
325 GS 22 8
326 GS 23 14

In [65]:
df[df.line == "S"]['count'].values


Out[65]:
array([1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1, 5, 2, 1, 2, 2, 4, 2])

In [66]:
counts = [1, 2, 1,0, 1, 2, 0,1, 1, 0,1, 2, 1, 1,0, 5, 0,2, 1, 2,0, 2, 4, 2]

In [67]:
d.loc[:,'S'] = counts

In [46]:
df[df.line == "S"] ## 3 6 9 14 16 20


Out[46]:
line hour count
471 S 0 1
472 S 1 2
473 S 2 1
474 S 4 1
475 S 5 2
476 S 7 1
477 S 8 1
478 S 10 1
479 S 11 2
480 S 12 1
481 S 13 1
482 S 15 5
483 S 17 2
484 S 18 1
485 S 19 2
486 S 21 2
487 S 22 4
488 S 23 2

In [56]:
df[df.line == "GS"]['count'].values


Out[56]:
array([11,  5,  4,  1,  3,  3, 10, 16,  6, 21, 10, 10, 16, 11, 11,  6,  5,
        8,  6,  6,  8, 14])

In [61]:
counts = [11, 5, 4, 0, 0, 1, 3, 3, 10, 16, 6, 21, 10, 10, 16, 11, 11, 6, 5,
        8, 6, 6,8, 14]

In [63]:
d["GS"] = counts

In [38]:
d.loc[6:,'C'] = df[df.line == 'C']['count'].values

In [69]:
df[df.line == "G"]['count'].values


Out[69]:
array([14, 13,  8,  6,  4,  3,  4,  3,  3,  4,  2,  4,  1,  5,  3,  1,  4,
        2,  7,  3,  4,  3,  4])

In [70]:
counts = [14, 13,  8,  6,  4,  3, 0, 4,  3,  3,  4,  2,  4,  1,  5,  3,  1,  4,
        2,  7,  3,  4,  3,  4]

In [73]:
d2 = d

In [75]:
d2.loc[:5,'C'] = [0, 0, 0, 0, 0, 0]

In [76]:
d2


Out[76]:
1 2 3 4 5 6 7 A C D ... G GS J L M N Q R S Z
0 241 67 68 46 39 171 25 188 0 105 ... 14 11 44 60 191 209 181 219 1 32
1 195 63 58 24 19 111 29 127 0 73 ... 13 5 30 101 148 133 109 149 2 20
2 134 39 39 22 16 87 27 113 0 55 ... 8 4 34 60 92 98 84 109 1 20
3 86 36 35 9 5 51 19 83 0 31 ... 6 0 17 71 83 72 60 95 0 14
4 81 36 36 7 6 46 15 84 0 33 ... 4 0 17 50 63 58 57 59 1 15
5 96 42 41 18 17 68 11 59 0 52 ... 3 1 2 29 91 52 47 61 2 2
6 177 56 57 22 22 187 22 120 215 60 ... 0 3 6 38 132 104 87 123 0 5
7 190 70 70 24 19 197 54 156 255 74 ... 4 3 6 43 143 118 86 137 1 2
8 264 61 63 60 52 281 46 157 270 78 ... 3 10 9 37 169 148 112 175 1 8
9 338 73 73 64 48 313 50 220 416 159 ... 3 16 13 52 250 205 159 232 0 11
10 336 71 74 80 59 390 43 191 418 176 ... 4 6 7 61 264 194 132 250 1 7
11 396 99 97 96 79 441 62 248 488 220 ... 2 21 15 61 324 294 230 333 2 15
12 431 99 98 73 59 419 52 237 482 212 ... 4 10 18 67 321 317 242 366 1 18
13 363 67 67 96 83 373 48 262 566 243 ... 1 10 24 55 345 336 242 399 1 24
14 449 88 86 96 85 392 44 218 459 224 ... 5 16 17 72 337 382 283 434 0 17
15 400 74 73 84 74 366 44 260 520 213 ... 3 11 19 62 286 367 282 428 5 17
16 381 68 66 80 74 331 29 225 424 199 ... 1 11 13 44 287 331 253 365 0 13
17 410 72 72 60 50 384 31 201 423 168 ... 4 6 16 85 281 317 228 351 2 16
18 502 90 89 68 57 416 24 252 556 217 ... 2 5 12 97 323 390 306 435 1 10
19 490 99 100 60 52 362 23 229 461 186 ... 7 8 16 81 284 378 287 405 2 13
20 376 78 77 46 39 309 18 220 424 147 ... 3 6 21 76 226 311 236 337 0 21
21 358 84 86 44 41 283 30 206 409 141 ... 4 6 26 66 241 307 221 333 2 21
22 356 84 83 33 30 243 31 174 351 100 ... 3 8 17 70 194 272 209 299 4 14
23 288 70 70 37 35 243 22 191 322 124 ... 4 14 23 69 207 208 167 240 2 16

24 rows × 22 columns


In [71]:
d["G"] = counts

In [78]:
d = d2
d


Out[78]:
1 2 3 4 5 6 7 A C D ... G GS J L M N Q R S Z
0 241 67 68 46 39 171 25 188 0 105 ... 14 11 44 60 191 209 181 219 1 32
1 195 63 58 24 19 111 29 127 0 73 ... 13 5 30 101 148 133 109 149 2 20
2 134 39 39 22 16 87 27 113 0 55 ... 8 4 34 60 92 98 84 109 1 20
3 86 36 35 9 5 51 19 83 0 31 ... 6 0 17 71 83 72 60 95 0 14
4 81 36 36 7 6 46 15 84 0 33 ... 4 0 17 50 63 58 57 59 1 15
5 96 42 41 18 17 68 11 59 0 52 ... 3 1 2 29 91 52 47 61 2 2
6 177 56 57 22 22 187 22 120 215 60 ... 0 3 6 38 132 104 87 123 0 5
7 190 70 70 24 19 197 54 156 255 74 ... 4 3 6 43 143 118 86 137 1 2
8 264 61 63 60 52 281 46 157 270 78 ... 3 10 9 37 169 148 112 175 1 8
9 338 73 73 64 48 313 50 220 416 159 ... 3 16 13 52 250 205 159 232 0 11
10 336 71 74 80 59 390 43 191 418 176 ... 4 6 7 61 264 194 132 250 1 7
11 396 99 97 96 79 441 62 248 488 220 ... 2 21 15 61 324 294 230 333 2 15
12 431 99 98 73 59 419 52 237 482 212 ... 4 10 18 67 321 317 242 366 1 18
13 363 67 67 96 83 373 48 262 566 243 ... 1 10 24 55 345 336 242 399 1 24
14 449 88 86 96 85 392 44 218 459 224 ... 5 16 17 72 337 382 283 434 0 17
15 400 74 73 84 74 366 44 260 520 213 ... 3 11 19 62 286 367 282 428 5 17
16 381 68 66 80 74 331 29 225 424 199 ... 1 11 13 44 287 331 253 365 0 13
17 410 72 72 60 50 384 31 201 423 168 ... 4 6 16 85 281 317 228 351 2 16
18 502 90 89 68 57 416 24 252 556 217 ... 2 5 12 97 323 390 306 435 1 10
19 490 99 100 60 52 362 23 229 461 186 ... 7 8 16 81 284 378 287 405 2 13
20 376 78 77 46 39 309 18 220 424 147 ... 3 6 21 76 226 311 236 337 0 21
21 358 84 86 44 41 283 30 206 409 141 ... 4 6 26 66 241 307 221 333 2 21
22 356 84 83 33 30 243 31 174 351 100 ... 3 8 17 70 194 272 209 299 4 14
23 288 70 70 37 35 243 22 191 322 124 ... 4 14 23 69 207 208 167 240 2 16

24 rows × 22 columns


In [18]:
d = pd.DataFrame(index=range(24),columns=df.line.unique())

In [23]:
df.columns


Out[23]:
Index([u'line', u'hour', u'count'], dtype='object')

In [ ]:


In [81]:
df = d.copy()

In [84]:
figure = df.iplot(kind='scatter', asFigure=True, )
# print figure.to_string()

In [87]:
df.iplot?

In [92]:
figure['data'][1]


Out[92]:
{'line': {'color': 'rgba(55, 128, 191, 1.0)', 'dash': 'solid', 'width': 1.3},
 'mode': 'lines',
 'name': 'Trace 1',
 'text': '',
 'type': 'scatter',
 'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
        17, 18, 19, 20, 21, 22, 23]),
 'y': array([67, 63, 39, 36, 36, 42, 56, 70, 61, 73, 71, 99, 99, 67, 88, 74, 68,
        72, 90, 99, 78, 84, 84, 70])}

In [94]:
df.iplot?

In [95]:
figure


Out[95]:
{'data': [{'line': {'color': 'rgba(255, 153, 51, 1.0)',
    'dash': 'solid',
    'width': 1.3},
   'mode': 'lines',
   'name': '1',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([241, 195, 134,  86,  81,  96, 177, 190, 264, 338, 336, 396, 431,
          363, 449, 400, 381, 410, 502, 490, 376, 358, 356, 288])},
  {'line': {'color': 'rgba(55, 128, 191, 1.0)', 'dash': 'solid', 'width': 1.3},
   'mode': 'lines',
   'name': '2',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([67, 63, 39, 36, 36, 42, 56, 70, 61, 73, 71, 99, 99, 67, 88, 74, 68,
          72, 90, 99, 78, 84, 84, 70])},
  {'line': {'color': 'rgba(50, 171, 96, 1.0)', 'dash': 'solid', 'width': 1.3},
   'mode': 'lines',
   'name': '3',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([ 68,  58,  39,  35,  36,  41,  57,  70,  63,  73,  74,  97,  98,
           67,  86,  73,  66,  72,  89, 100,  77,  86,  83,  70])},
  {'line': {'color': 'rgba(128, 0, 128, 1.0)', 'dash': 'solid', 'width': 1.3},
   'mode': 'lines',
   'name': '4',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([46, 24, 22,  9,  7, 18, 22, 24, 60, 64, 80, 96, 73, 96, 96, 84, 80,
          60, 68, 60, 46, 44, 33, 37])},
  {'line': {'color': 'rgba(219, 64, 82, 1.0)', 'dash': 'solid', 'width': 1.3},
   'mode': 'lines',
   'name': '5',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([39, 19, 16,  5,  6, 17, 22, 19, 52, 48, 59, 79, 59, 83, 85, 74, 74,
          50, 57, 52, 39, 41, 30, 35])},
  {'line': {'color': 'rgba(0, 128, 128, 1.0)', 'dash': 'solid', 'width': 1.3},
   'mode': 'lines',
   'name': '6',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([171, 111,  87,  51,  46,  68, 187, 197, 281, 313, 390, 441, 419,
          373, 392, 366, 331, 384, 416, 362, 309, 283, 243, 243])},
  {'line': {'color': 'rgba(255, 255, 51, 1.0)', 'dash': 'solid', 'width': 1.3},
   'mode': 'lines',
   'name': '7',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([25, 29, 27, 19, 15, 11, 22, 54, 46, 50, 43, 62, 52, 48, 44, 44, 29,
          31, 24, 23, 18, 30, 31, 22])},
  {'line': {'color': 'rgba(128, 128, 0, 1.0)', 'dash': 'solid', 'width': 1.3},
   'mode': 'lines',
   'name': 'A',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([188, 127, 113,  83,  84,  59, 120, 156, 157, 220, 191, 248, 237,
          262, 218, 260, 225, 201, 252, 229, 220, 206, 174, 191])},
  {'line': {'color': 'rgba(251, 128, 114, 1.0)',
    'dash': 'solid',
    'width': 1.3},
   'mode': 'lines',
   'name': 'C',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([  0,   0,   0,   0,   0,   0, 215, 255, 270, 416, 418, 488, 482,
          566, 459, 520, 424, 423, 556, 461, 424, 409, 351, 322])},
  {'line': {'color': 'rgba(128, 177, 211, 1.0)',
    'dash': 'solid',
    'width': 1.3},
   'mode': 'lines',
   'name': 'D',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([105,  73,  55,  31,  33,  52,  60,  74,  78, 159, 176, 220, 212,
          243, 224, 213, 199, 168, 217, 186, 147, 141, 100, 124])},
  {'line': {'color': 'rgba(128, 177, 211, 0.89999999999999991)',
    'dash': 'solid',
    'width': 1.3},
   'mode': 'lines',
   'name': 'E',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([246, 173, 137,  85,  78, 105, 180, 206, 221, 320, 304, 334, 343,
          414, 320, 317, 324, 339, 452, 393, 352, 343, 296, 265])},
  {'line': {'color': 'rgba(255, 153, 51, 0.89999999999999991)',
    'dash': 'solid',
    'width': 1.3},
   'mode': 'lines',
   'name': 'F',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([186, 157,  91,  73,  61,  93, 137, 167, 181, 299, 294, 359, 359,
          389, 394, 336, 325, 299, 358, 306, 252, 259, 218, 230])},
  {'line': {'color': 'rgba(55, 128, 191, 0.89999999999999991)',
    'dash': 'solid',
    'width': 1.3},
   'mode': 'lines',
   'name': 'G',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([14, 13,  8,  6,  4,  3,  0,  4,  3,  3,  4,  2,  4,  1,  5,  3,  1,
           4,  2,  7,  3,  4,  3,  4])},
  {'line': {'color': 'rgba(50, 171, 96, 0.89999999999999991)',
    'dash': 'solid',
    'width': 1.3},
   'mode': 'lines',
   'name': 'GS',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([11,  5,  4,  0,  0,  1,  3,  3, 10, 16,  6, 21, 10, 10, 16, 11, 11,
           6,  5,  8,  6,  6,  8, 14])},
  {'line': {'color': 'rgba(128, 0, 128, 0.89999999999999991)',
    'dash': 'solid',
    'width': 1.3},
   'mode': 'lines',
   'name': 'J',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([44, 30, 34, 17, 17,  2,  6,  6,  9, 13,  7, 15, 18, 24, 17, 19, 13,
          16, 12, 16, 21, 26, 17, 23])},
  {'line': {'color': 'rgba(219, 64, 82, 0.89999999999999991)',
    'dash': 'solid',
    'width': 1.3},
   'mode': 'lines',
   'name': 'L',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([ 60, 101,  60,  71,  50,  29,  38,  43,  37,  52,  61,  61,  67,
           55,  72,  62,  44,  85,  97,  81,  76,  66,  70,  69])},
  {'line': {'color': 'rgba(0, 128, 128, 0.89999999999999991)',
    'dash': 'solid',
    'width': 1.3},
   'mode': 'lines',
   'name': 'M',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([191, 148,  92,  83,  63,  91, 132, 143, 169, 250, 264, 324, 321,
          345, 337, 286, 287, 281, 323, 284, 226, 241, 194, 207])},
  {'line': {'color': 'rgba(255, 255, 51, 0.89999999999999991)',
    'dash': 'solid',
    'width': 1.3},
   'mode': 'lines',
   'name': 'N',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([209, 133,  98,  72,  58,  52, 104, 118, 148, 205, 194, 294, 317,
          336, 382, 367, 331, 317, 390, 378, 311, 307, 272, 208])},
  {'line': {'color': 'rgba(128, 128, 0, 0.89999999999999991)',
    'dash': 'solid',
    'width': 1.3},
   'mode': 'lines',
   'name': 'Q',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([181, 109,  84,  60,  57,  47,  87,  86, 112, 159, 132, 230, 242,
          242, 283, 282, 253, 228, 306, 287, 236, 221, 209, 167])},
  {'line': {'color': 'rgba(251, 128, 114, 0.89999999999999991)',
    'dash': 'solid',
    'width': 1.3},
   'mode': 'lines',
   'name': 'R',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([219, 149, 109,  95,  59,  61, 123, 137, 175, 232, 250, 333, 366,
          399, 434, 428, 365, 351, 435, 405, 337, 333, 299, 240])},
  {'line': {'color': 'rgba(251, 128, 114, 0.79999999999999982)',
    'dash': 'solid',
    'width': 1.3},
   'mode': 'lines',
   'name': 'S',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([1, 2, 1, 0, 1, 2, 0, 1, 1, 0, 1, 2, 1, 1, 0, 5, 0, 2, 1, 2, 0, 2, 4,
          2])},
  {'line': {'color': 'rgba(128, 177, 211, 0.79999999999999982)',
    'dash': 'solid',
    'width': 1.3},
   'mode': 'lines',
   'name': 'Z',
   'text': '',
   'type': 'scatter',
   'x': array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
          17, 18, 19, 20, 21, 22, 23]),
   'y': array([32, 20, 20, 14, 15,  2,  5,  2,  8, 11,  7, 15, 18, 24, 17, 17, 13,
          16, 10, 13, 21, 21, 14, 16])}],
 'layout': {'legend': {'bgcolor': '#F5F6F9', 'font': {'color': '#4D5663'}},
  'paper_bgcolor': '#F5F6F9',
  'plot_bgcolor': '#F5F6F9',
  'titlefont': {'color': '#4D5663'},
  'xaxis1': {'gridcolor': '#E1E5ED',
   'showgrid': True,
   'tickfont': {'color': '#4D5663'},
   'title': '',
   'titlefont': {'color': '#4D5663'},
   'zerolinecolor': '#E1E5ED'},
  'yaxis1': {'gridcolor': '#E1E5ED',
   'showgrid': True,
   'tickfont': {'color': '#4D5663'},
   'tickprefix': '$',
   'title': 'Price',
   'titlefont': {'color': '#4D5663'},
   'zerolinecolor': '#E1E5ED'}}}

In [111]:
#df=cf.datagen.lines(3,columns=['a','b','c'])
figure['layout']['yaxis1'].update({'title': 'Counts', 'tickprefix': ''})
figure['layout']['xaxis1'].update({'title': 'Hours', 'tickprefix': ''})
figure['layout']['title'] = 'How many people prefer yellow cab than subway?     by hour,  Jan 2016'

for i, trace in enumerate(figure['data']):
    trace['name'] = '{}'.format(d.columns.values[i])
    
py.iplot(figure)


Out[111]: