Skip to content

Commit

Permalink
update deprecation of .as_matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
tp committed Nov 24, 2017
1 parent 7fd4b71 commit c5ef79b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3736,7 +3736,7 @@ def _get_bool_data(self):
def as_matrix(self, columns=None):
"""
DEPRECATED: This method will be removed in a future version.
Use :meth:`NDFrame.values` instead.
Use :meth:`DataFrame.values` instead.
Convert the frame to its Numpy-array representation.
Expand Down Expand Up @@ -3773,8 +3773,8 @@ def as_matrix(self, columns=None):
--------
pandas.DataFrame.values
"""
warnings.warn("This method will be removed in a future version. "
"Use ``.values`` instead.")
warnings.warn(".as_matrix will be removed in a future version. "
"Use .values instead.", FutureWarning, stacklevel=2)
self._consolidate_inplace()
if self._AXIS_REVERSED:
return self._data.as_matrix(columns).T
Expand Down
6 changes: 6 additions & 0 deletions pandas/tests/frame/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,12 @@ def test_values(self):
self.frame.values[:, 0] = 5.
assert (self.frame.values[:, 0] == 5).all()

def test_as_matrix_deprecated(self):
with tm.assert_produces_warning(FutureWarning):
result = self.frame.as_matrix()
expected = self.frame.values
tm.assert_numpy_array_equal(result, expected)

def test_deepcopy(self):
cp = deepcopy(self.frame)
series = cp['A']
Expand Down

0 comments on commit c5ef79b

Please sign in to comment.