- See Also
-
Related Guides
- Elements of Lists
- Computation with Structured Datasets
- Functional Programming
- Function Composition & Operator Forms
- Database-Like Operations on Datasets
- List Manipulation
- Tabular Objects
- Handling Arrays of Data
- Associations
- Conditionals
- Incrementals
- Language Overview
- Numerical Data
- Tabular Transformation
- Tech Notes
-
- See Also
-
Related Guides
- Elements of Lists
- Computation with Structured Datasets
- Functional Programming
- Function Composition & Operator Forms
- Database-Like Operations on Datasets
- List Manipulation
- Tabular Objects
- Handling Arrays of Data
- Associations
- Conditionals
- Incrementals
- Language Overview
- Numerical Data
- Tabular Transformation
- Tech Notes
Select[data,critprop]
returns the property prop of the selected elements.
Select
Select[data,critprop]
returns the property prop of the selected elements.
Details
- Select keeps the elements for which the given criterion crit is True.
- The data can have the following forms and interpretations:
-
{e1,e2,…} list of values » f[e1,e2,…] expression with any head f » Association[…] association of values » QuantityArray[…] quantity array or other structured array Tabular[…] type‐consistent tabular data » TabularColumn[…] type‐consistent column data » Dataset[…] general hierarchical data TimeSeries[…] collection of sampled time-value pairs EventSeries[…] series of temporal events - The property prop can have the following forms and interpretations:
-
"Element" the selected values » "Index" indices of the selected values » "BitVectorMask" Boolean mask returning True for selected values and False otherwise » {prop1,prop2,…} a list of multiple forms » All an association giving element, index and bit vector mask » - Select[crit][data] is equivalent to Select[data,crit].
- Parallelize[Select[data,crit]] or ParallelSelect[data,crit] computes Select[data,crit] in parallel on all subkernels. »
Examples
open all close allBasic Examples (6)
Select elements that are even:
Select[{1, 2, 4, 7, 6, 2}, EvenQ]Return the indices of the selected elements:
Select[{1, 2, 4, 7, 6, 2}, # > 2& -> "Index"]Return only the first expression selected:
Select[{1, 2, 4, 7, 6, 2}, OddQ, 1]Use the operator form of Select:
Select[EvenQ][{1, 2, 4, 7, 6, 2}]Select operates on values in an Association:
Select[<|a -> 1, b -> 2, c -> 3, d -> 4|>, # > 2&]Select rows in a Tabular object:
Tabular[{{"cat", 2}, {"fox", 3}, {"dog", 5}}, {"a", "b"}]Select[%, OddQ[#b]&]Scope (15)
Basic Uses (5)
Select[{{1, y}, {2, x}, {3, x}, {4, z}, {5, x}, {6, y}}, MemberQ[#, x]&]Find up to 2 pairs containing x:
Select[{{1, y}, {2, x}, {3, x}, {4, z}, {5, x}, {6, y}}, MemberQ[#, x]&, 2]Fewer than the requested elements may be returned:
Select[{{1, y}, {2, x}, {3, x}, {4, z}, {5, x}, {6, y}}, MemberQ[#, z]&, 2]Use a pure function to test each element:
Select[{1, 2, 4, 7, 6, 2}, # > 2&]Use an operator form as selection criterion:
Select[Range[10], GreaterThan[3]]Use Select in operator form:
Range[10]//Select[GreaterThan[3]]Input Data (5)
Select works with any head, not just List:
Select[f[1, a, 2, b, 3], IntegerQ]Select works on values in Association:
Select[<|"a" -> {.1, .3, .2}, "b" -> {"dog", "cat", "fox"}|>, AllTrue[#, StringQ]&]Select works with SparseArray objects:
s = SparseArray[Table[2 ^ i -> i, {i, 0, 5}]]Select[s, EvenQ]The result may be a list if it is not sparse:
Select[s, OddQ]Select works with TabularColumn objects:
TabularColumn[RandomDate[10 ^ 5]]Select[SameQ[DateValue[#, "Month"], 11]&][%]The distribution of the dates is uniform:
DateHistogram[Normal[%]]Use Select on a Tabular object with named columns:
tab = ToTabular[{"a" -> {1, 2, 3}, "b" -> {.1, .3, .2}, "c" -> {"dog", "cat", "fox"}, "d" -> {DateObject[{2024, 8, 1}, "Day"], DateObject[{2024, 8, 2}, "Day"], DateObject[{2024, 8, 3}, "Day"]}}, "Columns"]Select rows with last column date being a business day:
Select[tab, Function[BusinessDayQ[#d]]]Normal[%]Property Forms (5)
Select[Range[10], OddQ -> "Element"]Return the indices of the selected elements:
Select[Range[10], OddQ -> "Index"]Return the Boolean mask of the data:
Select[Range[10], OddQ -> "BitVectorMask"]Normal[%]Select[Range[10], OddQ -> {"Element", "Index"}]Return the association with all the properties:
Select[Range[10], OddQ -> All]Applications (7)
Select numbers up to 100 that equal 1 modulo both 3 and 5:
Select[Range[100], Mod[#, 3] == 1 && Mod[#, 5] == 1&]Select 4-tuples that read the same in reverse:
Select[Tuples[{a, b}, 4], # == Reverse[#]&]Find the first four 3×3 matrices of 0s and 1s that have determinant 1:
Select[Tuples[{0, 1}, {3, 3}], Det[#] == 1&, 4]Select eigenvalues that lie within the unit circle:
Select[Eigenvalues[RandomReal[1, {5, 5}]], Abs[#] < 1&]Find built-in Wolfram Language objects whose names are less than 3 characters long:
Select[Names["*"], StringLength[#] < 3&]Select numeric quantities from a product:
Select[7 π^2 x^2 y^2, NumericQ]Find an approximation to
by finding the proportion of points that lie within a disk:
app[n_] := 4N[Length[Select[RandomReal[{-1, 1}, {n, 2}], Dot[#, #] ≤ 1&]] / n]TableForm[Table[n = 10 ^ k;p = app[n];{n, p, π - p}, {k, 1, 6}], TableHeadings -> {{}, {"n", "approximation", "error"}}]Properties & Relations (4)
Select is complementary to Discard:
data = RandomInteger[100, 10]Select[data, PrimeQ]Discard[data, PrimeQ]Union[%%, %] == Union@dataSelect is similar to Cases except that it uses a function instead of a pattern:
list = RandomInteger[9, {10, 2}]Select the lists that have sum of elements less than 10:
f = Total[#] < 10&;Select[list, f]Use Cases to get the same result:
Cases[list, x_ /; f[x]]Select elements that are even:
Select[Range[10], EvenQ]Use GatherBy to separate odd and even elements:
GatherBy[Range[10], EvenQ]Use GroupBy to construct an association explicitly containing as keys the results of the criterion:
GroupBy[Range[10], EvenQ]Compute Select in parallel:
Parallelize[Select[Range[200!, 200! + 10000], PrimeQ]] - 200!Possible Issues (2)
Select picks out elements for which applying the criterion explicitly yields True:
Select[{1, 2, 4, 7, x}, # > 2&]Select[{1, 2, 4, 7, x}, # <= 2&]The symbolic object x is not included in either case, since neither inequality gives True:
{x > 2, x <= 2}The head of the input expression is only preserved for the default "Element" property:
Select[f@@{1, 2, 4, 7, 8}, # > 2& -> All]See Also
SelectFirst Discard Cases Take Drop Reap Pick GatherBy GroupBy MatchQ StringMatchQ FreeQ ParallelSelect
Function Repository: SelectPositions SelectIndices Discard IncrementalParallelSelect
Tech Notes
Related Guides
-
▪
- Elements of Lists ▪
- Computation with Structured Datasets ▪
- Functional Programming ▪
- Function Composition & Operator Forms ▪
- Database-Like Operations on Datasets ▪
- List Manipulation ▪
- Tabular Objects ▪
- Handling Arrays of Data ▪
- Associations ▪
- Conditionals ▪
- Incrementals ▪
- Language Overview ▪
- Numerical Data ▪
- Tabular Transformation
Related Links
-

Fast Introduction for Programmers: Functionals & Operators
-

An Elementary Introduction to the Wolfram Language
: Tests and Conditionals
-

An Elementary Introduction to the Wolfram Language
: Expressions and Their Structure
-

An Elementary Introduction to the Wolfram Language
: Natural Language Understanding
-

An Elementary Introduction to the Wolfram Language
: Datasets
-

NKS|Online
(A New Kind of Science)
History
Introduced in 1988 (1.0) | Updated in 2003 (5.0) ▪ 2014 (10.0) ▪ 2025 (14.2) ▪ 2026 (15.0)
Text
Wolfram Research (1988), Select, Wolfram Language function, https://reference.wolfram.com/language/ref/Select.html (updated 2026).
CMS
Wolfram Language. 1988. "Select." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2026. https://reference.wolfram.com/language/ref/Select.html.
APA
Wolfram Language. (1988). Select. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Select.html
BibTeX
@misc{reference.wolfram_2026_select, author="Wolfram Research", title="{Select}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/Select.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_select, organization={Wolfram Research}, title={Select}, year={2026}, url={https://reference.wolfram.com/language/ref/Select.html}, note=[Accessed: 12-June-2026]}