-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: Improved the docstring of pandas.DataFrame.values #20065
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
8ae5805
3fc4398
3af7b88
c6607eb
41a2691
4d510e1
3b1027d
7650e10
ca17a15
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 |
---|---|---|
|
@@ -4232,7 +4232,35 @@ def as_matrix(self, columns=None): | |
|
||
@property | ||
def values(self): | ||
"""Numpy representation of NDFrame | ||
""" | ||
Generate and return a Numpy representation of NDFrame. | ||
|
||
Only the values in the NDFrame will be returned, the axes labels will | ||
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.
Yes, I know there are occurrences of NDFrame in the current docstrings, but that is exactly why we added the check in the validation script :). As that name should never be exposed to users. Now in this specific case: this docstring is actually only used for DataFrame (Series has a separate docstring), so you can just use "DataFrame" instead of "NDFrame" 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. I had noticed the inheritances - thank you for the clarification; I made the recommended changes |
||
be removed. | ||
|
||
Returns | ||
------- | ||
numpy.ndarray | ||
The values of the NDFrame | ||
|
||
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. I think 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. I went with |
||
Examples | ||
-------- | ||
>>> df = pd.DataFrame([('falcon', 'bird', 389.0), | ||
... ('parrot', 'bird', 24.0), | ||
... ('lion', 'mammal', 80.5), | ||
... ('monkey', 'mammal', np.nan)], | ||
... columns=('name', 'class', 'max_speed')) | ||
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. I think in this case it doesn't add so much value to have a so big example. But what IMO could be nice, is to show two examples, one with a numerical type, and another with mixed types. With some comments on how the data is casted to the most generic type ( 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. Excellent idea - I'll add a strictly numerical example. 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. That sounds great, I think the comment in |
||
>>> df | ||
name class max_speed | ||
0 falcon bird 389.0 | ||
1 parrot bird 24.0 | ||
2 lion mammal 80.5 | ||
3 monkey mammal NaN | ||
>>> df.values | ||
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. Can you show here |
||
array([['falcon', 'bird', 389.0], | ||
['parrot', 'bird', 24.0], | ||
['lion', 'mammal', 80.5], | ||
['monkey', 'mammal', nan]], dtype=object) | ||
|
||
Notes | ||
----- | ||
|
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 would maybe only use "Return" without the "generate" ?