Hello, @Pawan,

The as_matrix method is deprecated since 0.23.0, so you should use to_numpy instead.

I am giving you an example regarding your doubt:

For example let's assume we only need to convert the subset ['col1', 'col2', 'col4'] of our original DataFrame to a Numpy array. In that case, you might have some legacy code relying on as_matrix to convert, which looks more or less like:

df.as_matrix(['col1', 'col2', 'col4'])

While converting the above code to to_numpy you cannot simply replace the function name like in:

df.to_numpy(['col1', 'col2', 'col4']) # WRONG

because to_numpy does not accept a subset of columns as parameter. The solution, in that case, would be to do the selection first and apply to_numpy to the result, as in:

df[['col1', 'col2', 'col4']].to_numpy() # CORRECT