-
-
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
Merged
jorisvandenbossche
merged 9 commits into
pandas-dev:master
from
math-and-data:docstring_ndframe
Mar 10, 2018
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8ae5805
DOC: Improved the docstring of pandas.core.generic.NDFrame.values
math-and-data 3fc4398
DOC: Improved the docstring of pandas.DataFrame.values
math-and-data 3af7b88
DOC: Improved the docstring of pandas.DataFrame.values
math-and-data c6607eb
DOC: Improved the docstring of pandas.DataFrame.values
math-and-data 41a2691
DOC: Improved the docstring of pandas.DataFrame.values
math-and-data 4d510e1
DOC: Improved the docstring of pandas.DataFrame.values
math-and-data 3b1027d
DOC: Improved the docstring of pandas.DataFrame.values
math-and-data 7650e10
DOC: DataFrame.values grammar, user friendly text
math-and-data ca17a15
remove from_records
jorisvandenbossche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4232,7 +4232,55 @@ def as_matrix(self, columns=None): | |
|
||
@property | ||
def values(self): | ||
"""Numpy representation of NDFrame | ||
""" | ||
Return a Numpy representation of the DataFrame. | ||
|
||
Only the values in the DataFrame will be returned, the axes labels | ||
will be removed. | ||
|
||
Returns | ||
------- | ||
numpy.ndarray | ||
The values of the DataFrame | ||
|
||
Examples | ||
-------- | ||
A DataFrame where all columns are the same type (e.g., int64) results | ||
in an array of the same type. | ||
|
||
>>> df = pd.DataFrame({'age': [ 3, 29], | ||
... 'height': [94, 170], | ||
... 'weight': [31, 115]}) | ||
>>> df | ||
age height weight | ||
0 3 94 31 | ||
1 29 170 115 | ||
>>> df.dtypes | ||
age int64 | ||
height int64 | ||
weight int64 | ||
dtype: object | ||
>>> 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([[ 3, 94, 31], | ||
[ 29, 170, 115]], dtype=int64) | ||
|
||
A DataFrame with mixed type columns(e.g., str/object, int64, float32) | ||
results in an ndarray of the broadest type that accommodates these | ||
mixed types (e.g., object). | ||
|
||
>>> df2 = pd.DataFrame([('parrot', 24.0, 'second'), | ||
... ('lion', 80.5, 1), | ||
... ('monkey', np.nan, None)], | ||
... columns=('name', 'max_speed', 'rank')) | ||
>>> df2.dtypes | ||
name object | ||
max_speed float64 | ||
rank object | ||
dtype: object | ||
>>> df2.values | ||
array([['parrot', 24.0, 'second'], | ||
['lion', 80.5, 1], | ||
['monkey', nan, None]], dtype=object) | ||
|
||
Notes | ||
----- | ||
|
@@ -4243,8 +4291,15 @@ def values(self): | |
|
||
e.g. If the dtypes are float16 and float32, dtype will be upcast to | ||
float32. If dtypes are int32 and uint8, dtype will be upcast to | ||
int32. By numpy.find_common_type convention, mixing int64 and uint64 | ||
will result in a flot64 dtype. | ||
int32. By :func:`numpy.find_common_type` convention, mixing int64 | ||
and uint64 will result in a float64 dtype. | ||
|
||
See Also | ||
-------- | ||
pandas.DataFrame.from_records : Inverse operation; creating a | ||
DataFrame from an ndarray | ||
pandas.DataFrame.keys : Retrieving the 'info axis' (column names) | ||
pandas.DataFrame.columns : Retrieving the column names | ||
""" | ||
self._consolidate_inplace() | ||
return self._data.as_array(transpose=self._AXIS_REVERSED) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
from_array
could be a good option for aSee Also
section. If I'm not wrong it's kind of the inverse method.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 went with
from_records
, thank you for suggesting to include the inverse in that section.