Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Wed Mar 8 20:47:17 2017
- @author: wagner
- REF: http://pbpython.com/pandas-list-dict.html
- """
- import pandas as pd
- import numpy as np
- from io import StringIO
- txtFile = StringIO(u"0. 0.0007 0.001 0.001 0.0006\n0. 0.001 0.001 0.0008 0.0006\n0.001 0.001 0.001 0.0009 0.0007\n0.001 0.0013 0.001 0.0008 0.0006\n0.002 0.001 0.001 0.0008 0.0007")
- data = np.loadtxt(txtFile)
- StructData = {}
- Label = ['Label1', 'Label2', 'Label3', 'Label4', 'Label5']
- Columns = data.shape[1]
- for c in xrange(Columns):
- StructData[Label[c]] = list(data[:,c])
- #print StructData
- df = pd.DataFrame.from_dict(StructData)
- print '\n'*3, df
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement