[SciPy-user] inverse of column_stack

Ryan Krauss ryanlists at gmail.com
Tue Feb 21 09:11:18 CST 2006


I think we misunderstood one another.  I want to iterate over the
columns of a matrix I already have.  This does what I want, I just
wondered if there was one built-in function that does this (or if
tolist could have an axis argument):

In [54]: a=rand(4,3)

In [55]: a
Out[55]:
array([[ 0.98852747,  0.63751158,  0.49660263],
       [ 0.46143525,  0.19731989,  0.9668494 ],
       [ 0.78013891,  0.5187305 ,  0.74449523],
       [ 0.67888293,  0.80072502,  0.10930396]])

In [56]: a[0]
Out[56]: array([ 0.98852747,  0.63751158,  0.49660263])

In [57]: b=(a.tra
a.trace      a.transpose

In [57]: b=(a.transpose()).tolist()

In [58]: b
Out[58]:
[[0.98852746688978599,
  0.4614352515957133,
  0.7801389135899337,
  0.67888292673582395],
 [0.63751157798107616,
  0.19731989336625744,
  0.5187305017688113,
  0.80072502069726714],
 [0.49660262671527189,
  0.96684939764919231,
  0.74449523248153027,
  0.10930396251760111]]

In [59]: b[0]
Out[59]:
[0.98852746688978599,
 0.4614352515957133,
 0.7801389135899337,
 0.67888292673582395]


Ryan

On 2/21/06, Nils Wagner <nwagner at mecha.uni-stuttgart.de> wrote:
> Ryan Krauss wrote:
> >Is there an inverse function to column_stack?  i.e. I want to iterate
> >over the columns of a matrix.  I could first transpose it and then
> >call tolist, but I was wondering if there was some clean, fast, built
> >in way that I wasn't aware of.
> >
> >Thanks,
> >
> >Ryan
> >
> >_______________________________________________
> >SciPy-user mailing list
> >SciPy-user at scipy.net
> >http://www.scipy.net/mailman/listinfo/scipy-user
> >
> >>> a = rand(4*3)
> >>> a
> array([ 0.45210275,  0.45554869,  0.27096599,  0.72289623,  0.28874549,
>         0.60064951,  0.36406786,  0.97709256,  0.68812732,  0.73081783,
>         0.07033917,  0.50299293])
> >>> a = transpose(reshape(a,(4,3)))
> >>> a
> array([[ 0.45210275,  0.72289623,  0.36406786,  0.73081783],
>        [ 0.45554869,  0.28874549,  0.97709256,  0.07033917],
>        [ 0.27096599,  0.60064951,  0.68812732,  0.50299293]])
>
>  Nils
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user
>



More information about the SciPy-user mailing list