On Thu, Aug 7, 2008 at 1:36 PM, Simon Parker <simon_ecc@yaho o.co.ukwrote:
You can use numpy:
for example:
In [139]: arr = numpy.char.arra y(['a', 'A', 'b', 'B', 'c', 'C'])
In [140]: arr = arr.reshape((3, 2))
In [141]: arr
Out[141]:
chararray([['a', 'A'],
['b', 'B'],
['c', 'C']],
dtype='|S1')
In [142]: arr[0,:]
Out[142]:
chararray(['a', 'A'],
dtype='|S1')
In [143]: arr[:,0]
Out[143]:
chararray(['a', 'b', 'c'],
dtype='|S1')
More documentation here:
or take a look at these pages for some quick examples of what's possible:
Hello.
>
I want to be able to create a 2D character matrix, ThisMatrix, like :
>
>
a A
b B
c C
d D
>
and to be able to pick out elements, or rows or columns.
>
I have become used to programming in R where I can easily refer to a row as
:
>
ThisMatrix [1,]
>
and a column as
>
ThisMatrix[,1].
>
etc..
>
Can this be done easily in Python ?
>
>
>
I want to be able to create a 2D character matrix, ThisMatrix, like :
>
>
a A
b B
c C
d D
>
and to be able to pick out elements, or rows or columns.
>
I have become used to programming in R where I can easily refer to a row as
:
>
ThisMatrix [1,]
>
and a column as
>
ThisMatrix[,1].
>
etc..
>
Can this be done easily in Python ?
>
>
for example:
In [139]: arr = numpy.char.arra y(['a', 'A', 'b', 'B', 'c', 'C'])
In [140]: arr = arr.reshape((3, 2))
In [141]: arr
Out[141]:
chararray([['a', 'A'],
['b', 'B'],
['c', 'C']],
dtype='|S1')
In [142]: arr[0,:]
Out[142]:
chararray(['a', 'A'],
dtype='|S1')
In [143]: arr[:,0]
Out[143]:
chararray(['a', 'b', 'c'],
dtype='|S1')
More documentation here:
or take a look at these pages for some quick examples of what's possible: