-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
DOC iteritems docstring update and examples #22658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
0521552
5447a1f
8ccd554
fcc27e8
6dad21c
25da7f8
30026a4
5110b7c
76243b3
1b52a08
618318c
d8e5370
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -726,13 +726,32 @@ def style(self): | |
|
|
||
| def iteritems(self): | ||
| """ | ||
| Iterator over (column name, Series) pairs. | ||
| Iterate over DataFrame columns as (column name, Series) pairs. | ||
|
|
||
| See also | ||
| -------- | ||
| iterrows : Iterate over DataFrame rows as (index, Series) pairs. | ||
| itertuples : Iterate over DataFrame rows as namedtuples of the values. | ||
|
||
|
|
||
| Examples | ||
| -------- | ||
|
|
||
| >>> df = pd.DataFrame({'col1': [1, 2], 'col2': [0.1, 0.2]}, | ||
| index=['a', 'b']) | ||
|
||
| >>> df | ||
| col1 col2 | ||
| a 1 0.1 | ||
| b 2 0.2 | ||
| >>> for col in df.iteritems(): | ||
| ... print(col) | ||
|
||
| ... | ||
| ('col1', a 1 | ||
| b 2 | ||
| Name: col1, dtype: int64) | ||
| ('col2', a 0.1 | ||
| b 0.2 | ||
| Name: col2, dtype: float64) | ||
|
|
||
| """ | ||
| if self.columns.is_unique and hasattr(self, '_item_cache'): | ||
| for k in self.columns: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this returns an
Iterator(or more specifically aGenerator). So I would leave this asIteratoror change this toGenerator.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought to make the change to 'Iterate over DataFrame ... as (..., Series) pairs to stay within the style of the iterrows and itertuples functions, but I can revert back to 'Iterator over (column name, Series) pairs.