Skip to content

Instantly share code, notes, and snippets.

@beaumartinez
Created August 8, 2012 11:54
Show Gist options
  • Save beaumartinez/3294509 to your computer and use it in GitHub Desktop.
Save beaumartinez/3294509 to your computer and use it in GitHub Desktop.
Pandas data issues
from itertools import imap, izip
import datetime
import pandas
data = (
{u'_id': u'770000000006',
u'value': {u'timestamps': [datetime.datetime(2012, 5, 11, 15, 19, 49, 695000),
datetime.datetime(2012, 5, 11, 15, 25, 51, 586000),
datetime.datetime(2012, 5, 11, 15, 40, 11, 206000),
datetime.datetime(2012, 5, 11, 15, 44, 32, 883000),
datetime.datetime(2012, 5, 11, 15, 44, 44, 985000),
datetime.datetime(2012, 5, 11, 15, 44, 52, 659000),
datetime.datetime(2012, 5, 11, 15, 45, 1, 457000),
datetime.datetime(2012, 5, 11, 15, 45, 20, 746000),
datetime.datetime(2012, 5, 11, 15, 45, 23, 15000)],
u'values': [12.0,
14.0,
57.0,
21.0,
31.0,
19.0,
26.0,
57.0,
19.0]}},
{u'_id': u'770000000009',
u'value': {u'timestamps': [datetime.datetime(2012, 5, 14, 17, 39, 15, 609000),
datetime.datetime(2012, 5, 14, 17, 42, 15, 691000),
datetime.datetime(2012, 5, 14, 17, 48, 15, 852000),
datetime.datetime(2012, 5, 14, 18, 48, 30, 521000),
datetime.datetime(2012, 5, 14, 18, 56, 55, 254000),
datetime.datetime(2012, 5, 14, 18, 59, 38, 554000),
datetime.datetime(2012, 5, 14, 18, 59, 47, 632000),
datetime.datetime(2012, 5, 14, 19, 0, 45, 144000),
datetime.datetime(2012, 5, 14, 19, 8, 32, 234000),
datetime.datetime(2012, 5, 14, 19, 17, 43, 374000),
datetime.datetime(2012, 5, 14, 20, 6, 32, 42000),
datetime.datetime(2012, 5, 14, 20, 26, 32, 394000),
datetime.datetime(2012, 5, 14, 21, 51, 34, 145000),
datetime.datetime(2012, 5, 14, 22, 6, 34, 548000)],
u'values': [20.0,
20.0,
20.0,
564.99,
20.0,
20.0,
20.0,
20.0,
20.0,
564.99,
564.99,
564.99,
39.99,
564.99]}},
{u'_id': u'770000000010',
u'value': {u'timestamps': [datetime.datetime(2012, 5, 14, 18, 54, 55, 203000),
datetime.datetime(2012, 5, 14, 18, 59, 44, 607000),
datetime.datetime(2012, 5, 14, 19, 0, 17, 893000),
datetime.datetime(2012, 5, 14, 19, 16, 5, 751000),
datetime.datetime(2012, 5, 14, 19, 16, 11, 892000),
datetime.datetime(2012, 5, 14, 19, 56, 31, 836000),
datetime.datetime(2012, 5, 14, 20, 16, 32, 258000),
datetime.datetime(2012, 5, 14, 20, 21, 32, 285000),
datetime.datetime(2012, 5, 14, 20, 31, 32, 503000),
datetime.datetime(2012, 5, 14, 20, 46, 32, 823000),
datetime.datetime(2012, 5, 14, 20, 56, 33, 41000),
datetime.datetime(2012, 5, 14, 21, 6, 33, 259000),
datetime.datetime(2012, 5, 14, 21, 11, 33, 368000),
datetime.datetime(2012, 5, 14, 21, 26, 33, 694000),
datetime.datetime(2012, 5, 14, 21, 31, 33, 786000),
datetime.datetime(2012, 5, 14, 21, 36, 33, 895000)],
u'values': [564.99,
564.99,
564.99,
39.99,
20.0,
564.99,
564.99,
39.99,
20.0,
39.99,
20.0,
564.99,
20.0,
20.0,
20.0,
39.99]}},
{u'_id': u'770000000011',
u'value': {u'timestamps': [datetime.datetime(2012, 5, 14, 19, 0, 2, 767000),
datetime.datetime(2012, 5, 14, 19, 0, 8, 815000),
datetime.datetime(2012, 5, 14, 19, 0, 48, 195000),
datetime.datetime(2012, 5, 14, 19, 1, 0, 301000),
datetime.datetime(2012, 5, 14, 19, 1, 3, 350000),
datetime.datetime(2012, 5, 14, 19, 1, 12, 453000),
datetime.datetime(2012, 5, 14, 19, 16, 2, 680000),
datetime.datetime(2012, 5, 14, 19, 16, 8, 821000),
datetime.datetime(2012, 5, 14, 19, 16, 18, 41000),
datetime.datetime(2012, 5, 14, 19, 16, 43, 574000),
datetime.datetime(2012, 5, 14, 19, 17, 20, 654000),
datetime.datetime(2012, 5, 14, 20, 1, 31, 933000),
datetime.datetime(2012, 5, 14, 20, 11, 32, 150000),
datetime.datetime(2012, 5, 14, 21, 21, 33, 585000),
datetime.datetime(2012, 5, 14, 21, 46, 34, 114000),
datetime.datetime(2012, 5, 14, 21, 56, 34, 274000)],
u'values': [20.0,
39.99,
20.0,
20.0,
39.99,
564.99,
20.0,
39.99,
564.99,
564.99,
39.99,
564.99,
564.99,
564.99,
20.0,
39.99]}},
{u'_id': u'770000000012',
u'value': {u'timestamps': [datetime.datetime(2012, 5, 14, 18, 47, 30, 494000),
datetime.datetime(2012, 5, 14, 18, 59, 32, 500000),
datetime.datetime(2012, 5, 14, 18, 59, 50, 664000),
datetime.datetime(2012, 5, 14, 19, 0, 14, 868000),
datetime.datetime(2012, 5, 14, 19, 0, 20, 918000),
datetime.datetime(2012, 5, 14, 19, 0, 42, 104000),
datetime.datetime(2012, 5, 14, 19, 0, 57, 276000),
datetime.datetime(2012, 5, 14, 19, 8, 26, 83000),
datetime.datetime(2012, 5, 14, 19, 16, 14, 966000),
datetime.datetime(2012, 5, 14, 19, 17, 23, 721000),
datetime.datetime(2012, 5, 14, 20, 36, 32, 612000),
datetime.datetime(2012, 5, 14, 20, 41, 32, 714000),
datetime.datetime(2012, 5, 14, 20, 51, 32, 931000),
datetime.datetime(2012, 5, 14, 21, 1, 33, 149000),
datetime.datetime(2012, 5, 14, 21, 16, 33, 476000),
datetime.datetime(2012, 5, 14, 21, 41, 34, 4000),
datetime.datetime(2012, 5, 14, 22, 1, 34, 394000)],
u'values': [564.99,
39.99,
39.99,
20.0,
20.0,
20.0,
20.0,
564.99,
39.99,
564.99,
564.99,
20.0,
39.99,
39.99,
39.99,
39.99,
564.99]}},
{u'_id': u'770000000013',
u'value': {u'timestamps': [datetime.datetime(2012, 5, 14, 22, 33, 48, 88000),
datetime.datetime(2012, 5, 14, 22, 36, 58, 102000),
datetime.datetime(2012, 5, 14, 22, 39, 56, 328000),
datetime.datetime(2012, 5, 15, 9, 49, 9, 198000),
datetime.datetime(2012, 5, 15, 15, 9, 32, 149000),
datetime.datetime(2012, 5, 15, 15, 12, 45, 984000),
datetime.datetime(2012, 5, 16, 11, 8, 55, 480000),
datetime.datetime(2012, 5, 16, 16, 6, 36, 806000),
datetime.datetime(2012, 5, 16, 16, 6, 36, 860000),
datetime.datetime(2012, 5, 17, 14, 21, 16, 324000),
datetime.datetime(2012, 5, 17, 14, 24, 18, 39000),
datetime.datetime(2012, 5, 17, 14, 25, 4, 856000),
datetime.datetime(2012, 5, 17, 14, 28, 2, 407000),
datetime.datetime(2012, 5, 17, 14, 34, 3, 835000),
datetime.datetime(2012, 5, 17, 14, 34, 10, 106000),
datetime.datetime(2012, 5, 17, 14, 40, 49, 628000)],
u'values': [8.24,
8.24,
16.48,
18.27,
2521.37817,
4.8,
28.8,
11.39,
11.39,
8.24,
8.24,
8.24,
8.24,
8.24,
8.24,
8.24]}},
{u'_id': u'770000000018',
u'value': {u'timestamps': [datetime.datetime(2012, 5, 17, 15, 43, 58, 194000),
datetime.datetime(2012, 5, 17, 16, 34, 57, 422000),
datetime.datetime(2012, 5, 17, 16, 36, 10, 384000),
datetime.datetime(2012, 5, 17, 16, 39, 21, 627000),
datetime.datetime(2012, 5, 17, 16, 40, 56, 204000),
datetime.datetime(2012, 5, 17, 16, 46, 23, 852000),
datetime.datetime(2012, 5, 17, 17, 33, 12, 657000),
datetime.datetime(2012, 5, 17, 17, 33, 43, 339000),
datetime.datetime(2012, 5, 17, 17, 34, 21, 477000),
datetime.datetime(2012, 5, 17, 18, 30, 59, 454000),
datetime.datetime(2012, 5, 17, 18, 31, 52, 700000),
datetime.datetime(2012, 5, 17, 18, 33, 49, 401000),
datetime.datetime(2012, 5, 17, 18, 35, 45, 203000),
datetime.datetime(2012, 5, 17, 18, 36, 55, 809000),
datetime.datetime(2012, 5, 17, 18, 52, 44, 957000),
datetime.datetime(2012, 5, 17, 18, 54, 36, 97000),
datetime.datetime(2012, 5, 17, 18, 55, 18, 28000),
datetime.datetime(2012, 5, 17, 18, 55, 31, 26000),
datetime.datetime(2012, 5, 17, 18, 55, 48, 327000),
datetime.datetime(2012, 5, 18, 9, 46, 30, 362000),
datetime.datetime(2012, 5, 18, 10, 26, 59, 510000),
datetime.datetime(2012, 5, 18, 10, 32, 36, 501000),
datetime.datetime(2012, 5, 18, 10, 33, 47, 582000),
datetime.datetime(2012, 5, 18, 12, 0, 13, 279000),
datetime.datetime(2012, 5, 29, 13, 28, 25, 916000),
datetime.datetime(2012, 5, 29, 13, 28, 26, 496000),
datetime.datetime(2012, 5, 29, 14, 42, 17, 709000),
datetime.datetime(2012, 5, 29, 18, 41, 59, 316000),
datetime.datetime(2012, 6, 14, 9, 31, 44, 843000),
datetime.datetime(2012, 6, 14, 9, 43, 30, 399000),
datetime.datetime(2012, 6, 21, 12, 5, 54, 971000),
datetime.datetime(2012, 6, 27, 15, 18, 23, 396000),
datetime.datetime(2012, 7, 11, 16, 10, 14, 20000),
datetime.datetime(2012, 7, 16, 16, 5, 55, 331000),
datetime.datetime(2012, 7, 25, 9, 58, 28, 425000),
datetime.datetime(2012, 7, 25, 10, 0, 26, 568000),
datetime.datetime(2012, 7, 25, 10, 16, 56, 380000),
datetime.datetime(2012, 7, 25, 10, 28, 15, 151000),
datetime.datetime(2012, 7, 25, 11, 54, 3, 418000)],
u'values': [1.46,
146.0,
146.0,
141.0,
94.9,
59.2399979,
7.3,
1.46,
20.44,
175.2,
40.8799973,
1.79,
45.26,
18.5500011,
599.976,
47.88,
12.0,
29.94,
105.6,
173.74,
127.02,
105.6,
1.46,
1.46,
162.06,
162.06,
1.46,
194.18,
1.46,
1.46,
146.0,
1.46,
9.6,
146.0,
130.269989,
16.06,
7.35,
105.450005,
16.06]}},
{u'_id': u'770000000020',
u'value': {u'timestamps': [datetime.datetime(2012, 5, 17, 15, 54, 3, 66000),
datetime.datetime(2012, 5, 17, 16, 49, 45, 660000),
datetime.datetime(2012, 5, 17, 16, 52, 53, 633000)],
u'values': [93.6, 0.0, 93.6]}},
{u'_id': u'770000000021',
u'value': {u'timestamps': [datetime.datetime(2012, 5, 17, 15, 47, 40, 557000)],
u'values': [83.9399948]}},
{u'_id': u'770000000022',
u'value': {u'timestamps': [datetime.datetime(2012, 5, 17, 14, 45, 32, 591000),
datetime.datetime(2012, 5, 17, 15, 41, 4, 956000),
datetime.datetime(2012, 5, 17, 17, 25, 0, 904000),
datetime.datetime(2012, 5, 17, 17, 28, 27, 826000),
datetime.datetime(2012, 5, 17, 18, 35, 46, 11000),
datetime.datetime(2012, 5, 28, 13, 23, 42, 177000),
datetime.datetime(2012, 5, 28, 13, 24, 13, 3000),
datetime.datetime(2012, 5, 28, 14, 43, 46, 589000),
datetime.datetime(2012, 6, 12, 15, 6, 40, 581000),
datetime.datetime(2012, 6, 22, 16, 55, 40, 132000),
datetime.datetime(2012, 6, 25, 10, 43, 37, 486000),
datetime.datetime(2012, 6, 25, 10, 49, 1, 908000),
datetime.datetime(2012, 6, 25, 10, 55, 34, 445000),
datetime.datetime(2012, 6, 25, 17, 51, 33, 102000),
datetime.datetime(2012, 6, 28, 16, 52, 6, 984000),
datetime.datetime(2012, 6, 28, 16, 53, 50, 798000),
datetime.datetime(2012, 7, 9, 17, 29, 1, 289000),
datetime.datetime(2012, 7, 9, 17, 30, 16, 136000),
datetime.datetime(2012, 7, 10, 11, 23, 26, 910000),
datetime.datetime(2012, 7, 10, 13, 23, 46, 751000),
datetime.datetime(2012, 7, 10, 15, 18, 57, 54000),
datetime.datetime(2012, 7, 11, 8, 51, 34, 773000),
datetime.datetime(2012, 7, 11, 10, 55, 21, 671000)],
u'values': [599.976,
779.96405,
599.976,
977.975952,
468.0,
599.976,
599.976,
599.976,
1.575,
355.929,
355.929,
17.8395,
7.35,
17.8395,
12.688,
12.688,
1.575,
1.575,
1.575,
1.575,
1.575,
1.575,
1.575]}},
{u'_id': u'770000000029',
u'value': {u'timestamps': [datetime.datetime(2012, 7, 11, 10, 27, 19, 401000),
datetime.datetime(2012, 7, 11, 10, 41, 39, 401000)],
u'values': [10.2, 16.32]}},
{u'_id': u'770000000030',
u'value': {u'timestamps': [datetime.datetime(2012, 7, 13, 16, 13, 59, 823000),
datetime.datetime(2012, 7, 16, 10, 40, 6, 527000),
datetime.datetime(2012, 8, 2, 17, 5, 8, 429000),
datetime.datetime(2012, 8, 2, 17, 33, 28, 125000)],
u'values': [4891.26025, 10.8, 5.988, 5.988]}},
{u'_id': u'770000000032',
u'value': {u'timestamps': [datetime.datetime(2012, 7, 13, 16, 15, 4, 144000)],
u'values': [447.189575]}},
{u'_id': u'770000000034',
u'value': {u'timestamps': [datetime.datetime(2012, 7, 13, 16, 17, 8, 753000),
datetime.datetime(2012, 7, 16, 10, 24, 15, 363000),
datetime.datetime(2012, 7, 16, 10, 26, 2, 284000),
datetime.datetime(2012, 7, 16, 11, 15, 20, 952000),
datetime.datetime(2012, 7, 16, 11, 15, 48, 191000),
datetime.datetime(2012, 7, 16, 15, 24, 54, 175000),
datetime.datetime(2012, 7, 16, 16, 4, 4, 895000),
datetime.datetime(2012, 7, 17, 17, 59, 21, 371000),
datetime.datetime(2012, 7, 19, 13, 38, 51, 799000),
datetime.datetime(2012, 7, 19, 14, 13, 38, 478000),
datetime.datetime(2012, 7, 23, 10, 14, 55, 801000),
datetime.datetime(2012, 7, 25, 9, 59, 36, 157000),
datetime.datetime(2012, 7, 25, 10, 26, 33, 585000),
datetime.datetime(2012, 7, 25, 10, 30, 54, 251000),
datetime.datetime(2012, 7, 25, 14, 45, 58, 545000),
datetime.datetime(2012, 7, 26, 8, 52, 15, 721000),
datetime.datetime(2012, 7, 26, 11, 9, 33, 975000),
datetime.datetime(2012, 7, 26, 11, 36, 58, 334000),
datetime.datetime(2012, 7, 26, 12, 40, 50, 240000),
datetime.datetime(2012, 7, 26, 12, 45, 26, 153000),
datetime.datetime(2012, 7, 26, 12, 47, 2, 173000),
datetime.datetime(2012, 7, 26, 12, 53, 28, 699000),
datetime.datetime(2012, 7, 26, 12, 53, 32, 641000),
datetime.datetime(2012, 7, 26, 12, 53, 37, 973000),
datetime.datetime(2012, 7, 26, 12, 53, 50, 637000),
datetime.datetime(2012, 7, 26, 12, 55, 26, 850000),
datetime.datetime(2012, 7, 26, 12, 56, 56, 321000),
datetime.datetime(2012, 7, 26, 12, 58, 27, 39000),
datetime.datetime(2012, 7, 26, 12, 59, 6, 242000),
datetime.datetime(2012, 7, 26, 14, 7, 55, 848000),
datetime.datetime(2012, 7, 26, 14, 46, 5, 43000),
datetime.datetime(2012, 7, 26, 15, 22, 32, 3000),
datetime.datetime(2012, 7, 26, 17, 33, 1, 20000)],
u'values': [96.0,
528.0,
60.0,
0.0,
7.188000000000001,
0.0,
479.988,
561.6,
238.8,
79.2,
66.0,
239.988,
239.988,
14.376000000000001,
115.2,
71.964,
129.6,
14.4,
96.0,
0.0,
0.0,
4.8,
4.8,
4.8,
4.8,
0.0,
0.0,
0.0,
0.0,
9.6,
0.0,
66.0,
152.4]}},
{u'_id': u'770000000049',
u'value': {u'timestamps': [datetime.datetime(2012, 7, 25, 10, 16, 1, 270000),
datetime.datetime(2012, 7, 25, 10, 18, 29, 745000),
datetime.datetime(2012, 7, 25, 10, 21, 54, 931000),
datetime.datetime(2012, 7, 25, 10, 23, 18, 896000)],
u'values': [204.0, 16.788, 139.2, 116.004]}},
{u'_id': u'770000000024',
u'value': {u'timestamps': [datetime.datetime(2012, 5, 14, 17, 8, 42, 828000),
datetime.datetime(2012, 5, 14, 17, 9, 8, 834000),
datetime.datetime(2012, 5, 17, 18, 18, 24, 988000),
datetime.datetime(2012, 5, 17, 18, 33, 56, 865000),
datetime.datetime(2012, 5, 17, 18, 34, 45, 812000),
datetime.datetime(2012, 5, 17, 18, 49, 2, 539000),
datetime.datetime(2012, 5, 17, 18, 49, 15, 453000),
datetime.datetime(2012, 5, 17, 18, 49, 15, 855000),
datetime.datetime(2012, 5, 17, 18, 49, 32, 226000),
datetime.datetime(2012, 5, 17, 18, 49, 37, 706000),
datetime.datetime(2012, 5, 17, 18, 50, 1, 844000),
datetime.datetime(2012, 5, 17, 18, 50, 8, 486000),
datetime.datetime(2012, 5, 18, 9, 48, 11, 537000),
datetime.datetime(2012, 5, 18, 10, 2, 52, 432000),
datetime.datetime(2012, 5, 18, 10, 3, 37, 402000),
datetime.datetime(2012, 5, 18, 10, 12, 57, 263000),
datetime.datetime(2012, 5, 18, 10, 13, 35, 37000),
datetime.datetime(2012, 5, 18, 10, 24, 40, 745000),
datetime.datetime(2012, 5, 18, 10, 25, 13, 793000),
datetime.datetime(2012, 5, 18, 10, 35, 4, 413000),
datetime.datetime(2012, 5, 18, 10, 35, 50, 769000),
datetime.datetime(2012, 5, 18, 10, 46, 3, 698000),
datetime.datetime(2012, 5, 18, 10, 49, 18, 10000),
datetime.datetime(2012, 5, 18, 10, 58, 0, 688000),
datetime.datetime(2012, 5, 18, 12, 0, 56, 873000),
datetime.datetime(2012, 5, 18, 12, 3, 58, 729000),
datetime.datetime(2012, 5, 18, 12, 4, 6, 649000),
datetime.datetime(2012, 5, 21, 15, 0, 41, 301000),
datetime.datetime(2012, 5, 21, 15, 0, 54, 340000),
datetime.datetime(2012, 5, 21, 15, 0, 58, 502000),
datetime.datetime(2012, 5, 21, 15, 1, 4, 457000),
datetime.datetime(2012, 5, 21, 15, 58, 50, 555000),
datetime.datetime(2012, 5, 23, 10, 48, 9, 90000),
datetime.datetime(2012, 5, 23, 10, 56, 6, 548000),
datetime.datetime(2012, 5, 23, 11, 2, 11, 958000),
datetime.datetime(2012, 5, 23, 15, 9, 19, 577000),
datetime.datetime(2012, 5, 23, 17, 57, 28, 233000),
datetime.datetime(2012, 5, 24, 9, 52, 27, 933000),
datetime.datetime(2012, 5, 24, 9, 55, 7, 285000),
datetime.datetime(2012, 5, 24, 9, 55, 11, 973000),
datetime.datetime(2012, 5, 24, 9, 55, 17, 920000),
datetime.datetime(2012, 5, 24, 11, 16, 2, 986000),
datetime.datetime(2012, 5, 24, 12, 39, 48, 131000),
datetime.datetime(2012, 5, 24, 14, 44, 1, 921000),
datetime.datetime(2012, 5, 24, 14, 45, 40, 167000),
datetime.datetime(2012, 5, 25, 13, 28, 1, 847000),
datetime.datetime(2012, 5, 29, 12, 47, 19, 731000),
datetime.datetime(2012, 5, 29, 12, 53, 45, 772000),
datetime.datetime(2012, 5, 29, 12, 53, 49, 725000),
datetime.datetime(2012, 5, 29, 13, 3, 4, 356000),
datetime.datetime(2012, 5, 29, 13, 3, 9, 913000),
datetime.datetime(2012, 5, 29, 13, 3, 14, 50000),
datetime.datetime(2012, 5, 29, 13, 4, 21, 322000),
datetime.datetime(2012, 5, 11, 15, 27, 24, 873000),
datetime.datetime(2012, 5, 11, 15, 31, 5, 350000),
datetime.datetime(2012, 5, 11, 15, 33, 33, 803000),
datetime.datetime(2012, 5, 11, 15, 34, 2, 623000),
datetime.datetime(2012, 5, 11, 15, 34, 13, 324000),
datetime.datetime(2012, 5, 11, 15, 34, 30, 850000),
datetime.datetime(2012, 5, 11, 15, 34, 48, 873000),
datetime.datetime(2012, 5, 14, 16, 43, 0, 557000),
datetime.datetime(2012, 5, 14, 22, 40, 48, 178000),
datetime.datetime(2012, 5, 15, 9, 40, 54, 367000),
datetime.datetime(2012, 5, 15, 9, 41, 28, 364000),
datetime.datetime(2012, 5, 15, 10, 10, 39, 181000),
datetime.datetime(2012, 5, 15, 10, 12, 45, 906000),
datetime.datetime(2012, 5, 15, 10, 13, 28, 959000),
datetime.datetime(2012, 5, 15, 10, 13, 43, 384000),
datetime.datetime(2012, 5, 15, 12, 14, 51, 960000),
datetime.datetime(2012, 5, 15, 12, 14, 52, 40000),
datetime.datetime(2012, 5, 15, 12, 14, 52, 108000),
datetime.datetime(2012, 5, 15, 12, 23, 5, 609000),
datetime.datetime(2012, 5, 16, 11, 11, 45, 82000),
datetime.datetime(2012, 5, 16, 15, 41, 22, 187000),
datetime.datetime(2012, 5, 16, 16, 5, 37, 430000),
datetime.datetime(2012, 5, 17, 12, 9, 7, 27000),
datetime.datetime(2012, 5, 17, 12, 14, 49, 214000),
datetime.datetime(2012, 5, 17, 12, 26, 58, 312000),
datetime.datetime(2012, 5, 17, 12, 40, 35, 293000),
datetime.datetime(2012, 5, 17, 12, 41, 27, 91000),
datetime.datetime(2012, 5, 17, 12, 44, 58, 319000),
datetime.datetime(2012, 5, 17, 12, 45, 25, 649000),
datetime.datetime(2012, 5, 17, 12, 58, 24, 76000),
datetime.datetime(2012, 5, 17, 13, 2, 15, 354000),
datetime.datetime(2012, 5, 17, 13, 2, 37, 254000),
datetime.datetime(2012, 5, 17, 13, 5, 0, 182000),
datetime.datetime(2012, 5, 17, 13, 5, 29, 992000),
datetime.datetime(2012, 5, 17, 13, 6, 50, 647000),
datetime.datetime(2012, 5, 17, 13, 17, 23, 835000),
datetime.datetime(2012, 5, 17, 13, 23, 54, 552000),
datetime.datetime(2012, 5, 17, 13, 26, 49, 835000),
datetime.datetime(2012, 5, 17, 14, 55, 24, 833000),
datetime.datetime(2012, 5, 17, 14, 58, 11, 409000),
datetime.datetime(2012, 5, 17, 16, 17, 3, 828000),
datetime.datetime(2012, 5, 17, 16, 33, 34, 664000),
datetime.datetime(2012, 5, 17, 16, 57, 58, 996000),
datetime.datetime(2012, 5, 29, 13, 26, 50, 851000),
datetime.datetime(2012, 5, 29, 13, 29, 22, 787000),
datetime.datetime(2012, 5, 29, 13, 34, 18, 383000),
datetime.datetime(2012, 5, 29, 13, 34, 35, 665000),
datetime.datetime(2012, 5, 29, 13, 35, 6, 475000),
datetime.datetime(2012, 5, 29, 13, 35, 13, 644000),
datetime.datetime(2012, 5, 29, 13, 35, 13, 807000),
datetime.datetime(2012, 5, 29, 13, 35, 36, 205000),
datetime.datetime(2012, 5, 29, 13, 35, 36, 383000),
datetime.datetime(2012, 5, 29, 13, 35, 36, 663000),
datetime.datetime(2012, 5, 29, 13, 35, 41, 20000),
datetime.datetime(2012, 5, 29, 13, 35, 44, 748000),
datetime.datetime(2012, 5, 29, 13, 35, 49, 777000),
datetime.datetime(2012, 5, 29, 14, 28, 18, 921000),
datetime.datetime(2012, 5, 29, 14, 28, 22, 348000),
datetime.datetime(2012, 5, 29, 14, 28, 26, 438000),
datetime.datetime(2012, 5, 29, 14, 28, 30, 472000),
datetime.datetime(2012, 5, 29, 18, 41, 4, 526000),
datetime.datetime(2012, 5, 30, 10, 10, 56, 987000),
datetime.datetime(2012, 5, 30, 10, 16, 55, 112000),
datetime.datetime(2012, 5, 30, 10, 17, 4, 121000),
datetime.datetime(2012, 5, 30, 10, 17, 6, 919000),
datetime.datetime(2012, 5, 30, 10, 17, 10, 279000),
datetime.datetime(2012, 5, 30, 11, 18, 16, 290000),
datetime.datetime(2012, 5, 31, 15, 47, 33, 75000),
datetime.datetime(2012, 5, 31, 15, 49, 29, 670000),
datetime.datetime(2012, 5, 31, 15, 49, 35, 790000),
datetime.datetime(2012, 5, 31, 15, 49, 45, 52000),
datetime.datetime(2012, 5, 31, 15, 50, 3, 644000),
datetime.datetime(2012, 5, 31, 15, 50, 8, 461000),
datetime.datetime(2012, 6, 11, 14, 3, 30, 917000),
datetime.datetime(2012, 6, 11, 16, 24, 55, 911000),
datetime.datetime(2012, 6, 13, 16, 30, 6, 467000),
datetime.datetime(2012, 6, 13, 16, 32, 0, 366000),
datetime.datetime(2012, 6, 13, 18, 34, 25, 825000),
datetime.datetime(2012, 6, 13, 18, 41, 39, 451000),
datetime.datetime(2012, 6, 13, 18, 42, 45, 346000),
datetime.datetime(2012, 6, 13, 18, 44, 24, 99000),
datetime.datetime(2012, 6, 13, 22, 2, 55, 25000),
datetime.datetime(2012, 6, 13, 22, 6, 33, 688000),
datetime.datetime(2012, 6, 13, 22, 11, 17, 247000),
datetime.datetime(2012, 6, 19, 15, 16, 42, 318000),
datetime.datetime(2012, 6, 19, 15, 31, 50, 579000),
datetime.datetime(2012, 6, 20, 12, 6, 27, 972000),
datetime.datetime(2012, 6, 20, 12, 38, 43, 321000),
datetime.datetime(2012, 6, 20, 12, 44, 48, 95000),
datetime.datetime(2012, 6, 22, 17, 22, 16, 407000),
datetime.datetime(2012, 6, 22, 17, 22, 20, 67000),
datetime.datetime(2012, 6, 22, 17, 22, 23, 311000),
datetime.datetime(2012, 6, 22, 17, 22, 51, 534000),
datetime.datetime(2012, 6, 22, 17, 22, 58, 834000),
datetime.datetime(2012, 6, 22, 17, 23, 2, 39000),
datetime.datetime(2012, 6, 22, 17, 23, 4, 948000),
datetime.datetime(2012, 6, 22, 17, 23, 30, 27000),
datetime.datetime(2012, 6, 22, 17, 23, 32, 690000),
datetime.datetime(2012, 6, 22, 17, 23, 36, 214000),
datetime.datetime(2012, 6, 22, 17, 24, 19, 742000),
datetime.datetime(2012, 6, 25, 12, 9, 11, 224000),
datetime.datetime(2012, 6, 25, 12, 16, 51, 666000),
datetime.datetime(2012, 6, 25, 12, 20, 37, 972000),
datetime.datetime(2012, 6, 25, 12, 24, 13, 896000),
datetime.datetime(2012, 6, 25, 12, 26, 34, 607000),
datetime.datetime(2012, 6, 25, 12, 27, 21, 332000),
datetime.datetime(2012, 6, 25, 12, 34, 2, 632000),
datetime.datetime(2012, 6, 25, 12, 40, 46, 691000),
datetime.datetime(2012, 6, 25, 12, 41, 4, 19000),
datetime.datetime(2012, 6, 25, 13, 1, 17, 900000),
datetime.datetime(2012, 6, 25, 14, 33, 8, 315000),
datetime.datetime(2012, 6, 25, 14, 33, 22, 370000),
datetime.datetime(2012, 6, 25, 16, 14, 14, 717000),
datetime.datetime(2012, 6, 25, 16, 25, 14, 321000),
datetime.datetime(2012, 6, 25, 16, 30, 32, 818000),
datetime.datetime(2012, 6, 26, 11, 6, 48, 384000),
datetime.datetime(2012, 6, 27, 15, 14, 39, 145000),
datetime.datetime(2012, 6, 29, 11, 48, 20, 572000),
datetime.datetime(2012, 6, 29, 11, 48, 53, 697000),
datetime.datetime(2012, 6, 30, 17, 20, 37, 819000),
datetime.datetime(2012, 7, 3, 14, 19, 21, 892000),
datetime.datetime(2012, 7, 3, 14, 19, 58, 702000),
datetime.datetime(2012, 7, 3, 14, 39, 6, 488000),
datetime.datetime(2012, 7, 3, 16, 7, 27, 977000),
datetime.datetime(2012, 7, 4, 9, 41, 42, 951000),
datetime.datetime(2012, 7, 5, 11, 17, 15, 491000),
datetime.datetime(2012, 7, 5, 11, 20, 25, 389000),
datetime.datetime(2012, 7, 5, 11, 24, 46, 62000),
datetime.datetime(2012, 7, 6, 11, 53, 6, 399000),
datetime.datetime(2012, 7, 6, 11, 54, 48, 872000),
datetime.datetime(2012, 7, 10, 11, 42, 13, 972000),
datetime.datetime(2012, 7, 10, 13, 4, 4, 821000),
datetime.datetime(2012, 7, 10, 15, 59, 46, 161000),
datetime.datetime(2012, 7, 11, 10, 45, 36, 625000),
datetime.datetime(2012, 7, 13, 13, 38, 4, 832000)],
u'values': [26.936,
26.936,
299.64,
134.12400000000002,
21.9,
471.41999999999996,
43.8,
43.8,
358.08,
500.58,
566.28,
682.0799999999999,
219.264,
219.264,
240.276,
156.024,
186.6,
138.00000000000003,
201.23999999999998,
219.264,
186.6,
146.376,
62.124,
197.364,
201.23999999999998,
276.624,
370.524,
219.264,
398.304,
869.7239999999999,
157.14,
314.28,
291.264,
179.04,
92.07600000000002,
156.024,
219.264,
179.04,
179.04,
470.304,
510.5279999999999,
156.024,
272.94,
131.4,
570.0,
43.8,
179.04,
219.264,
383.66400000000004,
197.364,
433.764,
455.66400000000004,
495.88800000000003,
43.092,
21.491999999999997,
48.708,
21.093999999999998,
47.806000000000004,
304.8760000000001,
111.888,
103.74,
10.347999999999999,
21.491999999999997,
119.515,
54.907999999999994,
53.872,
42.294,
73.06200000000001,
97.416,
97.416,
97.416,
121.77,
211.46999999999997,
73.06200000000001,
20.695999999999998,
48.708,
62.16,
712.5,
10.8,
7.2,
157.14,
570.0,
80.4,
0.0,
43.8,
157.14,
109.5,
855.0,
855.0,
365.64,
459.5400000000001,
157.14,
339.86400000000003,
219.264,
179.04,
87.6,
179.04,
393.53999999999996,
43.8,
146.14800000000002,
157.14,
157.14,
157.14,
157.14,
157.14,
157.14,
157.14,
157.14,
157.14,
314.28,
408.17999999999995,
550.68,
590.904,
644.5799999999999,
272.94,
430.08,
523.98,
545.88,
549.756,
219.264,
219.264,
179.04,
492.20399999999995,
219.264,
438.5279999999999,
617.5679999999999,
219.264,
156.024,
40.224000000000004,
208.5,
276.624,
142.5,
236.4,
258.3,
21.9,
62.124,
156.024,
119.676,
415.44,
313.16400000000004,
219.264,
416.62799999999993,
179.04,
276.816,
298.716,
320.61599999999993,
272.94,
366.84,
509.34,
728.6039999999999,
750.5039999999999,
907.6439999999999,
907.6439999999999,
157.14,
127.32,
17.964000000000002,
0.0,
286.74,
30.0,
129.6,
157.14,
129.6,
352.8,
30.0,
12.0,
132.0,
36.0,
270.0,
244.8,
240.0,
4.8,
6.0,
479.988,
0.0,
8.280000000000001,
2.4,
9.6,
960.0,
54.0,
14.4,
54.0,
119.97599999999998,
17.988,
5.988,
27.6,
13.188,
27.6,
25.188]}})
df1_data = {}
for datum in data:
df1_data[datum['_id']] = pandas.Series(datum['value']['values'], index=datum['value']['timestamps'])
df1 = pandas.DataFrame(df1_data)
# Completely fucked up
print df1
# Sort the data
for datum in data:
pairs = izip(datum['value']['timestamps'], datum['value']['values'])
pairs = sorted(pairs, key=lambda x: x[0])
datum['value']['timestamps'] = imap(lambda x: x[0], pairs)
datum['value']['values'] = imap(lambda x: x[1], pairs)
df2_data = {}
for datum in data:
df2_data[datum['_id']] = pandas.Series(datum['value']['values'], index=datum['value']['timestamps'])
df2 = pandas.DataFrame(df2_data)
# Fine
print df2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment