DataFrame.iterrows

DataFrame.iterrows(sort_index: str | None = '_doc') Iterable[Tuple[str | Tuple[str, ...], Series]][source]

Iterate over opensearch_py_ml.DataFrame rows as (index, pandas.Series) pairs.

Parameters

sort_index: str, default ‘_doc’

What field to sort the OpenSearch data by.

Yields

index: index

The index of the row.

data: pandas Series

The data of the row as a pandas Series.

See Also

opensearch_py_ml.DataFrame.itertuples: Iterate over opensearch_py_ml.DataFrame rows as namedtuples.

Examples

>>> from tests import OPENSEARCH_TEST_CLIENT
>>> df = oml.DataFrame(OPENSEARCH_TEST_CLIENT, 'flights', columns=['AvgTicketPrice', 'Cancelled']).head()
>>> df
   AvgTicketPrice  Cancelled
0      841.265642      False
1      882.982662      False
2      190.636904      False
3      181.694216       True
4      730.041778      False

[5 rows x 2 columns]
>>> for index, row in df.iterrows():
...     print(row)
AvgTicketPrice    841.265642
Cancelled              False
Name: 0, dtype: object
AvgTicketPrice    882.982662
Cancelled              False
Name: 1, dtype: object
AvgTicketPrice    190.636904
Cancelled              False
Name: 2, dtype: object
AvgTicketPrice    181.694216
Cancelled               True
Name: 3, dtype: object
AvgTicketPrice    730.041778
Cancelled              False
Name: 4, dtype: object