Recall & Review
beginner
What are set operations in data science?
Set operations are ways to combine or compare groups of items, like finding common or unique elements between lists or arrays.
Click to reveal answer
beginner
Why are set operations useful when working with numpy arrays?
They help quickly find shared or different data points, remove duplicates, and merge data efficiently without loops.
Click to reveal answer
beginner
Name three common set operations available in numpy.
Union (all unique elements), Intersection (common elements), and Difference (elements in one set but not the other).
Click to reveal answer
intermediate
How does using set operations improve data analysis?
They simplify comparing datasets, speed up processing, and reduce errors by handling duplicates and overlaps clearly.
Click to reveal answer
beginner
Give an example of a real-life situation where set operations help.
Finding customers who bought both product A and product B by intersecting two customer lists.
Click to reveal answer
Which numpy function finds elements common to two arrays?
✗ Incorrect
np.intersect1d returns the sorted, unique values that are in both input arrays.
What does np.union1d do?
✗ Incorrect
np.union1d returns the sorted unique elements that appear in either of the two arrays.
Why might set operations be faster than loops for comparing data?
✗ Incorrect
Numpy's set operations are implemented in optimized C code, making them faster than Python loops.
Which operation would you use to find elements in array A but not in array B?
✗ Incorrect
np.setdiff1d returns elements in the first array that are not in the second.
What is a practical benefit of removing duplicates using set operations?
✗ Incorrect
Removing duplicates helps avoid confusion and speeds up analysis by working with clean data.
Explain why set operations are important when analyzing data with numpy arrays.
Think about how comparing lists by hand is slow and error-prone.
You got /4 concepts.
Describe a real-world example where you would use intersection and union operations on data.
Imagine two groups of people and what you want to learn about them.
You got /3 concepts.