Skip to content

Commit 3584977

Browse files
Merge pull request #7417 from clham/7413
DOC: update df.as_matrix and df.values. Closes gh7413
2 parents 9015e43 + 8536e05 commit 3584977

File tree

1 file changed

+41
-15
lines changed

1 file changed

+41
-15
lines changed

pandas/core/generic.py

+41-15
Original file line numberDiff line numberDiff line change
@@ -1929,25 +1929,39 @@ def _get_bool_data(self):
19291929

19301930
def as_matrix(self, columns=None):
19311931
"""
1932-
Convert the frame to its Numpy-array matrix representation. Columns
1933-
are presented in sorted order unless a specific list of columns is
1934-
provided.
1935-
1936-
NOTE: the dtype will be a lower-common-denominator dtype (implicit
1937-
upcasting) that is to say if the dtypes (even of numeric types)
1938-
are mixed, the one that accommodates all will be chosen use this
1939-
with care if you are not dealing with the blocks
1940-
1941-
e.g. if the dtypes are float16,float32 -> float32
1942-
float16,float32,float64 -> float64
1943-
int32,uint8 -> int32
1944-
1932+
Convert the frame to its Numpy-array representation.
1933+
1934+
Parameters
1935+
----------
1936+
columns: list, optional, default:None
1937+
If None, return all columns, otherwise, returns specified columns.
19451938
19461939
Returns
19471940
-------
19481941
values : ndarray
19491942
If the caller is heterogeneous and contains booleans or objects,
1950-
the result will be of dtype=object
1943+
the result will be of dtype=object. See Notes.
1944+
1945+
1946+
Notes
1947+
-----
1948+
Return is NOT a Numpy-matrix, rather, a Numpy-array.
1949+
1950+
The dtype will be a lower-common-denominator dtype (implicit
1951+
upcasting); that is to say if the dtypes (even of numeric types)
1952+
are mixed, the one that accommodates all will be chosen. Use this
1953+
with care if you are not dealing with the blocks.
1954+
1955+
e.g. If the dtypes are float16 and float32, dtype will be upcast to
1956+
float32. If dtypes are int32 and uint8, dtype will be upcase to
1957+
int32.
1958+
1959+
This method is provided for backwards compatibility. Generally,
1960+
it is recommended to use '.values'.
1961+
1962+
See Also
1963+
--------
1964+
pandas.DataFrame.values
19511965
"""
19521966
self._consolidate_inplace()
19531967
if self._AXIS_REVERSED:
@@ -1956,7 +1970,19 @@ def as_matrix(self, columns=None):
19561970

19571971
@property
19581972
def values(self):
1959-
"Numpy representation of NDFrame"
1973+
"""Numpy representation of NDFrame
1974+
1975+
Notes
1976+
-----
1977+
The dtype will be a lower-common-denominator dtype (implicit
1978+
upcasting); that is to say if the dtypes (even of numeric types)
1979+
are mixed, the one that accommodates all will be chosen. Use this
1980+
with care if you are not dealing with the blocks.
1981+
1982+
e.g. If the dtypes are float16 and float32, dtype will be upcast to
1983+
float32. If dtypes are int32 and uint8, dtype will be upcase to
1984+
int32.
1985+
"""
19601986
return self.as_matrix()
19611987

19621988
@property

0 commit comments

Comments
 (0)