
A cartoon panda is a school crossing guard. He is directing traffic with a hand-held Stop sign and allowing an adorable group of school-aged pythons to cross the street. MidJourney 5
Yesterday we learned to describe a dataset. Today we will start asking questions of it.
Day 3 brings in two new patterns that address most of the questions anyone asks of a table. We begin this morning with booleans, comparison operators and if/elif/else, because they are the underlying grammar that a filter depends on. The filter pattern, which allows you to keep the rows that satisfy a condition, follows in the second session of the morning. Then this afternoon we take up the top-N pattern, which puts the rows in order and takes the first few from the front of the list. The N is a stand-in for however many rows you want back, so you write .head(10) when you want the top ten and .head(3) when you want the top three.
Class materials
| Session | Session 1 | Session 2 |
|---|---|---|
| day 3 / morning | ๐ Booleans & Conditionals, Asked of Data | ๐ The Filter Pattern |
| day 3 / afternoon | ๐ฅ The Top-N Pattern | ๐ Which One, and How Do You Know? |
End-of-day practice
Later today you will rank the foods in The Economistโs banana index, which scores the carbon emissions of a food against those of a banana. You will rank them three ways: per kilogram of food, per thousand calories, and per hundred grams of protein. The three rankings disagree with each other, and working out why is most of the practice.