-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
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 |
---|---|---|
|
@@ -887,15 +887,16 @@ def itertuples(self, index=True, name="Pandas"): | |
|
||
Parameters | ||
---------- | ||
index : boolean, default True | ||
index : bool, default True | ||
If True, return the index as the first element of the tuple. | ||
name : string, default "Pandas" | ||
name : str, default "Pandas" | ||
The name of the returned namedtuples or None to return regular | ||
tuples. | ||
|
||
Returns | ||
Yields | ||
------- | ||
Returns namedtuples. | ||
collections.namedtuple | ||
Yields namedtuples of corresponding index and column values. | ||
|
||
|
||
Notes | ||
----- | ||
|
@@ -910,17 +911,35 @@ 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']) | ||
>>> df = pd.DataFrame({'num_legs': [4,2], 'num_wings': [0,2]}, | ||
|
||
... index=['dog','hawk']) | ||
>>> df | ||
col1 col2 | ||
a 1 0.1 | ||
b 2 0.2 | ||
num_legs num_wings | ||
dog 4 0 | ||
hawk 2 2 | ||
>>> for row in df.itertuples(): | ||
... print(row) | ||
... | ||
Pandas(Index='a', col1=1, col2=0.1) | ||
Pandas(Index='b', col1=2, col2=0.2) | ||
Pandas(Index='dog', num_legs=4, num_wings=0) | ||
Pandas(Index='hawk', num_legs=2, num_wings=2) | ||
|
||
By setting the `index` parameter to False we can remove the index | ||
as the first element of the tuple: | ||
|
||
>>> for row in df.itertuples(index=False): | ||
... print(row) | ||
... | ||
Pandas(num_legs=4, num_wings=0) | ||
Pandas(num_legs=2, num_wings=2) | ||
|
||
With the `name` parameter set we set a custom name for the yielded | ||
namedtuples: | ||
|
||
>>> for row in df.itertuples(name='Animal'): | ||
... print(row) | ||
... | ||
Animal(Index='dog', num_legs=4, num_wings=0) | ||
Animal(Index='hawk', num_legs=2, num_wings=2) | ||
""" | ||
arrays = [] | ||
fields = [] | ||
|
Uh oh!
There was an error while loading. Please reload this page.