Ohm
Ohm

Reputation: 2442

Iterate over rows of astropy.table Table object

What is the smartest way to iterate over rows of a Table object from astropy.table?

Is it something like:

for row in table:
    ....

?

Upvotes: 1

Views: 2603

Answers (1)

Tom Aldcroft
Tom Aldcroft

Reputation: 2542

Iterating over table rows works as expected:

>>> from astropy.table import Table
>>> table = Table([[1, 2, 3], ['a', 'b', 'c']])
>>> for row in table:
...     print row['col0'], row['col1']
...     
1 a
2 b
3 c

Upvotes: 6

Related Questions