[Numpy-discussion] array - dimension size of 1-D and 2-D examples
Vinodhini Balusamy
me.vinob at gmail.com
Sat Dec 30 05:37:09 EST 2017
Hi,
I am new to bumpy and started working on basics.
I need clarification for the below behaviour.
case 1:
>>> x12 = np.array([[1,2,3]])
>>> print(x12)
[[1 2 3]]
>>> x12.ndim
2
>>>
Tried creating a 2-D array.
also,
>>> x12 = np.array([[1,2,3],[0,0,0]])
>>> print(x12)
[[1 2 3]
[0 0 0]]
>>> x12.ndim
2
>>>
Case 2:
>>>
>>> x12 = np.array([[1,2,3],[]])
>>> x12.ndim
1
>>> print(x12)
[list([1, 2, 3]) list([])]
>>>
In case 2, I am trying to understand why it becomes 1 dimentional ?!?!
Case 3:
>>>
>>> x12 = np.array([1,2,3])
>>> x12.ndim
1
>>> print(x12)
[1 2 3]
>>>
This seems reasonable to me to be considered as 1 dimensional.
Would like to understand case 2 a bit more to get to know if i am missing something.
Will be much appreciated if someone to explain me a bit.
Thanks in advance.
Regards,
Vinodhini B
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20171230/de115d0a/attachment.html>
More information about the NumPy-Discussion
mailing list