§ 2.4section 6 of 18·~3 min
Collections
One value at a time doesn't get you far. Collections hold many values, and you'll use these four constantly.
| Type | Looks like | Ordered | Changeable | Typical use |
|---|---|---|---|---|
| list | [1, 2, 3] | yes | yes | rows in order |
| tuple | (1, 2) | yes | no | fixed pairs like lat, lon |
| dict | {"id": 1} | yes | yes | one record |
| set | {1, 2} | no | yes | unique values |
A useful mental model for data work: a dict is a row, and a list of dicts is a table. The next three sections go through each type.