Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Data Analysis with NumPy and Pandas

You're reading from  Hands-On Data Analysis with NumPy and Pandas

Product type Book
Published in Jun 2018
Publisher Packt
ISBN-13 9781789530797
Pages 168 pages
Edition 1st Edition
Languages
Author (1):
Curtis Miller Curtis Miller
Profile icon Curtis Miller
Toc

Advanced indexing


Let's now discuss more advanced indexing techniques. We can index ndarray objects using other ndarray. We can slice an ndarray using either ndarray objects containing integers that correspond to the indices of the ndarray we wish to select, or ndarray objects of Boolean values, where the value true means a cell should be included in the slice.

Select the elements of arr2 that are not Wayne, and this is the result:

Wayne is not included in the selection, and this was the array that was generated to do that indexing:

It is True everywhere except where the contents were Wayne.

Another more advanced technique is to select using arrays of integers that identify which elements we want. So here, we're going to create two arrays that will be used for this slicing:

This first 0 in the first array means the first coordinate is zero, and the first 0 in the second array means that second coordinate is zero, as specified by the order these two arrays are listed in. So, in the first row and...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime