= 'https://bit.ly/eds217-studentdata' url
A line of pandas, where each panda is dressed similar to the others, but one thing about them is different. For example, one panda has a different pattern on his shirt, while another has the same pattern, but in a different color. One is wearing a blue hat and the other is wearing a green hat in the same style. A third panda is wearing a green hat, but it is in a different style. MidJourney 5
Overview
In this session, we will be exploring how to select and filter data from DataFrames.
Objectives
- Apply various indexing methods to select rows and columns in dataframes.
- Use boolean logic to filter data based on values
- Develop the ability to troubleshoot and debug in a live setting.
Getting Started
We will be using the data stored in the csv at this url:
To get the most out of this session, please follow these guidelines:
Prepare Your Environment:
- Make sure JupyterLab is up and running on your machine.
- Open a new Jupyter notebook where you can write your own code as we go along.
- Make sure to name the notebook something informative so you can refer back to it later.
Setup Your Notebook:
Before we begin the live coding session, please set up your Jupyter notebook with the following structure. This will help you organize your notes and code as we progress through the lesson.
Create a new Jupyter notebook.
In the first cell, create a markdown cell with the title of our session:
# Basic Pandas Selection and Filtering
- Below that, create markdown cells for each of the following topics we’ll cover. Leave empty code cells between each markdown cell where you’ll write your code during the session:
# Introduction to Pandas Selection and Filtering ## 1. Setup [Empty Code Cell] ## 2. Basic Selection [Empty Code Cell] ## 3. Filtering Based on Column Values ### 3a. Single Condition Filtering [Empty Code Cell] ### 3b. Multiple Conditions with Logical Operators [Empty Code Cell] ### 3c. Using the filter command [ Emptyh Code Cell] ## 4. Combining Selection and Filtering [Empty Code Cell] ## 5. Using .isin() for Multiple Values [Empty Code Cell] ## 6. Filtering with String Methods [Empty Code Cell] ## 7. Advanced Selection: .loc vs .iloc [Empty Code Cell] ## Conclusion
As we progress through the live coding session, you’ll fill in the code cells with the examples we work on together.
Feel free to add additional markdown cells for your own notes or observations throughout the session.
By setting up your notebook this way, you’ll have a clear structure to follow along with the lesson and easily reference specific topics later for review. Remember, you can always add more cells or modify the structure as needed during the session!
Participation:
- Try to code along with me during the session.
- Feel free to ask questions at any time. Remember, if you have a question, others probably do too!
Resources:
I will be sharing snippets of code and notes. Make sure to take your own notes and save snippets in your notebook for future reference.
Check out our class data selection and filtering cheatsheet.