numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersReturns
fromfile(fd, dtype=None, shape=None, offset=0, formats=None, names=None, titles=None, aligned=False, byteorder=None)

Parameters

fd : str or file type

If file is a string or a path-like object then that file is opened, else it is assumed to be a file object. The file object must support random access (i.e. it must have tell and seek methods).

dtype : data-type, optional

valid dtype for all arrays

shape : int or tuple of ints, optional

shape of each array.

offset : int, optional

Position in the file to start reading from.

formats, names, titles, aligned, byteorder :

If dtype is None , these arguments are passed to numpy.format_parser to construct a dtype. See that function for detailed documentation

Returns

np.recarray

record array consisting of data enclosed in file.

Create an array from binary file data

Examples

>>> from tempfile import TemporaryFile
... a = np.empty(10,dtype='f8,i4,a5')
... a[5] = (0.5,10,'abcde') >>>
>>> fd=TemporaryFile()
... a = a.newbyteorder('<')
... a.tofile(fd) >>>
>>> _ = fd.seek(0)
... r=np.core.records.fromfile(fd, formats='f8,i4,a5', shape=10,
... byteorder='<')
... print(r[5]) (0.5, 10, 'abcde')
>>> r.shape
(10,)
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/core/records.py#852
type: <class 'function'>
Commit: