%matplotlib inline
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
inst = pd.read_csv('instructors.csv', names=['date','cumulative instructors trained'], parse_dates=['date'])
work = pd.read_csv('workshops.csv', names=['date', 'cumulative workshops run'], parse_dates=['date'])
lern = pd.read_csv('learners.csv', names=['date','cumulative learners reached'], parse_dates=['date'])
full = pd.merge(work, lern, on='date')
full['learners reached'] = full['cumulative learners reached'].diff().fillna(full['cumulative learners reached'])
full['workshops run'] = full['cumulative workshops run'].diff().fillna(full['cumulative workshops run'])
full['workshop size'] = full['learners reached']/full['workshops run']
full['date_int'] = full.date.astype(np.int64)
full
date | cumulative workshops run | cumulative learners reached | learners reached | workshops run | workshop size | date_int | |
---|---|---|---|---|---|---|---|
0 | 2011-11-07 | 1 | 22 | 22 | 1 | 22.000000 | 1320624000000000000 |
1 | 2012-01-18 | 2 | 36 | 14 | 1 | 14.000000 | 1326844800000000000 |
2 | 2012-02-20 | 3 | 86 | 50 | 1 | 50.000000 | 1329696000000000000 |
3 | 2012-02-23 | 4 | 114 | 28 | 1 | 28.000000 | 1329955200000000000 |
4 | 2012-03-07 | 5 | 153 | 39 | 1 | 39.000000 | 1331078400000000000 |
5 | 2012-03-26 | 6 | 191 | 38 | 1 | 38.000000 | 1332720000000000000 |
6 | 2012-03-28 | 7 | 226 | 35 | 1 | 35.000000 | 1332892800000000000 |
7 | 2012-04-02 | 8 | 261 | 35 | 1 | 35.000000 | 1333324800000000000 |
8 | 2012-04-14 | 9 | 293 | 32 | 1 | 32.000000 | 1334361600000000000 |
9 | 2012-04-15 | 10 | 302 | 9 | 1 | 9.000000 | 1334448000000000000 |
10 | 2012-04-30 | 11 | 346 | 44 | 1 | 44.000000 | 1335744000000000000 |
11 | 2012-05-07 | 12 | 401 | 55 | 1 | 55.000000 | 1336348800000000000 |
12 | 2012-05-14 | 13 | 442 | 41 | 1 | 41.000000 | 1336953600000000000 |
13 | 2012-05-16 | 14 | 480 | 38 | 1 | 38.000000 | 1337126400000000000 |
14 | 2012-05-22 | 15 | 519 | 39 | 1 | 39.000000 | 1337644800000000000 |
15 | 2012-06-18 | 16 | 539 | 20 | 1 | 20.000000 | 1339977600000000000 |
16 | 2012-06-28 | 17 | 567 | 28 | 1 | 28.000000 | 1340841600000000000 |
17 | 2012-07-09 | 18 | 603 | 36 | 1 | 36.000000 | 1341792000000000000 |
18 | 2012-07-10 | 19 | 627 | 24 | 1 | 24.000000 | 1341878400000000000 |
19 | 2012-07-12 | 20 | 667 | 40 | 1 | 40.000000 | 1342051200000000000 |
20 | 2012-07-16 | 21 | 707 | 40 | 1 | 40.000000 | 1342396800000000000 |
21 | 2012-07-19 | 22 | 746 | 39 | 1 | 39.000000 | 1342656000000000000 |
22 | 2012-08-26 | 23 | 766 | 20 | 1 | 20.000000 | 1345939200000000000 |
23 | 2012-09-13 | 24 | 799 | 33 | 1 | 33.000000 | 1347494400000000000 |
24 | 2012-09-17 | 25 | 833 | 34 | 1 | 34.000000 | 1347840000000000000 |
25 | 2012-09-28 | 26 | 872 | 39 | 1 | 39.000000 | 1348790400000000000 |
26 | 2012-10-08 | 27 | 914 | 42 | 1 | 42.000000 | 1349654400000000000 |
27 | 2012-10-11 | 28 | 939 | 25 | 1 | 25.000000 | 1349913600000000000 |
28 | 2012-10-17 | 29 | 979 | 40 | 1 | 40.000000 | 1350432000000000000 |
29 | 2012-10-18 | 30 | 1041 | 62 | 1 | 62.000000 | 1350518400000000000 |
... | ... | ... | ... | ... | ... | ... | ... |
331 | 2015-08-17 | 450 | 14926 | 44 | 1 | 44.000000 | 1439769600000000000 |
332 | 2015-08-20 | 454 | 15017 | 91 | 4 | 22.750000 | 1440028800000000000 |
333 | 2015-08-21 | 455 | 15063 | 46 | 1 | 46.000000 | 1440115200000000000 |
334 | 2015-08-24 | 459 | 15184 | 121 | 4 | 30.250000 | 1440374400000000000 |
335 | 2015-08-26 | 462 | 15258 | 74 | 3 | 24.666667 | 1440547200000000000 |
336 | 2015-08-27 | 464 | 15318 | 60 | 2 | 30.000000 | 1440633600000000000 |
337 | 2015-09-03 | 465 | 15355 | 37 | 1 | 37.000000 | 1441238400000000000 |
338 | 2015-09-06 | 466 | 15380 | 25 | 1 | 25.000000 | 1441497600000000000 |
339 | 2015-09-07 | 468 | 15409 | 29 | 2 | 14.500000 | 1441584000000000000 |
340 | 2015-09-08 | 470 | 15435 | 26 | 2 | 13.000000 | 1441670400000000000 |
341 | 2015-09-10 | 474 | 15585 | 150 | 4 | 37.500000 | 1441843200000000000 |
342 | 2015-09-14 | 475 | 15603 | 18 | 1 | 18.000000 | 1442188800000000000 |
343 | 2015-09-15 | 477 | 15650 | 47 | 2 | 23.500000 | 1442275200000000000 |
344 | 2015-09-17 | 480 | 15713 | 63 | 3 | 21.000000 | 1442448000000000000 |
345 | 2015-09-19 | 481 | 15788 | 75 | 1 | 75.000000 | 1442620800000000000 |
346 | 2015-09-22 | 482 | 15799 | 11 | 1 | 11.000000 | 1442880000000000000 |
347 | 2015-09-23 | 483 | 15800 | 1 | 1 | 1.000000 | 1442966400000000000 |
348 | 2015-09-24 | 485 | 15843 | 43 | 2 | 21.500000 | 1443052800000000000 |
349 | 2015-09-26 | 486 | 15918 | 75 | 1 | 75.000000 | 1443225600000000000 |
350 | 2015-09-28 | 490 | 16021 | 103 | 4 | 25.750000 | 1443398400000000000 |
351 | 2015-10-01 | 492 | 16021 | 0 | 2 | 0.000000 | 1443657600000000000 |
352 | 2015-10-03 | 495 | 16025 | 4 | 3 | 1.333333 | 1443830400000000000 |
353 | 2015-10-05 | 496 | 16062 | 37 | 1 | 37.000000 | 1444003200000000000 |
354 | 2015-10-06 | 497 | 16074 | 12 | 1 | 12.000000 | 1444089600000000000 |
355 | 2015-10-07 | 498 | 16074 | 0 | 1 | 0.000000 | 1444176000000000000 |
356 | 2015-10-12 | 500 | 16092 | 18 | 2 | 9.000000 | 1444608000000000000 |
357 | 2015-10-17 | 503 | 16130 | 38 | 3 | 12.666667 | 1445040000000000000 |
358 | 2015-10-19 | 507 | 16130 | 0 | 4 | 0.000000 | 1445212800000000000 |
359 | 2015-10-21 | 508 | 16130 | 0 | 1 | 0.000000 | 1445385600000000000 |
360 | 2015-10-22 | 509 | 16130 | 0 | 1 | 0.000000 | 1445472000000000000 |
361 rows × 7 columns
ax1 = lern.plot(x='date', figsize=(10.0,10.0), title="Software Carpentry Growth", kind='area', stacked=False, alpha=0.5, color='g')
ax2 = ax1.twinx()
ax2 = work.plot(x='date', color='r', ax=ax2, kind='area', stacked=False, alpha=0.5)
ax2.legend(loc=0)
ax1.legend(loc = (0.05,0.9))
ax2.legend(loc = (0.5,0.9))
for tl in ax1.get_yticklabels():
tl.set_color('g')
for tl in ax2.get_yticklabels():
tl.set_color('r')
ax1 = inst.plot(x='date', figsize=(10.0,10.0), title="Software Carpentry Growth", kind='area', stacked=False, alpha=0.5, color='b')
ax1 = inst.plot(x='date', figsize=(10.0,10.0), title="Software Carpentry Growth", kind='area', stacked=False, alpha=0.5, color='b')
ax2 = ax1.twinx()
ax2 = work.plot(x='date', color='r', ax=ax2, kind='area', stacked=False, alpha=0.5)
ax2.legend(loc=0)
ax1.legend(loc = (0.05,0.9))
ax2.legend(loc = (0.5,0.9))
for tl in ax1.get_yticklabels():
tl.set_color('g')
for tl in ax2.get_yticklabels():
tl.set_color('r')
# Workshops and learners, discrete
#ax1 = full.plot(x='date', y='learners reached', figsize=(10.0,10.0), title="Software Carpentry Growth")
ax1 = full.plot(x='date', y='workshop size', figsize=(10.0,10.0), title="Software Carpentry Growth", kind='area', stacked=False, alpha=0.2)
ax2 = ax1.twinx()
ax2 = full.plot(x='date', y='workshops run', color='r', ax=ax2, ylim=(0.0,100.0), kind='area', stacked=False, alpha=0.5)
#ax2 = full.plot(x='date', y='workshop size', color='g', ax=ax2, ylim=(0.0,100.0))
ax2.legend(loc=0)
ax1.legend(loc = (0.05,0.95))
ax2.legend(loc = (0.7,0.95))
for tl in ax1.get_yticklabels():
tl.set_color('b')
for tl in ax2.get_yticklabels():
tl.set_color('r')
pd.to_datetime(full['date'][:]).month
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-306-f42cb359c9b8> in <module>() ----> 1 pd.to_datetime(full['date'][:]).month /Users/khuff/anaconda/lib/python2.7/site-packages/pandas/core/generic.pyc in __getattr__(self, name) 2148 return self[name] 2149 raise AttributeError("'%s' object has no attribute '%s'" % -> 2150 (type(self).__name__, name)) 2151 2152 def __setattr__(self, name, value): AttributeError: 'Series' object has no attribute 'month'
# Workshops and learners, discrete
#ax1 = full.plot(x='date', y='learners reached', figsize=(10.0,10.0), title="Software Carpentry Growth")
ax1.clear()
ax1 = full.plot(kind='scatter',x='date_int',y='workshops run', s=full['workshop size']*10, figsize=(5.0,5.0), title="Software Carpentry Workshop Sizes", alpha=0.2)
ax1.legend(loc = (0.05,0.95))
for tl in ax1.get_yticklabels():
tl.set_color('b')
ax1 = inst.plot(x='date')
ax2 = ax1.twinx()
ax2 = work.plot(x='date', color='g', ax=ax2)
ax1.legend(loc = (0.05,0.85))
ax2.legend(loc = (0.05,0.7))
for tl in ax1.get_yticklabels():
tl.set_color('b')
for t2 in ax2.get_yticklabels():
t2.set_color('g')
full
date | cumulative workshops run | cumulative learners reached | learners reached | workshops run | workshop size | date_int | |
---|---|---|---|---|---|---|---|
0 | 2011-11-07 | 1 | 22 | 22 | 1 | 22.000000 | 1320624000000000000 |
1 | 2012-01-18 | 2 | 36 | 14 | 1 | 14.000000 | 1326844800000000000 |
2 | 2012-02-20 | 3 | 86 | 50 | 1 | 50.000000 | 1329696000000000000 |
3 | 2012-02-23 | 4 | 114 | 28 | 1 | 28.000000 | 1329955200000000000 |
4 | 2012-03-07 | 5 | 153 | 39 | 1 | 39.000000 | 1331078400000000000 |
5 | 2012-03-26 | 6 | 191 | 38 | 1 | 38.000000 | 1332720000000000000 |
6 | 2012-03-28 | 7 | 226 | 35 | 1 | 35.000000 | 1332892800000000000 |
7 | 2012-04-02 | 8 | 261 | 35 | 1 | 35.000000 | 1333324800000000000 |
8 | 2012-04-14 | 9 | 293 | 32 | 1 | 32.000000 | 1334361600000000000 |
9 | 2012-04-15 | 10 | 302 | 9 | 1 | 9.000000 | 1334448000000000000 |
10 | 2012-04-30 | 11 | 346 | 44 | 1 | 44.000000 | 1335744000000000000 |
11 | 2012-05-07 | 12 | 401 | 55 | 1 | 55.000000 | 1336348800000000000 |
12 | 2012-05-14 | 13 | 442 | 41 | 1 | 41.000000 | 1336953600000000000 |
13 | 2012-05-16 | 14 | 480 | 38 | 1 | 38.000000 | 1337126400000000000 |
14 | 2012-05-22 | 15 | 519 | 39 | 1 | 39.000000 | 1337644800000000000 |
15 | 2012-06-18 | 16 | 539 | 20 | 1 | 20.000000 | 1339977600000000000 |
16 | 2012-06-28 | 17 | 567 | 28 | 1 | 28.000000 | 1340841600000000000 |
17 | 2012-07-09 | 18 | 603 | 36 | 1 | 36.000000 | 1341792000000000000 |
18 | 2012-07-10 | 19 | 627 | 24 | 1 | 24.000000 | 1341878400000000000 |
19 | 2012-07-12 | 20 | 667 | 40 | 1 | 40.000000 | 1342051200000000000 |
20 | 2012-07-16 | 21 | 707 | 40 | 1 | 40.000000 | 1342396800000000000 |
21 | 2012-07-19 | 22 | 746 | 39 | 1 | 39.000000 | 1342656000000000000 |
22 | 2012-08-26 | 23 | 766 | 20 | 1 | 20.000000 | 1345939200000000000 |
23 | 2012-09-13 | 24 | 799 | 33 | 1 | 33.000000 | 1347494400000000000 |
24 | 2012-09-17 | 25 | 833 | 34 | 1 | 34.000000 | 1347840000000000000 |
25 | 2012-09-28 | 26 | 872 | 39 | 1 | 39.000000 | 1348790400000000000 |
26 | 2012-10-08 | 27 | 914 | 42 | 1 | 42.000000 | 1349654400000000000 |
27 | 2012-10-11 | 28 | 939 | 25 | 1 | 25.000000 | 1349913600000000000 |
28 | 2012-10-17 | 29 | 979 | 40 | 1 | 40.000000 | 1350432000000000000 |
29 | 2012-10-18 | 30 | 1041 | 62 | 1 | 62.000000 | 1350518400000000000 |
... | ... | ... | ... | ... | ... | ... | ... |
331 | 2015-08-17 | 450 | 14926 | 44 | 1 | 44.000000 | 1439769600000000000 |
332 | 2015-08-20 | 454 | 15017 | 91 | 4 | 22.750000 | 1440028800000000000 |
333 | 2015-08-21 | 455 | 15063 | 46 | 1 | 46.000000 | 1440115200000000000 |
334 | 2015-08-24 | 459 | 15184 | 121 | 4 | 30.250000 | 1440374400000000000 |
335 | 2015-08-26 | 462 | 15258 | 74 | 3 | 24.666667 | 1440547200000000000 |
336 | 2015-08-27 | 464 | 15318 | 60 | 2 | 30.000000 | 1440633600000000000 |
337 | 2015-09-03 | 465 | 15355 | 37 | 1 | 37.000000 | 1441238400000000000 |
338 | 2015-09-06 | 466 | 15380 | 25 | 1 | 25.000000 | 1441497600000000000 |
339 | 2015-09-07 | 468 | 15409 | 29 | 2 | 14.500000 | 1441584000000000000 |
340 | 2015-09-08 | 470 | 15435 | 26 | 2 | 13.000000 | 1441670400000000000 |
341 | 2015-09-10 | 474 | 15585 | 150 | 4 | 37.500000 | 1441843200000000000 |
342 | 2015-09-14 | 475 | 15603 | 18 | 1 | 18.000000 | 1442188800000000000 |
343 | 2015-09-15 | 477 | 15650 | 47 | 2 | 23.500000 | 1442275200000000000 |
344 | 2015-09-17 | 480 | 15713 | 63 | 3 | 21.000000 | 1442448000000000000 |
345 | 2015-09-19 | 481 | 15788 | 75 | 1 | 75.000000 | 1442620800000000000 |
346 | 2015-09-22 | 482 | 15799 | 11 | 1 | 11.000000 | 1442880000000000000 |
347 | 2015-09-23 | 483 | 15800 | 1 | 1 | 1.000000 | 1442966400000000000 |
348 | 2015-09-24 | 485 | 15843 | 43 | 2 | 21.500000 | 1443052800000000000 |
349 | 2015-09-26 | 486 | 15918 | 75 | 1 | 75.000000 | 1443225600000000000 |
350 | 2015-09-28 | 490 | 16021 | 103 | 4 | 25.750000 | 1443398400000000000 |
351 | 2015-10-01 | 492 | 16021 | 0 | 2 | 0.000000 | 1443657600000000000 |
352 | 2015-10-03 | 495 | 16025 | 4 | 3 | 1.333333 | 1443830400000000000 |
353 | 2015-10-05 | 496 | 16062 | 37 | 1 | 37.000000 | 1444003200000000000 |
354 | 2015-10-06 | 497 | 16074 | 12 | 1 | 12.000000 | 1444089600000000000 |
355 | 2015-10-07 | 498 | 16074 | 0 | 1 | 0.000000 | 1444176000000000000 |
356 | 2015-10-12 | 500 | 16092 | 18 | 2 | 9.000000 | 1444608000000000000 |
357 | 2015-10-17 | 503 | 16130 | 38 | 3 | 12.666667 | 1445040000000000000 |
358 | 2015-10-19 | 507 | 16130 | 0 | 4 | 0.000000 | 1445212800000000000 |
359 | 2015-10-21 | 508 | 16130 | 0 | 1 | 0.000000 | 1445385600000000000 |
360 | 2015-10-22 | 509 | 16130 | 0 | 1 | 0.000000 | 1445472000000000000 |
361 rows × 7 columns