numpy - how to get to various attributes in the same order in python -


I have one line and in return, information, speed, time and type of surfaces are saved for each line. I want this information to be shown in the order shown below in an NP.ER. where the number is the number of id.

  (ID) 0 1 2 3 4 5 6 7 8 9 0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 1 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 2 T1 t2 t3 t4 t5 t6 t7 t8 t9 t10 3 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 4 t1 t2 t3 t5 t6 t7 t8 t9 t10 5 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 < / Code> 

... thanks for any feedback

your useful It may seem

For example, suppose you have a file with these content:.

datafile:

  (id) 0 1 0 1 smooth 1 11 fluctuating 2 20 turbulent 3 2 smooth 4 5 volatile 5 to 7 rugged  

imported numpy NP arrival = np.loadtxt ('datafile', dtype = [('id', '', then you can load data in a numpy with

Int '), (as' speed', 'boat'), ('surface', '| s20')], skiprows = 1)

Note that you , you can skip the first row of the datafile.

Then you can use rows as usual with the numerical index, such as the arrival [1] , and you can access columns by names , Such as arr ['speed'] .

And you can get speed in 3 lines, for more information about structured arrays, arr [3] ['speed'] or arr [speed] ] [3] .

/ P>


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -