View onto a numpy array?

+1 vote

View Onto A NumPy Array
I have a 2D numpy array. Is there a way to create a view onto it that would include the first k rows and all columns?

Apr 15, 2018 in Python by ana1504.k
• 5,990 points
34 views

2 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

It;s really easy, just specify the index value, for example:
x-> NumPy Array, K-> Rows that you want.
x[:k, :]

answered Apr 15, 2018 by anto.trigg4
• 3,420 points
+1 vote

 just index it as you normally would. E.g. y = x[:k, :] This will return a view into the original array. No data will be copied, and any updates made to y will be reflected in x and vice versa.

answered Oct 18, 2018 by roberto

Related Questions In Python

0 votes
1 answer

Is an array a view of another?

The array has a base attribute, as ...READ MORE

answered Apr 23 in Python by SDeb
• 9,540 points
11 views
0 votes
1 answer
0 votes
1 answer

How can I define a multidimensional array in python using ctype?

Here's one quick-and-dirty method: >>> A = ((ctypes.c_float ...READ MORE

answered Oct 9, 2018 in Python by ariaholic
• 7,320 points
116 views
0 votes
1 answer

How to save Numpy array as image in python?

If you have matplotlib, you can do: import ...READ MORE

answered Nov 16, 2018 in Python by Nymeria
• 3,500 points
582 views
0 votes
1 answer

Dictionary in NumPy array

You have a 0-dimensional array of object ...READ MORE

answered Jan 18 in Python by SDeb
• 9,540 points
255 views
0 votes
1 answer

Shift all indices in NumPy array

You can use the following : y = ...READ MORE

answered Feb 26 in Python by SDeb
• 9,540 points
49 views
0 votes
1 answer

Printing a large numpy array

numpy.set_printoptions(threshold='nan') READ MORE

answered Jul 20, 2018 in Python by Nietzsche's daemon
• 4,260 points
61 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.