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 16, 2018 in Python by ana1504.k
• 7,910 points
678 views

2 answers to this question.

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 16, 2018 by anto.trigg4
• 3,440 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, 2019 in Python by SDeb
• 13,300 points
472 views
0 votes
1 answer

How do I turn a list into numpy array?

Use this line: numpy_array = np.array(list) And printing/displaying the ...READ MORE

answered May 24, 2019 in Python by Isha
550 views
0 votes
1 answer

Error while converting a list into a numpy array

The only possible reason I could think ...READ MORE

answered Jun 14, 2019 in Python by Rhea
2,350 views
0 votes
1 answer

How to pretty-print a numpy.array without scientific notation and with given precision?

Hii @kartik, The numpy arrays have the method round(precision) which ...READ MORE

answered Apr 14, 2020 in Python by Niroj
• 82,880 points
2,614 views
0 votes
1 answer

How do I read CSV data into a record array in NumPy?

Hello @kartik, You can use Numpy's genfromtxt() method to do ...READ MORE

answered Jun 22, 2020 in Python by Niroj
• 82,880 points
3,232 views
+1 vote
1 answer

How to convert a PIL Image into a numpy array?

Hello @kartik, You just need to convert your ...READ MORE

answered Jun 22, 2020 in Python by Niroj
• 82,880 points
3,867 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
1,522 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP