<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Thanks Derek for quick clarification.<div class=""><br class=""></div><div class="">Just one more question from the details you have provided which from my understanding strongly seems to be Design  </div><div class="">[DEREK] <font color="#0433ff" class="">You cannot create a regular 2-dimensional integer array from one row of length 3</font><blockquote type="cite" class=""><font color="#ff2600" class="">and a second one of length 0. </font><font color="#0433ff" class="">Thus np.array chooses the next most basic type of<br class="">array it can fit your input data in</font></blockquote><div class=""><br class=""></div><div class="">   Which is the case,  only if an second one of length 0 is given.</div><div class="">   What about the case 1 :</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">>>> x12 = np.array([[1,2,3]])</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">>>> x12</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">array([[1, 2, 3]])</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">>>> print(x12)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">[[1 2 3]]</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">>>> x12.ndim</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">2</span></div><div class="">>>></div><div class="">>>></div><div class="">This seems to take 2 dimension.</div><div class="">I presumed the above case and the case where length 0 is provided to be treated same(I mean same behaviour).</div><div class="">Correct me if I am wrong.</div><div class=""><br class=""></div><div class="">Also, could u please point out any documentation to understand the logic behind creating elements of type list in case 2(with second grid of length 0) ? If possible. I am curious to understand.</div><div class=""> </div><div class="">Kind Rgds,</div><div class="">Vinodhini B</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 30 Dec 2017, at 11:36 PM, Derek Homeier <<a href="mailto:derek@astro.physik.uni-goettingen.de" class="">derek@astro.physik.uni-goettingen.de</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">On 30 Dec 2017, at 11:37 am, Vinodhini Balusamy <<a href="mailto:me.vinob@gmail.com" class="">me.vinob@gmail.com</a>> wrote:<br class=""><blockquote type="cite" class=""><br class="">Case 2:<br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><br class="">x12 = np.array([[1,2,3],[]])<br class="">x12.ndim<br class=""></blockquote></blockquote></blockquote>1<br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class="">print(x12)<br class=""></blockquote></blockquote></blockquote>[list([1, 2, 3]) list([])]<br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><br class=""></blockquote></blockquote></blockquote>   In case 2, I am trying to understand why it becomes 1 dimentional ?!?!<br class=""><br class=""><br class="">Case 3:<br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><br class="">x12 = np.array([1,2,3])<br class="">x12.ndim<br class=""></blockquote></blockquote></blockquote>1<br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class="">print(x12)<br class=""></blockquote></blockquote></blockquote>[1 2 3]<br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><br class=""></blockquote></blockquote></blockquote>     This seems reasonable to me to be considered as 1 dimensional.<br class=""><br class="">Would like to understand case 2 a bit more to get to know if i am missing something.<br class="">Will be much appreciated if someone to explain me a bit.<br class=""><br class=""></blockquote>Welcome to the crowd!<br class="">You cannot create a regular 2-dimensional integer array from one row of length 3<br class="">and a second one of length 0. Thus np.array chooses the next most basic type of<br class="">array it can fit your input data in - you will notice in case 2 the array actually has two<br class="">elements of type ‘list’, and you can verify that<br class=""><br class="">In [1]: x12 = np.array([[1,2,3],[]])<br class="">In [2]: x12.dtype<br class="">Out[2]: dtype('O')<br class="">In [3]: x12.shape<br class="">Out[3]: (2,)<br class=""><br class="">i.e. it has created an array of dtype ‘object’, which is probably not what you expected<br class="">(and nothing you could perform standard arithmetic operations on:<br class=""><br class="">In [4]: x12+1<br class="">TypeError: can only concatenate list (not "int") to list<br class=""><br class="">HTH<br class=""><span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span>Derek<br class=""><br class="">_______________________________________________<br class="">NumPy-Discussion mailing list<br class=""><a href="mailto:NumPy-Discussion@python.org" class="">NumPy-Discussion@python.org</a><br class="">https://mail.python.org/mailman/listinfo/numpy-discussion<br class=""></div></div></blockquote></div><br class=""></div></body></html>