| Trees | Indices | Help |
|---|
|
|
|
|||
| format_parser | |||
| recarray | |||
| record | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
_byteorderconv =
|
|||
_typestr = {<type 'numpy.int64'>: 'i8', <type 'numpy.int16'>:
|
|||
numfmt =
|
|||
|
|||
>>> x1=N.array([1,2,3,4]) >>> x2=N.array(['a','dd','xyz','12']) >>> x3=N.array([1.1,2,3,4]) >>> r = fromarrays([x1,x2,x3],names='a,b,c') >>> print r[1] (2, 'dd', 2.0) >>> x1[1]=34 >>> r.a array([1, 2, 3, 4]) |
Create an array from binary file data If file is a string then that file is opened, else it is assumed to be a file object.>>> from tempfile import TemporaryFile >>> a = N.empty(10,dtype='f8,i4,a5') >>> a[5] = (0.5,10,'abcde') >>> >>> fd=TemporaryFile() >>> a = a.newbyteorder('<') >>> a.tofile(fd) >>> >>> fd.seek(0) >>> r=fromfile(fd, formats='f8,i4,a5', shape=10, byteorder='<') >>> print r[5] (0.5, 10, 'abcde') >>> r.shape (10,) |
create a recarray from a list of records in text form
The data in the same field can be heterogeneous, they will be promoted
to the highest data type. This method is intended for creating
smaller record arrays. If used to create large array without formats
defined
r=fromrecords([(2,3.,'abc')]*100000)
it can be slow.
If formats is None, then this will auto-detect formats. Use list of
tuples rather than list of lists for faster processing.
>>> r=fromrecords([(456,'dbe',1.2),(2,'de',1.3)],names='col1,col2,col3')
>>> print r[0]
(456, 'dbe', 1.2)
>>> r.col1
array([456, 2])
>>> r.col2
chararray(['dbe', 'de'],
dtype='|S3')
>>> import cPickle
>>> print cPickle.loads(cPickle.dumps(r))
[(456, 'dbe', 1.2) (2, 'de', 1.3)]
|
|
|||
_byteorderconv
|
_typestr
|
numfmt
|
| Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0beta1 on Tue Jun 3 09:41:18 2008 | http://epydoc.sourceforge.net |