Question:
given a ndarray:
In [2]: a
Out[2]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
I look for a routine giving me:
array([7, 8, 9, 0, 1])
Ex.: Starting at index 8, crossing the array boundarie and stopping at index 2 (included) If I use slicing, I (of course) get:
In [3]: a[-3:2]
Out[3]: array([], dtype=int64)
A possible answer:
Is to use the roll function.
In [5]: np.roll(a,3)[:5]
Out[5]: array([7, 8, 9, 0, 1])
What I look for:
What I do not like concerning this one, is that it is not as straightforward as slicing. So I look for something like:
In [6]: a.xxx[-3:2]
A syntax similar to this one exists for example in pandas.DataFrame.iloc. Thank you very much in advance!
Note: iloc, does not do what I want. I just reffered to the syntax (which i like). Thanks for the comment, cᴏʟᴅsᴘᴇᴇᴅ