MCPcopy Create free account
hub / github.com/numpy/numpy / recarray

Class recarray

numpy/core/records.py:308–573  ·  view source on GitHub ↗

Construct an ndarray that allows field access using attributes. Arrays may have a data-types containing fields, analogous to columns in a spread sheet. An example is ``[(x, int), (y, float)]``, where each entry in the array is a pair of ``(int, float)``. Normally, these attributes

Source from the content-addressed store, hash-verified

306# the fields (and any subfields)
307
308class recarray(ndarray):
309 """Construct an ndarray that allows field access using attributes.
310
311 Arrays may have a data-types containing fields, analogous
312 to columns in a spread sheet. An example is ``[(x, int), (y, float)]``,
313 where each entry in the array is a pair of ``(int, float)``. Normally,
314 these attributes are accessed using dictionary lookups such as ``arr['x']``
315 and ``arr['y']``. Record arrays allow the fields to be accessed as members
316 of the array, using ``arr.x`` and ``arr.y``.
317
318 Parameters
319 ----------
320 shape : tuple
321 Shape of output array.
322 dtype : data-type, optional
323 The desired data-type. By default, the data-type is determined
324 from `formats`, `names`, `titles`, `aligned` and `byteorder`.
325 formats : list of data-types, optional
326 A list containing the data-types for the different columns, e.g.
327 ``['i4', 'f8', 'i4']``. `formats` does *not* support the new
328 convention of using types directly, i.e. ``(int, float, int)``.
329 Note that `formats` must be a list, not a tuple.
330 Given that `formats` is somewhat limited, we recommend specifying
331 `dtype` instead.
332 names : tuple of str, optional
333 The name of each column, e.g. ``('x', 'y', 'z')``.
334 buf : buffer, optional
335 By default, a new array is created of the given shape and data-type.
336 If `buf` is specified and is an object exposing the buffer interface,
337 the array will use the memory from the existing buffer. In this case,
338 the `offset` and `strides` keywords are available.
339
340 Other Parameters
341 ----------------
342 titles : tuple of str, optional
343 Aliases for column names. For example, if `names` were
344 ``('x', 'y', 'z')`` and `titles` is
345 ``('x_coordinate', 'y_coordinate', 'z_coordinate')``, then
346 ``arr['x']`` is equivalent to both ``arr.x`` and ``arr.x_coordinate``.
347 byteorder : {'<', '>', '='}, optional
348 Byte-order for all fields.
349 aligned : bool, optional
350 Align the fields in memory as the C-compiler would.
351 strides : tuple of ints, optional
352 Buffer (`buf`) is interpreted according to these strides (strides
353 define how many bytes each array element, row, column, etc.
354 occupy in memory).
355 offset : int, optional
356 Start reading buffer (`buf`) from this offset onwards.
357 order : {'C', 'F'}, optional
358 Row-major (C-style) or column-major (Fortran-style) order.
359
360 Returns
361 -------
362 rec : recarray
363 Empty array of the given shape and type.
364
365 See Also

Callers 6

addfieldFunction · 0.90
fromarraysFunction · 0.85
fromrecordsFunction · 0.85
fromstringFunction · 0.85
fromfileFunction · 0.85
arrayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected