[Numpy-discussion] Inplace shift
Zachary Pincus
zachary.pincus@yale....
Fri Jun 6 14:08:26 CDT 2008
> I'd like to shift the columns of a 2d array one column to the right.
> Is there a way to do that without making a copy?
I think what you want is numpy.roll?
Definition: numpy.roll(a, shift, axis=None)
Docstring:
Roll the elements in the array by 'shift' positions along
the given axis.
>>> from numpy import roll
>>> arange(10)
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> roll(arange(10), 2)
array([8, 9, 0, 1, 2, 3, 4, 5, 6, 7])
Zach
More information about the Numpy-discussion
mailing list