-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: #22899, Fixed docstring of itertuples in pandas/core/frame.py #22902
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
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 |
---|---|---|
|
@@ -883,8 +883,7 @@ def iterrows(self): | |
|
||
def itertuples(self, index=True, name="Pandas"): | ||
""" | ||
Iterate over DataFrame rows as namedtuples, with index value as first | ||
element of the tuple. | ||
Iterate over DataFrame rows as namedtuples. | ||
|
||
Parameters | ||
---------- | ||
|
@@ -894,6 +893,10 @@ def itertuples(self, index=True, name="Pandas"): | |
The name of the returned namedtuples or None to return regular | ||
datapythonista marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tuples. | ||
|
||
Returns | ||
------- | ||
Returns namedtuples. | ||
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. In this case instead of The exact syntax would be something like:
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. Got it! Working on it now. |
||
|
||
Notes | ||
----- | ||
The column names will be renamed to positional names if they are | ||
|
@@ -907,19 +910,17 @@ def itertuples(self, index=True, name="Pandas"): | |
|
||
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. In 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. Ok, just prefixed both |
||
Examples | ||
-------- | ||
|
||
>>> df = pd.DataFrame({'col1': [1, 2], 'col2': [0.1, 0.2]}, | ||
index=['a', 'b']) | ||
... 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. In general I think it's better to have data that somehow looks real. I think it helps understand better, as you don't need to check in the DataFrame constructor that the row a, in the col2, has a 0.1. It's self-contained that a cat has 4 legs (see this example: https://github.com/pandas-dev/pandas/blob/master/pandas/core/frame.py#L7580). Also, if you can also one examples 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. Awesome. I really like the animal ideas, it is super intuitive! I made the changes as such and will push it up now.
|
||
>>> df | ||
col1 col2 | ||
a 1 0.1 | ||
b 2 0.2 | ||
>>> for row in df.itertuples(): | ||
... print(row) | ||
... | ||
Pandas(Index='a', col1=1, col2=0.10000000000000001) | ||
Pandas(Index='b', col1=2, col2=0.20000000000000001) | ||
|
||
Pandas(Index='a', col1=1, col2=0.1) | ||
Pandas(Index='b', col1=2, col2=0.2) | ||
""" | ||
arrays = [] | ||
fields = [] | ||
|
Uh oh!
There was an error while loading. Please reload this page.