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
| 277 | |
| 278 | @set_module("numpy.rec") |
| 279 | class recarray(ndarray): |
| 280 | """Construct an ndarray that allows field access using attributes. |
| 281 | |
| 282 | Arrays may have a data-types containing fields, analogous |
| 283 | to columns in a spread sheet. An example is ``[(x, int), (y, float)]``, |
| 284 | where each entry in the array is a pair of ``(int, float)``. Normally, |
| 285 | these attributes are accessed using dictionary lookups such as ``arr['x']`` |
| 286 | and ``arr['y']``. Record arrays allow the fields to be accessed as members |
| 287 | of the array, using ``arr.x`` and ``arr.y``. |
| 288 | |
| 289 | Parameters |
| 290 | ---------- |
| 291 | shape : tuple |
| 292 | Shape of output array. |
| 293 | dtype : data-type, optional |
| 294 | The desired data-type. By default, the data-type is determined |
| 295 | from `formats`, `names`, `titles`, `aligned` and `byteorder`. |
| 296 | formats : list of data-types, optional |
| 297 | A list containing the data-types for the different columns, e.g. |
| 298 | ``['i4', 'f8', 'i4']``. `formats` does *not* support the new |
| 299 | convention of using types directly, i.e. ``(int, float, int)``. |
| 300 | Note that `formats` must be a list, not a tuple. |
| 301 | Given that `formats` is somewhat limited, we recommend specifying |
| 302 | `dtype` instead. |
| 303 | names : tuple of str, optional |
| 304 | The name of each column, e.g. ``('x', 'y', 'z')``. |
| 305 | buf : buffer, optional |
| 306 | By default, a new array is created of the given shape and data-type. |
| 307 | If `buf` is specified and is an object exposing the buffer interface, |
| 308 | the array will use the memory from the existing buffer. In this case, |
| 309 | the `offset` and `strides` keywords are available. |
| 310 | |
| 311 | Other Parameters |
| 312 | ---------------- |
| 313 | titles : tuple of str, optional |
| 314 | Aliases for column names. For example, if `names` were |
| 315 | ``('x', 'y', 'z')`` and `titles` is |
| 316 | ``('x_coordinate', 'y_coordinate', 'z_coordinate')``, then |
| 317 | ``arr['x']`` is equivalent to both ``arr.x`` and ``arr.x_coordinate``. |
| 318 | byteorder : {'<', '>', '='}, optional |
| 319 | Byte-order for all fields. |
| 320 | aligned : bool, optional |
| 321 | Align the fields in memory as the C-compiler would. |
| 322 | strides : tuple of ints, optional |
| 323 | Buffer (`buf`) is interpreted according to these strides (strides |
| 324 | define how many bytes each array element, row, column, etc. |
| 325 | occupy in memory). |
| 326 | offset : int, optional |
| 327 | Start reading buffer (`buf`) from this offset onwards. |
| 328 | order : {'C', 'F'}, optional |
| 329 | Row-major (C-style) or column-major (Fortran-style) order. |
| 330 | |
| 331 | Returns |
| 332 | ------- |
| 333 | rec : recarray |
| 334 | Empty array of the given shape and type. |
| 335 | |
| 336 | See Also |
no outgoing calls
no test coverage detected
searching dependent graphs…