-
-
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
DOC:Improve the docstring of DataFrame.iloc() #20228
Conversation
Hello @tuhinmahmud! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on July 07, 2018 at 19:10 Hours UTC |
pandas/core/indexing.py
Outdated
0 1 2 3 4 | ||
1 100 200 300 400 | ||
|
||
ref:`Selection by Position <indexing.integer>` |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
moved it to "extended summary"
pandas/core/indexing.py
Outdated
See more at :ref:`Selection by Position <indexing.integer>` | ||
See Also | ||
-------- | ||
DataFrame.ix : A primarily label-location based indexer |
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.
ix is deprecated, you can remove.
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.
done
pandas/core/indexing.py
Outdated
See Also | ||
-------- | ||
DataFrame.ix : A primarily label-location based indexer | ||
DataFrame.loc : Fast integer location scalar accessor. |
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:
- DataFrame.ix : A primarily label-location based indexer
- DataFrame.loc : Fast integer location scalar accessor.
- DataFrame.iat : Fast integer location scalar accessor.
- DataFrame.loc : Purely label-location based indexer for selection by label.
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
pandas/core/indexing.py
Outdated
-------- | ||
>>> import pandas as pd | ||
>>> 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
updated the double spaces with single
pandas/core/indexing.py
Outdated
Name: 0, dtype: int64 | ||
>>> print(df.iloc[0:2]) | ||
a b c d | ||
0 1 2 3 4 |
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.
formatting seems a bit off. Can you double check this?
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.
reran the command and updated.
pandas/core/indexing.py
Outdated
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
took off the prints
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.
ok
pandas/core/indexing.py
Outdated
0 1 2 3 4 | ||
1 100 200 300 400 | ||
|
||
ref:`Selection by Position <indexing.integer>` |
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.
moved it to "extended summary"
See Also | ||
-------- | ||
DataFrame.iat : Fast integer location scalar accessor. | ||
DataFrame.loc : Purely label-location based indexer for selection by label. |
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.
add Series.iloc
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.
added Series.iloc
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.
Can you look at other PRs for those accessors to have a consistent way to reference them? See eg https://github.com/pandas-dev/pandas/pull/20229/files, They use:
DateFrame.at : Access a single value for a row/column label pair
DateFrame.iloc : Access group of rows and columns by integer position(s)
Series.loc : Access group of values using labels
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.
@tuhinmahmud make sure to pull my changes before looking into this.
pandas/core/indexing.py
Outdated
|
||
Examples | ||
-------- | ||
>>> import pandas as pd |
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.
don't need the pandas import
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.
removed pandas import
pandas/core/indexing.py
Outdated
-------- | ||
>>> import pandas as pd | ||
>>> 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 comment
The reason will be displayed to describe this comment to others. Learn more.
need to indent here
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.
undated the indentation
pandas/core/indexing.py
Outdated
0 1 2 3 4 | ||
1 100 200 300 400 | ||
2 1000 2000 3000 4000 | ||
>>> df.iloc[0] |
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.
blank lines between cases.
show additional examples, including selecting with .iloc[0] vs .iloc[[0]], and use a multi-axis selction .iloc[0, 0] and lists for the last, e.g. .iloc[[0, 1], [0, 1]]
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.
also add a sentence for each case explaining it.
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.
added sentences and put different types of example of .iloc in paragraph
added 5 types of examples for iloc * Select using integer.r * Select via index slicing. * Select using boolean array. * Select using callable function. * Multi index selection. Updated indentation removed import
@tuhinmahmud pushed an update to your examples to make the ordering a bit more logical. We now show each of the valid indexer values (scalar, sequence, slice, mask, callable) for just indexing the rows. Then we show the same for rows and 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.
made requested changes
i) Remove ix and update loc description
ii) removed pandas import
iii) single space issue
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.
Looks good.. Do you know what is the next step to get it commited?
…ent_sprint_03_2018
Codecov Report
@@ Coverage Diff @@
## master #20228 +/- ##
=========================================
Coverage ? 91.95%
=========================================
Files ? 160
Lines ? 49837
Branches ? 0
=========================================
Hits ? 45830
Misses ? 4007
Partials ? 0
Continue to review full report at Codecov.
|
Merged in master to restart the CI. They were complaining about a non-ASCII character, but that may have been on master when you made the PR, and not in your actual branch. Ping if you notice that the tests all pass before we do. |
@TomAugspurger Hi .. I am kind of lost as to what I can do to make it work .. I see one of the test continuous-integration/travi-ci/pr failing.. not sure what to make of it |
Sometimes travis jobs take much longer than others, and exceed Travis' time limit. I restarted that one. |
Looks like everything was addressed. Will merge on green since it looks like CI caught an issue before. |
Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):
scripts/validate_docstrings.py <your-function-or-method>
git diff upstream/master -u -- "*.py" | flake8 --diff
python doc/make.py --single <your-function-or-method>
Please include the output of the validation script below between the "```" ticks:
If the validation script still gives errors, but you think there is a good reason
to deviate in this case (and there are certainly such cases), please state this
explicitly.
Error Returned because Class do not need return