-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Conversation
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.
Nice examples
pandas/core/generic.py
Outdated
Examples | ||
-------- | ||
>>> df = pd.DataFrame({ | ||
... 'col1' : ['A', 'A', 'B', np.nan, 'D', 'C', 'E', 'E', 'F'], |
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 extra space after you finish the string:
'col1':
Instead of:
'col1' :
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.
and being PEP8 compliant!
pandas/core/generic.py
Outdated
0 A 2 0 | ||
1 A 1 1 | ||
2 B 9 9 | ||
3 NaN 8 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.
Why are you adding a nan value?
This is creating a mixed type column. (floats and strings) is this intentional?
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.
NaN is used for marking missing values in string (object) dtype columns too, so this is OK.
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.
just copied from an example above, but I agree. It made sense in the sort_values
, but not really here.
pandas/core/generic.py
Outdated
4 D 7 2 | ||
|
||
Viewing the first n lines (three in this case) | ||
>>> df.head(n=3) |
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.
You don't need to specify n
the same thing can be achieved with:
df.head(3)
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18746 +/- ##
==========================================
+ Coverage 91.59% 91.59% +<.01%
==========================================
Files 153 153
Lines 51364 51364
==========================================
+ Hits 47046 47049 +3
+ Misses 4318 4315 -3
Continue to review full report at Codecov.
|
closes #18691
closes #16416