Friday 15 January 2010

python - How to import Dictionary into DataFrame? -


How to import dictionaries into dotfred, and assign the first column as the date and assign the header: < Pre> db = {u'data ': [[u'18 / 06/2013', u'34.8400 ', u'34.8400'], [u'17 / 06/2013 ', '34.44900,' ' 34.4900 ']], you'fund': u'tgc '}, {u'data': [[u'18 / 06/2013 ', u'14.9179', u'14.9179 '], [u'17 / 06 / 2013] ', U'14.8712', '14.8712 '], you'fund': youf '}, {u'data': [[u'18 / 06/2013 ', u'6.6780', U'6.6780 '], [U / 06/2013', U'6.6510 ', U'6.6570']], 'Ufund': u'FAF '}]

The following dataframe As: TGC FeF FAF Date Quote Bid asking bidding bid 18/06/2013 34.8400 34.8400 14.9179 14.9179 6.6780 6.6780 17/06/2013 34.4 9 00 34.4 9 00 14.8712 14.8712 6.6510 6.6570

 r'). ()) = [DB in D: if d ['data']: df = pd.DataFrame (d ['data']) df.column = ['date', 'bid', 'ask'] df = Df.set_index ('date') pi Eces.append (df) df = pd.concat (pieces, axis = 1, keys = [db for d [d]) print df   

Output:

  TGC FeF FAF bid bid to ask for bid quote date 18/06/2013 34.8400 34.8400 14.9179 14.9179 6.6780 6.6780 17/06/2013 34.4 9 00 34.4900 14.8712 14.8712 6.6510 6.6570    

No comments:

Post a Comment