Python Forum
numpy.copy / numpy.delete
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
numpy.copy / numpy.delete
#1
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
Reply
#2
I got ... stupid error
Reply
#3
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?
Reply
#4
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Numpy: repeat cells variable number of times paul18fr 0 1,127 Nov-22-2024, 06:34 PM
Last Post: paul18fr
  TypeError: '>' not supported between instances of 'numpy.str_' and 'int' Anouar 0 1,003 Apr-26-2024, 09:34 AM
Last Post: Anouar
  Bitwise Operations in numpy Sowmya 3 1,567 Apr-03-2024, 02:51 PM
Last Post: deanhystad
  [Numpy] How to store different data type in one numpy array? water 7 2,866 Mar-26-2024, 02:18 PM
Last Post: snippsat
  [Numpy] Load date/time from .txt to 'datetime64' type. water 4 3,148 Mar-01-2024, 11:16 PM
Last Post: Gribouillis
  numpy.ufunc - Arguments missunderstand MarioBruza 0 1,410 Jan-11-2023, 05:03 AM
Last Post: MarioBruza
  reshaping 2D numpy array paul18fr 3 2,165 Jan-03-2023, 06:45 PM
Last Post: paul18fr
  Pandas dataframes and numpy arrays bytecrunch 1 2,095 Oct-11-2022, 08:08 PM
Last Post: Larz60+
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 4,199 Jul-19-2022, 06:31 AM
Last Post: paul18fr
Question about Numpy indexing. water 1 2,143 Jan-18-2022, 09:52 PM
Last Post: paul18fr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020