-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Adding example to head and tail method (#16416) #18749
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
Conversation
Hello @Cheukting! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on December 15, 2017 at 13:34 Hours UTC |
aca9e37
to
a9f5ad9
Compare
Codecov Report
@@ Coverage Diff @@
## master #18749 +/- ##
==========================================
- Coverage 91.63% 91.62% -0.02%
==========================================
Files 154 154
Lines 51422 51422
==========================================
- Hits 47121 47114 -7
- Misses 4301 4308 +7
Continue to review full report at Codecov.
|
5a9e68e
to
2a4f160
Compare
can you also add a See Also section to both .head & .tail, this could close #18691 |
looks like this duplicates #18746 and was a little before yours. Happy to have you contribute on any other issues though! |
@jreback, I think this PR is better than #18746. Sorry for the duplicate, they were both implemented in the same sprint, and people was supposed to notify on a gitter channel which methods they were working on, but we failed to do that successfully. This PR documents both head and tail, and I think the example is a bit clearer. I'd probably use a sorted dataframe for better clarity, and I agree with the "See also" section. Are you ok reopening this PR, and closing the other as duplicate? @Cheukting, can you add the See also section Jeff mentioned, and sort the dataframe so it's faster for people to see that the first or last rows are the ones returned? For the See also, in the head you should mention the tail, and viceversa. You have an example of See also section here: https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.isin.html |
yeah happy to have either |
d59fba4
to
26911dd
Compare
@jreback @datapythonista it is all done, let me know if there more changes needed :-) |
pandas/core/generic.py
Outdated
5 parrot | ||
6 shark | ||
|
||
Viewing the last 5 lines (the default) |
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.
last -> first
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.
Changes made
pandas/core/generic.py
Outdated
3 lion | ||
4 monkey | ||
|
||
Viewing the last n lines (three in this case) |
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.
same (actually needs editing as well)
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.
By editing you mean?
23a449c
to
14cc5cf
Compare
pandas/core/generic.py
Outdated
5 parrot | ||
6 shark | ||
|
||
Viewing the first 5 lines (the default) |
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 remove '(the default)' and from each of these (e.g. things in '()')
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.
Thanks, changes has been done :-)
9d16f4a
to
241a336
Compare
Can I also suggest of having animals starting with A and Z in the list. So it's even more obvious (and faster to see) that the returned rows are the first and the last? For example:
I think we can save couple of seconds on understanding the example of each new pandas user that visit these pages. Which given the number of users of pandas, can be a lot of time. :) |
99fdec4
to
018aad7
Compare
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.
Small comment
pandas/core/generic.py
Outdated
8 zebra | ||
|
||
Viewing the first 5 lines | ||
>>> df.head() |
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 keep a blank line between the explanation and the code line beginning with >>>
? (and the same for the other occurences)
This might be needed to satisfy sphinx (not fully sure), but I also think it improves readability
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.
Thanks, changes has been done :-)
0a982ee
to
0abe91c
Compare
pandas/core/generic.py
Outdated
|
||
Examples | ||
-------- | ||
>>> df = pd.DataFrame({'animal':['falcon', 'parrot', 'lion', |
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.
One last typo, this dataframe should also include alligator, bee... it's inconsistent with the results now.
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.
fixed 👍
43feae9
to
e730630
Compare
thanks @Cheukting |
closes #18691
git diff upstream/master -u -- "*.py" | flake8 --diff