Introduction
Series
5. Accessing Series elements
What DataFrames are
DataFrame columns
DataFrame rows
Filtering rows and columns
Filtering data frames
Sorting rows
Summary

Instruction

Great! To access a specific element of a Series, you can use the same bracket operator that you know from lists:

magic_numbers = pd.Series([100, 200, 300, 400, 500, 600])
magic_numbers[2]

Like lists, Series are indexed from zero, so the code above will return the third value in the Series, which is 300. You can use slicing with Series, too.

An excellent feature of Series is that you can easily filter their elements. Take a look:

magic_numbers[magic_numbers>200]

The code above will return all elements greater than 200, which means 300, 400, 500 and 600.

Exercise

Take a look at the template code. Return all Series elements that are less than 30.

As you can see, there is no import pandas as pd statement in the code editor. From now on, we'll add it automatically for you.

Stuck? Here's a hint!

Use respondents_age < 30 inside square brackets.