---
title: "Associations"
language: "en"
type: "Guide"
summary: "Along with lists, associations are fundamental constructs in the Wolfram Language. They associate keys with values, allowing highly efficient lookup and updating, even with millions of elements. Associations provide generalizations of symbolically indexed lists, associative arrays, dictionaries, hashmaps, structs, and a variety of other powerful data structures."
sections: 
  - 
    title: "Associations and Parts"
    link: "null"
  - 
    title: "Elements of Associations"
    link: "null"
  - 
    title: "Functions That Apply to Values"
    link: "paclet:guide/HandlingArraysOfData"
  - 
    title: "Functions That Apply to Keys"
    link: "null"
  - 
    title: "Modifying Associations"
    link: "null"
  - 
    title: "Pattern Matching with Associations"
    link: "null"
  - 
    title: "Functions That Create Associations"
    link: "null"
  - 
    title: "Functions Operating on Lists of Associations"
    link: "null"
canonical_url: "https://reference.wolfram.com/language/guide/Associations.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Lists & List Manipulation"
    link: "https://reference.wolfram.com/language/guide/ListManipulation.en.md"
  - 
    title: "Structured Datasets"
    link: "https://reference.wolfram.com/language/guide/ComputationWithStructuredDatasets.en.md"
related_functions: 
  - 
    title: "AssociateTo"
    link: "https://reference.wolfram.com/language/ref/AssociateTo.en.md"
  - 
    title: "Association"
    link: "https://reference.wolfram.com/language/ref/Association.en.md"
  - 
    title: "AssociationMap"
    link: "https://reference.wolfram.com/language/ref/AssociationMap.en.md"
  - 
    title: "AssociationQ"
    link: "https://reference.wolfram.com/language/ref/AssociationQ.en.md"
  - 
    title: "AssociationThread"
    link: "https://reference.wolfram.com/language/ref/AssociationThread.en.md"
  - 
    title: "Catenate"
    link: "https://reference.wolfram.com/language/ref/Catenate.en.md"
  - 
    title: "Counts"
    link: "https://reference.wolfram.com/language/ref/Counts.en.md"
  - 
    title: "CountsBy"
    link: "https://reference.wolfram.com/language/ref/CountsBy.en.md"
  - 
    title: "Dataset"
    link: "https://reference.wolfram.com/language/ref/Dataset.en.md"
  - 
    title: "DeleteDuplicates"
    link: "https://reference.wolfram.com/language/ref/DeleteDuplicates.en.md"
  - 
    title: "GroupBy"
    link: "https://reference.wolfram.com/language/ref/GroupBy.en.md"
  - 
    title: "JoinAcross"
    link: "https://reference.wolfram.com/language/ref/JoinAcross.en.md"
  - 
    title: "Key"
    link: "https://reference.wolfram.com/language/ref/Key.en.md"
  - 
    title: "KeyComplement"
    link: "https://reference.wolfram.com/language/ref/KeyComplement.en.md"
  - 
    title: "KeyDrop"
    link: "https://reference.wolfram.com/language/ref/KeyDrop.en.md"
  - 
    title: "KeyDropFrom"
    link: "https://reference.wolfram.com/language/ref/KeyDropFrom.en.md"
  - 
    title: "KeyExistsQ"
    link: "https://reference.wolfram.com/language/ref/KeyExistsQ.en.md"
  - 
    title: "KeyFreeQ"
    link: "https://reference.wolfram.com/language/ref/KeyFreeQ.en.md"
  - 
    title: "KeyIntersection"
    link: "https://reference.wolfram.com/language/ref/KeyIntersection.en.md"
  - 
    title: "KeyMap"
    link: "https://reference.wolfram.com/language/ref/KeyMap.en.md"
  - 
    title: "KeyMemberQ"
    link: "https://reference.wolfram.com/language/ref/KeyMemberQ.en.md"
  - 
    title: "Keys"
    link: "https://reference.wolfram.com/language/ref/Keys.en.md"
  - 
    title: "KeySelect"
    link: "https://reference.wolfram.com/language/ref/KeySelect.en.md"
  - 
    title: "KeySort"
    link: "https://reference.wolfram.com/language/ref/KeySort.en.md"
  - 
    title: "KeySortBy"
    link: "https://reference.wolfram.com/language/ref/KeySortBy.en.md"
  - 
    title: "KeyTake"
    link: "https://reference.wolfram.com/language/ref/KeyTake.en.md"
  - 
    title: "KeyUnion"
    link: "https://reference.wolfram.com/language/ref/KeyUnion.en.md"
  - 
    title: "KeyValueMap"
    link: "https://reference.wolfram.com/language/ref/KeyValueMap.en.md"
  - 
    title: "KeyValuePattern"
    link: "https://reference.wolfram.com/language/ref/KeyValuePattern.en.md"
  - 
    title: "ListPlot"
    link: "https://reference.wolfram.com/language/ref/ListPlot.en.md"
  - 
    title: "Lookup"
    link: "https://reference.wolfram.com/language/ref/Lookup.en.md"
  - 
    title: "Map"
    link: "https://reference.wolfram.com/language/ref/Map.en.md"
  - 
    title: "Merge"
    link: "https://reference.wolfram.com/language/ref/Merge.en.md"
  - 
    title: "Missing"
    link: "https://reference.wolfram.com/language/ref/Missing.en.md"
  - 
    title: "name"
    link: "https://reference.wolfram.com/language/ref/Slot.en.md"
  - 
    title: "Normal"
    link: "https://reference.wolfram.com/language/ref/Normal.en.md"
  - 
    title: "Plus"
    link: "https://reference.wolfram.com/language/ref/Plus.en.md"
  - 
    title: "PositionIndex"
    link: "https://reference.wolfram.com/language/ref/PositionIndex.en.md"
  - 
    title: "Select"
    link: "https://reference.wolfram.com/language/ref/Select.en.md"
  - 
    title: "Sort"
    link: "https://reference.wolfram.com/language/ref/Sort.en.md"
  - 
    title: "Values"
    link: "https://reference.wolfram.com/language/ref/Values.en.md"
---
# Associations

Along with lists, associations are fundamental constructs in the Wolfram Language. They associate keys with values, allowing highly efficient lookup and updating, even with millions of elements. Associations provide generalizations of symbolically indexed lists, associative arrays, dictionaries, hashmaps, structs, and a variety of other powerful data structures.

---

[`Association`](https://reference.wolfram.com/language/ref/Association.en.md) ( [`<\|…\|>`](https://reference.wolfram.com/language/ref/Association.en.md) ) — an association between keys and values

[`<\|…\|>[key]`](https://reference.wolfram.com/language/ref/Association.en.md) — extract the value associated with any given key

### Associations and Parts

[`<\|…\|>[[str]]`](https://reference.wolfram.com/language/ref/Part.en.md) — extract a value corresponding to a key that is a string

[`Key`](https://reference.wolfram.com/language/ref/Key.en.md) — indicate a key within a part specification

[`Missing`](https://reference.wolfram.com/language/ref/Missing.en.md) — default value if a key is not found

[`\#name`](https://reference.wolfram.com/language/ref/Slot.en.md) — a slot in a pure function that picks out value with key ``"name"`` in an association

[`AssociationQ`](https://reference.wolfram.com/language/ref/AssociationQ.en.md) — test if an expression is a valid association

---

### Elements of Associations

[`Keys`](https://reference.wolfram.com/language/ref/Keys.en.md) — list of keys

[`Values`](https://reference.wolfram.com/language/ref/Values.en.md) — list of values

[`Normal`](https://reference.wolfram.com/language/ref/Normal.en.md) — convert to a list of rules

[`Lookup`](https://reference.wolfram.com/language/ref/Lookup.en.md) — perform a lookup of a value by key, returning a specified default if it is not found

[`KeyExistsQ`](https://reference.wolfram.com/language/ref/KeyExistsQ.en.md) — test whether a key exists in an association

---

### [Functions That Apply to Values](https://reference.wolfram.com/language/guide/HandlingArraysOfData.en.md)

* [`Map`](https://reference.wolfram.com/language/ref/Map.en.md)
* [`Select`](https://reference.wolfram.com/language/ref/Select.en.md)
* [`Sort`](https://reference.wolfram.com/language/ref/Sort.en.md)
* [`DeleteDuplicates`](https://reference.wolfram.com/language/ref/DeleteDuplicates.en.md)
* [`ListPlot`](https://reference.wolfram.com/language/ref/ListPlot.en.md)
* [`Plus`](https://reference.wolfram.com/language/ref/Plus.en.md)
* [`...`](https://reference.wolfram.com/language/guide/HandlingArraysOfData.en.md)

### Functions That Apply to Keys

[`KeySort`](https://reference.wolfram.com/language/ref/KeySort.en.md), [`KeySortBy`](https://reference.wolfram.com/language/ref/KeySortBy.en.md) — sort an association by its keys

[`KeyTake`](https://reference.wolfram.com/language/ref/KeyTake.en.md), [`KeyDrop`](https://reference.wolfram.com/language/ref/KeyDrop.en.md) — take, drop particular keys in an association

[`KeySelect`](https://reference.wolfram.com/language/ref/KeySelect.en.md) — select elements based on a criterion on their keys

[`KeyMap`](https://reference.wolfram.com/language/ref/KeyMap.en.md) — map a function over the keys in an association

[`KeyValueMap`](https://reference.wolfram.com/language/ref/KeyValueMap.en.md) — map a function over keys and values in an association

* [`KeyMemberQ`](https://reference.wolfram.com/language/ref/KeyMemberQ.en.md)
* [`KeyFreeQ`](https://reference.wolfram.com/language/ref/KeyFreeQ.en.md)

### Modifying Associations

``<|…|>[key] = val`` — change an element of an association

[`AssociateTo`](https://reference.wolfram.com/language/ref/AssociateTo.en.md) — add elements to an association

[`KeyDropFrom`](https://reference.wolfram.com/language/ref/KeyDropFrom.en.md) — drop elements from an association

### Pattern Matching with Associations

[`KeyValuePattern`](https://reference.wolfram.com/language/ref/KeyValuePattern.en.md) — elements that can appear anywhere in an association

---

### Functions That Create Associations

[`Association`](https://reference.wolfram.com/language/ref/Association.en.md) — turn a list of rules into an association

[`AssociationMap`](https://reference.wolfram.com/language/ref/AssociationMap.en.md) — create an association by applying a function to a list of keys

[`AssociationThread`](https://reference.wolfram.com/language/ref/AssociationThread.en.md) — create an association from a list of keys and a list of values

[`Counts`](https://reference.wolfram.com/language/ref/Counts.en.md), [`CountsBy`](https://reference.wolfram.com/language/ref/CountsBy.en.md) — associate values with the number of times they occur

[`GroupBy`](https://reference.wolfram.com/language/ref/GroupBy.en.md) — group values by collecting those sharing a criterion ("map reduce")

[`PositionIndex`](https://reference.wolfram.com/language/ref/PositionIndex.en.md) — build an index of positions at which values occur

### Functions Operating on Lists of Associations

* [`KeyUnion`](https://reference.wolfram.com/language/ref/KeyUnion.en.md)
* [`KeyIntersection`](https://reference.wolfram.com/language/ref/KeyIntersection.en.md)
* [`KeyComplement`](https://reference.wolfram.com/language/ref/KeyComplement.en.md)

[`Catenate`](https://reference.wolfram.com/language/ref/Catenate.en.md) — catenate elements from multiple associations

[`Merge`](https://reference.wolfram.com/language/ref/Merge.en.md) — merge associations using a function to combine elements with common keys

[`JoinAcross`](https://reference.wolfram.com/language/ref/JoinAcross.en.md) — do the analog of a database join on multiple associations

[`Dataset`](https://reference.wolfram.com/language/ref/Dataset.en.md) — representation supporting general structured data queries

## Related Guides

* [Lists & List Manipulation](https://reference.wolfram.com/language/guide/ListManipulation.en.md)
* [Structured Datasets](https://reference.wolfram.com/language/guide/ComputationWithStructuredDatasets.en.md)