I did this call:
data = numpy.genfromtxt('grades.txt', dtype=None, delimiter='\t', names=True)
How do you get a list of the column names?
The column names can be found in
data.dtype.names
For example,
In [39]: data
Out[39]:
array([('2010-1-1', 1.2, 2.3, 3.4), ('2010-2-1', 4.5, 5.6, 6.7)],
dtype=[('f0', '|S10'), ('f1', '<f8'), ('f2', '<f8'), ('f3', '<f8')])
In [40]: data.dtype
Out[40]: dtype([('f0', '|S10'), ('f1', '<f8'), ('f2', '<f8'), ('f3', '<f8')])
In [41]: data.dtype.names
Out[41]: ('f0', 'f1', 'f2', 'f3')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With