-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Use |
||
|
||
Examples | ||
-------- | ||
|
||
>>> df = pd.DataFrame({'col1': [1, 2], 'col2': [0.1, 0.2]}, | ||
index=['a', 'b']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Continuation lines need to start with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, make sure the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha, I will make the changes. |
||
>>> df | ||
col1 col2 | ||
a 1 0.1 | ||
b 2 0.2 | ||
>>> for col in df.iteritems(): | ||
... print(col) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think something like next would make things easier to understand:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the edits! I rephrased the long description, changed the Yields section to cover label and content, prepended DataFrame. to the See Also examples, and reworked the Examples section to hopefully be more engaging. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you push the changes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got my git commands mixed up sheepishly, but it's pushed now |
||
... | ||
('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 asIterator
or 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.