[Numpy-discussion] dimension along axis?
Charles R Harris
charlesr.harris at gmail.com
Mon Apr 13 21:47:37 EDT 2009
On Mon, Apr 13, 2009 at 7:40 PM, Grissiom <chaos.proton at gmail.com> wrote:
> Hi all,
>
> It there a convenience way to get dimension along an axis? Say I have two
> ndarray:
>
> li1 = np.array([2,3,4])
> li2 = np.array([[2,3,4],[5,6,7]])
>
> I know my list is in C order so the two array is the same in someway. But
> li1.shape will give (3, ) and li2.shape will give (2,3). "3" appear in
> different position so it's inconvenient to identify them. Is there anyway to
> get dimension along axis? (In this case should be axis0)
>
You mean something like this?
In [1]: li1 = np.array([2,3,4])
In [2]: li1[np.newaxis,:].shape
Out[2]: (1, 3)
Or maybe like this?
In [3]: li1 = np.array([[2,3,4]])
In [4]: li1.shape
Out[4]: (1, 3)
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090413/165ae802/attachment.html>
More information about the NumPy-Discussion
mailing list