numpy.copy / numpy.delete - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: numpy.copy / numpy.delete (/thread-20080.html) |
numpy.copy / numpy.delete - paul18fr - Jul-26-2019 Dear All I tried to copy a part of an array/matrix using numpy.copy; my first reaction was to write: n = 10; A = np.random.random( (n,5) ); B = np.copy(A[:, 0:3]);Nevertheless it does not work (single vector is obtained): how to proceed? Thanks for your advice(s) Paul RE: numpy.copy / numpy.delete - paul18fr - Jul-26-2019 I got ... stupid error RE: numpy.copy / numpy.delete - ThomasL - Jul-26-2019 It works perfect, maybe the result only doesn´t match your expectations? But first, Python is not Javascript, so forget using the ; at the end of the lines. np.copy(A[0, 0:3]) gives you the first three elements of the first row of A so that is definitly a single vector. What do you expect that it should return? RE: numpy.copy / numpy.delete - paul18fr - Jul-26-2019 yes it works; I've found my (stupid) error but I've been unable to supress the post. In any way thanks for your interest Paul |