From the course: Python Data Analysis
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Indexing in pandas - Python Tutorial
From the course: Python Data Analysis
Indexing in pandas
- [Instructor] We have seen how to load and create data frames and how to select records based on Boolean conditions. However, for anything more complex than a simple selection, you want to use pandas indices. You will also need to use indices wherever you need to modify values within a data frame. So let's load up our Nobels list database again. Here, the index is the default integer range. We can instead use the nobel here. To elevate the column to serve as index, we use the set index method, which creates a new data frame. The data frame is now shown with the year at the front of each record. And here's the index itself. Pandas indices do not need to have unique values, and that's a feature, not a bug, because we may very well want to select all Nobels awarded in a given year. The pandas indexing notation is a bit surprising. To select all the records with a given index, we use .lock followed by the index value in brackets, not by parenthesis. We can also add a column name just as…