Pandas · Match lists and ranges
Google Search Analytics
Course overviewGoogle Search · Filter and sort searches

Match lists and ranges

Match several values with isin and control numeric range boundaries with between.

Step 1 of 3 · Learn

Match any value in a list

.isin([...]) checks whether each value belongs to a list. Use ~ before the condition to exclude those values.

indexteamscore
0A10
1B20
2C30
indexteamscore
0A10
2C30
A and C match the list. Each source row appears at most once.

Include or exclude endpoints

.between(low, high, inclusive="both") includes both endpoints. Use "neither" to exclude both, "left" to include only the lower endpoint, or "right" to include only the upper endpoint.

indexscore
010
120
230
340
indexscore
120
230
Both 20 and 30 are included.
▷ Your turn

Return search_id and device for searches on desktop or tablet. Keep source row order and save the DataFrame as result.

LANGUAGEPython · Pandas

Loading Python and Pandas…

Run the code to see DataFrame results here.