

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
Not enough gems
Cost: 6 gems
1: What Is Pandas?
incomplete
2: Series
incomplete
3: DataFrames
incomplete
4: Derived Columns
incomplete
5: Series vs. DataFrame
incomplete
6: Filtering Data
incomplete
7: The Index in Pandas
incomplete
8: Custom Indexes
incomplete
9: Loading Data
incomplete
10: Inspect Head
incomplete
11: Info & Describe
incomplete
12: Inspecting Workflow
incomplete
13: Data Properties
incomplete
14: Inspecting Columns
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
When you select one column from a DataFrame, you get a Series. Given the following DataFrame:
title author page_count
0 The Hobbit Tolkien 310
1 Dune Herbert 412
2 It King 1138
We can select the title column:
titles = df["title"]
print(titles)
Which prints the following Series:
0 The Hobbit
1 Dune
2 It
Name: title, dtype: object
When you select multiple columns from a DataFrame, you get another (smaller) DataFrame. We use double brackets here because we're actually passing a list of column names as the key for selection:
subset = df[["title", "page_count"]]
print(subset)
Which yields the following DataFrame:
title page_count
0 The Hobbit 310
1 Dune 412
2 It 1138
Series and DataFrame objects are not interchangeable. They support different methods and properties, so keeping track of which one you have will help you avoid errors.
Say we have a table of library books:
| book_id | title | page_count | in_stock |
|---|---|---|---|
| 101 | The Hobbit | 310 | true |
| 102 | Dune | 412 | false |
| 103 | It | 1138 | true |
DataFrame.title column alone is a Series.page_count column alone is a Series.title and in_stock columns, we'll have a smaller two-column DataFrame.SnackStack's dashboard needs two slices of the same device table: a Series of device IDs, and an environment-panel DataFrame. The sensors report temperature in Fahrenheit, so a provided add_celsius() helper adds a "temperature_c" column for you.
Complete the get_device_views function. It accepts a DataFrame and returns a tuple of two values.