|
From: Piet v. O. <pi...@va...> - 2014-02-28 20:52:18
|
AR12 wrote:
> Hi,
>
> I have a csv file where head -5 looks like this:
>
> A B C
> 100 0.45 0.3
> 67 0.25 0.4
> 50.6 0.2 0.6
> 56.4 0.4 0.3
>
> The columns are tab separated. I want to load this CSV file and plot the
> histogram of the third or second column. I was able to load the csv file
> using this:
> data=csv2rec('Downloads/Sample.txt',delimiter='\t',skiprows=0)
> The file has 2792 rows including the top header row.
>
> When I do
> >> data['A'] I get this error:
> ---------------------------------------------------------------------------
> ValueError Traceback (most recent call last)
> <ipython-input-19-856828b8eaa3> in <module>()
> ----> 1 data['A']
numpy.csv2rec lowercases the column names.
"If *names* is *None*, a header row is required to automatically
assign the recarray names. The headers will be lower cased,
spaces will be converted to underscores, and illegal attribute
name characters removed. If *names* is not *None*, it is a
sequence of names to use for the column names. In this case, it
is assumed there is no header row."
So data['a'] should do it.
--
Piet van Oostrum <pi...@va...>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
|