Skip to content

Commit

Permalink
DOC iteritems docstring update and examples (pandas-dev#22658)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ecboxer authored and victor committed Sep 30, 2018
1 parent 9cdd357 commit eea97cb
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,14 +779,50 @@ def style(self):
return Styler(self)

def iteritems(self):
"""
r"""
Iterator over (column name, Series) pairs.
See also
Iterates over the DataFrame columns, returning a tuple with the column name
and the content as a Series.
Yields
------
label : object
The column names for the DataFrame being iterated over.
content : Series
The column entries belonging to each label, as a Series.
See Also
--------
iterrows : Iterate over DataFrame rows as (index, Series) pairs.
itertuples : Iterate over DataFrame rows as namedtuples of the values.
DataFrame.iterrows : Iterate over DataFrame rows as (index, Series) pairs.
DataFrame.itertuples : Iterate over DataFrame rows as namedtuples of the values.
Examples
--------
>>> df = pd.DataFrame({'species': ['bear', 'bear', 'marsupial'],
... 'population': [1864, 22000, 80000]},
... index=['panda', 'polar', 'koala'])
>>> df
species population
panda bear 1864
polar bear 22000
koala marsupial 80000
>>> for label, content in df.iteritems():
... print('label:', label)
... print('content:', content, sep='\n')
...
label: species
content:
panda bear
polar bear
koala marsupial
Name: species, dtype: object
label: population
content:
panda 1864
polar 22000
koala 80000
Name: population, dtype: int64
"""
if self.columns.is_unique and hasattr(self, '_item_cache'):
for k in self.columns:
Expand Down

0 comments on commit eea97cb

Please sign in to comment.