-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC:Improve the docstring of DataFrame.iloc() #20228
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
28222cd
e5dc827
9b103c1
76271f6
9cda098
1ede54b
a72f864
3d10bd8
f553ceb
100b62e
dfd8be0
329b05b
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 |
---|---|---|
|
@@ -1629,7 +1629,8 @@ def _getitem_axis(self, key, axis=None): | |
|
||
|
||
class _iLocIndexer(_LocationIndexer): | ||
"""Purely integer-location based indexing for selection by position. | ||
""" | ||
Purely integer-location based indexing for selection by position. | ||
|
||
``.iloc[]`` is primarily integer position based (from ``0`` to | ||
``length-1`` of the axis), but may also be used with a boolean | ||
|
@@ -1648,8 +1649,35 @@ class _iLocIndexer(_LocationIndexer): | |
out-of-bounds, except *slice* indexers which allow out-of-bounds | ||
indexing (this conforms with python/numpy *slice* semantics). | ||
|
||
See more at :ref:`Selection by Position <indexing.integer>` | ||
See Also | ||
-------- | ||
DataFrame.ix : A primarily label-location based indexer, with integer position fallback. | ||
DataFrame.loc : Fast integer location scalar accessor. | ||
|
||
Examples | ||
-------- | ||
>>> import pandas as pd | ||
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. don't need the pandas import 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. removed pandas import |
||
>>> mydict = [{'a': 1, 'b': 2, 'c': 3, 'd': 4}, | ||
... {'a': 100, 'b': 200, 'c': 300, 'd': 400}, | ||
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. PEP8: single spaces. 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. updated the double spaces with single |
||
... {'a': 1000, 'b': 2000, 'c': 3000, 'd': 4000 }] | ||
>>> df = pd.DataFrame(mydict) | ||
>>> print(df.head()) | ||
a b c d | ||
0 1 2 3 4 | ||
1 100 200 300 400 | ||
2 1000 2000 3000 4000 | ||
>>> print(df.iloc[0]) | ||
a 1 | ||
b 2 | ||
c 3 | ||
d 4 | ||
Name: 0, dtype: int64 | ||
>>> print(df.iloc[0:2]) | ||
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. don't need the prints here and above 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. took off the prints |
||
a b c d | ||
0 1 2 3 4 | ||
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. formatting seems a bit off. Can you double check this? 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. reran the command and updated. |
||
1 100 200 300 400 | ||
|
||
ref:`Selection by Position <indexing.integer>` | ||
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. Could you use the "extended summary" section for this, right below the opening summary? I think the prose docs are the most important for indexing, and I don't want them to get lost. 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. moved it to "extended summary" |
||
""" | ||
|
||
_valid_types = ("integer, integer slice (START point is INCLUDED, END " | ||
|
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 think you may want the " A primarily label-location based indexer" for the .loc description.
You may be thinking of
DataFrame.iat
for this dsecription.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.
Remove ix and update loc description:
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.
missed your comment about .loc .. but instead got the description from https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.loc.html