1

I read in a csv file and did some manipulations, and got an object x. When I use type(x), it returns numpy.matrixlib.defmatrix.matrix. I have never seen this type before and wondering if there is any difference between it and a commonly seen 'numpy matrix'. Thanks!

1 Answer 1

2

They are the same:

In [1]: import numpy as np

In [2]: np.matrix
Out[2]: numpy.matrixlib.defmatrix.matrix

In [3]: id(np.matrix)
Out[3]: 4300190472

In [4]: id(np.matrixlib.defmatrix.matrix)
Out[4]: 4300190472

In [5]: a = np.matrix([[1, 2], [3, 4]])

In [6]: type(a)
Out[6]: numpy.matrixlib.defmatrix.matrix

numpy.matrix is a more convenient name for numpy.matrixlib.defmatrix.matrix.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.