<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="">> That says, "This is a 0-length array of 3-char Unicode strings." Numpy<br>
> doesn't recognize the string as a specification of an array. Try<br>
> `np.array(4.)` and you'll get (IIRC) `array(4., dtype='float')`, which<br>
> has<br>
> shape `()`. Numpy probably won't let you index either one. What can you<br>
> even do with it?<br>
<br>
</span>In my poking around I found that you can index it with [()] or access<br>
with .item() and .itemset(value). Still seems more like a party trick<br>
than the well-reasoned practical implementation choice he implied it<br>
was.</blockquote><div><br></div><div>my apologies about the confusion, the dim=() was not the point, but rather that numpy treats the string as a monolithic object rather than disassembling it as it would do with other iterables. I was just trying to give the simplest possible example. </div><div><br></div><div>Numpy still does</div><div><br></div><div><div>>>> np.array([[1,2],[3,4]])</div><div>array([[1, 2],<br></div><div> [3, 4]])</div></div><div><div>>>> np.array([[1,2],[3,4]]).shape</div></div><div>(2, 2)<br></div><div><br></div><div>but not here</div><div><br></div><div><div>>>> np.array(['ab','cd'])</div><div>array(['ab', 'cd'], <br></div><div> dtype='<U2')</div></div><div>>>> np.array(['ab','cd']).shape<br></div><div><div>(2,)</div></div><div><br></div><div>-Alexander</div><div><br></div><div><br></div><div> </div></div>
</div></div>