How to slice an array using python numpy? Is there any numpy tutorial which has covered all its operations?

0 votes
Unable to slice a numpy array.
Apr 24, 2018 in Python by anto.trigg4
• 3,420 points
49 views

1 answer to this question.

Your answer

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

Slicing is basically extracting particular set of elements from an array. It is pretty much similar to the one which is there in the list as well. For example: We have an array and we need a particular element (say 3) out of a given array.

import numpy as np
a=np.array([(1,2,3,4),(3,4,5,6)])
print(a[0,2])

Output – 3

Here, the array(1,2,3,4) is your index 0 and (3,4,5,6) is index 1 of the python numpy array. Therefore, we have printed the second element from the zeroth index. 
Taking one step forward, let’s say you need the 2nd element from the zeroth and first index of the array.

import numpy as np
a=np.array([(1,2,3,4),(3,4,5,6)])
print(a[0:,2])

Output –[3 5]

answered Apr 24, 2018 by Christine
• 15,790 points

Related Questions In Python

+4 votes
7 answers
0 votes
1 answer
0 votes
1 answer

Is there a foreach function in python and is there a way to implement it if there isnt any

Every occurence of "foreach" I've seen (PHP, ...READ MORE

answered Aug 31, 2018 in Python by charlie_brown
• 7,710 points
41 views
+1 vote
2 answers

View onto a numpy array?

 just index it as you normally would. ...READ MORE

answered Oct 18, 2018 in Python by roberto
34 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
59 views
+1 vote
3 answers

What are the ways of detecting outliners in Python

code from http://eurekastatistics.com/using-the-median-absolute-deviation-to-find-outliers  This uses the L1 distance ...READ MORE

answered Aug 24, 2018 in Python by eatcodesleeprepeat
• 4,670 points

reshown Aug 24, 2018 by Priyaj 38 views
0 votes
1 answer

how to download and install Django rest framework?

To install Django, you can simply open ...READ MORE

answered Apr 24, 2018 in Python by Christine
• 15,790 points
67 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.