[SciPy-User] Valid array assignment argument

Ivo Maljevic ivo.maljevic at gmail.com
Fri Feb 19 15:31:47 EST 2010


It looks like the second solution can be written in a shorter form:

np.r_[np.arange(10), 13, 15]

Ivo

On 19 February 2010 15:25, <josef.pktd at gmail.com> wrote:

> On Fri, Feb 19, 2010 at 3:21 PM, Benjamin J. Racine
> <bjracine at glosten.com> wrote:
> > Anybody know the pythonic way to get what I'm seeking with this line of
> invalid code...
> >
> > desired_columns = np.array([np.arange(10), 13, 15])
>
> indices need to be concatenated so they are not nested list/array
>
> >>> np.array(range(10) + [13, 15])
> array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 13, 15])
> >>> np.array(np.r_[np.arange(10), 13, 15])
> array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 13, 15])
>
> Josef
>
>
> >
> > Many thanks,
> > Ben R.
> > _______________________________________________
> > SciPy-User mailing list
> > SciPy-User at scipy.org
> > http://mail.scipy.org/mailman/listinfo/scipy-user
> >
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20100219/74c43623/attachment.html>


More information about the SciPy-User mailing list