SigmaAnalytics & Tech
A10PythonBeginnerAbout 90 min to complete

Sets

Instant deduplication, O(1) membership, and the reconciliation toolkit for comparing two systems.

Notebook

About 90 minutes to complete

Enrol to read the notebook and download it to run.

What this module covers

Instant deduplication, O(1) membership, and the reconciliation toolkit for comparing two systems.

By the end of it

  • Create sets, and avoid the empty-set trap ({} is a dict)
  • Explain the three defining properties: unordered, unique, hashable-only
  • Add and remove items, choosing correctly between .remove() and .discard()
  • Apply the four set operations — union, intersection, difference, symmetric difference —
  • Test subset and superset relationships
  • Use frozenset where an immutable, hashable set is required
  • Write set comprehensions
  • Justify sets on performance grounds with a benchmark