Skip to content
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

Add example to Dataframe.head() method's docstring. #18746

Closed
wants to merge 5 commits into from

Conversation

dpshelio
Copy link

@dpshelio dpshelio commented Dec 12, 2017

closes #18691
closes #16416

Copy link

@s3bw s3bw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice examples

Examples
--------
>>> df = pd.DataFrame({
... 'col1' : ['A', 'A', 'B', np.nan, 'D', 'C', 'E', 'E', 'F'],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra space after you finish the string:

'col1': 

Instead of:
'col1' :

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and being PEP8 compliant!

0 A 2 0
1 A 1 1
2 B 9 9
3 NaN 8 4
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you adding a nan value?
This is creating a mixed type column. (floats and strings) is this intentional?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NaN is used for marking missing values in string (object) dtype columns too, so this is OK.

Copy link
Author

@dpshelio dpshelio Dec 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just copied from an example above, but I agree. It made sense in the sort_values, but not really here.

4 D 7 2

Viewing the first n lines (three in this case)
>>> df.head(n=3)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to specify n
the same thing can be achieved with:

df.head(3)

@codecov
Copy link

codecov bot commented Dec 12, 2017

Codecov Report

Merging #18746 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #18746      +/-   ##
==========================================
- Coverage   91.59%   91.57%   -0.02%     
==========================================
  Files         153      153              
  Lines       51364    51364              
==========================================
- Hits        47046    47037       -9     
- Misses       4318     4327       +9
Flag Coverage Δ
#multiple 89.44% <ø> (ø) ⬆️
#single 40.74% <ø> (-0.12%) ⬇️
Impacted Files Coverage Δ
pandas/core/generic.py 95.9% <ø> (ø) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.81% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 96439fb...439f6be. Read the comment docs.

@codecov
Copy link

codecov bot commented Dec 12, 2017

Codecov Report

Merging #18746 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #18746      +/-   ##
==========================================
+ Coverage   91.59%   91.59%   +<.01%     
==========================================
  Files         153      153              
  Lines       51364    51364              
==========================================
+ Hits        47046    47049       +3     
+ Misses       4318     4315       -3
Flag Coverage Δ
#multiple 89.46% <ø> (+0.02%) ⬆️
#single 40.74% <ø> (-0.12%) ⬇️
Impacted Files Coverage Δ
pandas/core/generic.py 95.9% <ø> (ø) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.81% <0%> (-0.1%) ⬇️
pandas/plotting/_converter.py 66.52% <0%> (+1.73%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 96439fb...0ac5fab. Read the comment docs.

@jreback jreback added the Docs label Dec 13, 2017
@jreback
Copy link
Contributor

jreback commented Dec 13, 2017

so you are before #18746 so if you want to add an example for .tail and a See Also section (closes #18691) would be great.

@jreback jreback added the Output-Formatting __repr__ of pandas objects, to_string label Dec 13, 2017
@jreback
Copy link
Contributor

jreback commented Dec 15, 2017

superseded by #18749

thanks @dpshelio love to have your contribution on another issue!

@jreback jreback closed this Dec 15, 2017
@dpshelio dpshelio deleted the DFheadDocs branch December 16, 2017 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an ends function that shows both head and tail of the df DOC: add examples to docstrings
4 participants