craftutils.wrap.dragons.Table.iterrows(*names)

Iterate over rows of table returning a tuple of values for each row.

This method is especially useful when only a subset of columns are needed.

The iterrows method can be substantially faster than using the standard Table row iteration (e.g. for row in tbl:), since that returns a new ~astropy.table.Row object for each row and accessing a column in that row (e.g. row['col0']) is slower than tuple access.

Parameters

nameslist

List of column names (default to all columns if no names provided)

Returns

rowsiterable

Iterator returns tuples of row values

Examples

Create a table with three columns ‘a’, ‘b’ and ‘c’:

>>> t = Table({'a': [1, 2, 3],
...            'b': [1.0, 2.5, 3.0],
...            'c': ['x', 'y', 'z']})

To iterate row-wise using column names:

>>> for a, c in t.iterrows('a', 'c'):
...     print(a, c)
1 x
2 y
3 z