Skip to main content
`Ctrl`+`K`

# Row

class astropy.table.Row(table, index)

  Bases: `object`

  A class to represent one row of a Table object.

  A Row object is returned when a Table object is indexed with an integer or when iterating over a table:

      >>> from astropy.table import Table
      >>> table = Table([(1, 2), (3, 4)], names=('a', 'b'),
      ...               dtype=('int32', 'int32'))
      >>> row = table[1]
      >>> row
      <Row index=1>
        a     b
      int32 int32
      ----- -----
          2     4
      >>> row['a']
      np.int32(2)
      >>> row[1]
      np.int32(4)

  Attributes Summary

  `colnames` |
  `columns` |
  `dtype` |
  `index` |
  `meta` |
  `table` |

  Methods Summary

  `as_void`() | Returns a read-only copy of the row values in the form of np.void or np.ma.mvoid objects.
  `get`(key[, default]) | Return the value for key if key is in the columns, else default.
  `keys`() |
  `values`() |

  Attributes Documentation

  colnames
  columns
  dtype
  index
  meta
  table

  Methods Documentation

  as_void()

    Returns a read-only copy of the row values in the form of np.void or np.ma.mvoid objects. This corresponds to the object types returned for row indexing of a pure numpy structured array or masked array. This method is slow and its use is discouraged when possible.

    Returns:
      void_row `numpy.void` or `numpy.ma.mvoid`

        Copy of row values. `numpy.void` if unmasked, `numpy.ma.mvoid` else.

  get(key, default=None, /)

    Return the value for key if key is in the columns, else default.

    Parameters:
      key `str`, positional-only

        The name of the column to look for.

      default `object`, optional, positional-only

        The value to return if the `key` is not among the columns.

    Returns:
      `object`

        The value in the `key` column of the row if present, `default` otherwise.

    Examples

        >>> from astropy.table import Table
        >>> t = Table({"a": [2., 3., 5.], "b": [7., 11., 13.]})
        >>> t[0].get("a")
        np.float64(2.0)
        >>> t[1].get("b", 0.)
        np.float64(11.0)
        >>> t[2].get("c", 0.)
        0.0

  keys()
  values()