[SciPy-User] Valid array assignment argument

josef.pktd at gmail.com josef.pktd at gmail.com
Fri Feb 19 15:25:53 EST 2010


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
>



More information about the SciPy-User mailing list