How to use the method loadtxt() of numpy neatly?

chao dong neutronest at gmail.com
Fri Dec 20 06:48:53 CET 2013


    HI, everybody. When I try to use numpy to deal with my dataset in the style of csv, I face a little problem.
    
    In my dataset of the csv file, some columns are string that can not convert to float easily. Some of them can ignore, but other columns I need to change the data to a enum style.

    for example, one column just contain three kinds : S,Q,C. Each of them can declare one meaning, so I must convert them to a dict just like {1,2,3}
    
    Now the question is, when I use numpy.loadtxt, I must do all things above in just one line and one fuction. So as a new user in numpy, I don't know how to solve it.

    Thank you.



More information about the Python-list mailing list