Skip to main content
`Ctrl`+`K`

# pandas.DataFrame.__iter__

DataFrame.__iter__()

  Iterate over info axis.

  For a DataFrame this yields column names (labels); for a Series it yields the single name. Enables iteration over the object with `for col in df`.

  Returns:
    iterator

      Info axis as iterator.

  See also

  `DataFrame.items`

    Iterate over (column name, Series) pairs.

  `DataFrame.itertuples`

    Iterate over DataFrame rows as namedtuples.

  Examples

      >>> df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
      >>> for x in df:
      ...     print(x)
      A
      B