Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
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 Implement Python packages from data manipulation to processing

Arrow left icon
Product type Paperback
Published in Jun 2018
Publisher Packt
ISBN-13 9781789530797
Length 168 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Curtis Miller Curtis Miller
Author Profile Icon Curtis Miller
Curtis Miller
Arrow right icon
View More author details
Toc

Indexing methods

pandas provides methods that allow us to clearly state how we want to index. We can also distinguish between indexing based on values of the index of the series, and indexing based on the position of objects in the series, as would be the case if we were working with a list. The two methods we'll focus on are loc and iloc. loc focuses on selecting based on the index of the series, and if we try to select key elements that don't exist, we will get an error. iloc indexes as if we were working with a Python list; that is, it indexes based on integer position. So, if we were to try to index with a non-integer in iloc, or try to select an element outside of the range of valid integers, an error will be produced. There is a hybrid method, ix, that acts like loc, but if passed input that cannot be interpreted with respect to the index, it will act like iloc...

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 $19.99/month. Cancel anytime