Hi apologies for the newbie question, but I'm wondering if someone can help me with two questions. Example say I have this,
[[1,2,3],[10,2,2]]
I have two questions.
thank you very much. A
In the NumPy with the help of shape() function, we can find the number of rows and columns. In this function, we pass a matrix and it will return row and column number of the matrix. Return: The number of rows and columns.
Getting number of rows and columns is as simple as:
>>> import numpy as np >>> a=np.array([[1,2,3],[10,2,2]]) >>> num_rows, num_cols = a.shape >>> print num_rows, num_cols 2 3
import numpy as np a = np.array([[1,2,3],[10,2,2]]) num_rows = np.shape(a)[0] num_columns = np.shape(a)[1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With