Hello.You can use numpy:
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 ?
http://www.scipy.org/NumPy
for example:
In [139]: arr = numpy.char.array(['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:
http://mentat.za.net/numpy/refguide/
or take a look at these pages for some quick examples of what's possible:
http://pages.physics.cornell.edu/~my...on/arrays.html
http://www.scipy.org/Numpy_Example_List_With_Doc