TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Member-only story

6 Common Index-Related Operations You Should Know about Pandas

Yong Cui
9 min readOct 17, 2023

--

Photo by Alejandro Luengo on Unsplash

Imagine that you have a library filled with thousands of books, each holding a treasure trove of information. To find the exact book you need, you’d turn to the library’s index (if you have one), right? When you deal with real-world data, having a library-like index is essential for you to sift through vast amounts of data, pinpointing exactly what you want without rummaging through every bit.

In this article, I’m going to share some common yet important index-related operations, breaking them down using simple applicable scenarios. Whether you’re a data newbie or a seasoned pro, you’ll soon see how these operations can be your data’s best friend.

Without further ado, let’s get it started.

As a quick note, in a data frame, both rows and columns are considered indexes, but in most data manipulations, we simply consider rows as the index of interest, as many datasets are presented in the wide format — each row represents one data record and columns represent varied aspects of the data record.
In this article, we will be focused on manipulating the index along the rows. That is, each item of the index responds to a row.

1. Setting index

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Yong Cui
Yong Cui

Written by Yong Cui

Work at the nexus of biomedicine, data science & mobile dev. Author of Python How-to by Manning (https://www.manning.com/books/python-how-to).

Responses (2)