pyspark.pandas.DataFrame.items¶
-
DataFrame.
items
() → Iterator[Tuple[Union[Any, Tuple[Any, …]], Series]][source]¶ Iterator over (column name, Series) pairs.
Iterates over the DataFrame columns, returning a tuple with the column name and the content as a Series.
- Returns
- labelobject
The column names for the DataFrame being iterated over.
- contentSeries
The column entries belonging to each label, as a Series.
Examples
>>> df = ps.DataFrame({'species': ['bear', 'bear', 'marsupial'], ... 'population': [1864, 22000, 80000]}, ... index=['panda', 'polar', 'koala'], ... columns=['species', 'population']) >>> df species population panda bear 1864 polar bear 22000 koala marsupial 80000
>>> for label, content in df.iteritems(): ... print('label:', label) ... print('content:', content.to_string()) ... ... label: species content: panda bear polar bear koala marsupial label: population content: panda 1864 polar 22000 koala 80000