Ahdee - 7 months ago 28

Python Question

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.

- How do I find total columns:
- How do I find total rows:

thank you very much.

A

Answer

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
```