RowKey
Examples
open all close allBasic Examples (2)
Create a Tabular object with three columns:
Tabular[{{1, "a", 2.}, {4, "b", 3.}}, {"col1", "col2", "col3"}]Set one of them to be a key column, to allow indexing by that column:
tab = Tabular[%, <|"KeyColumns" -> {"col2"}|>]Extract the row containing "b" in the key column:
tab[RowKey[{"b"}]]%//NormalUse RowKey[…] as a function to extract a row from a Tabular object with a key column:
EntityValue[{Entity["Country", "France"], Entity["Country", "Italy"]}, {"GDP", "Area"}, "Tabular"]%//RowKey[Entity["Country", "France"]]// NormalScope (3)
Create a Tabular object with a key column:
tab = Tabular[{{"a", 2.}, {"b", 3.}}, <|"ColumnKeys" -> {"col1", "col2"}, "KeyColumns" -> {"col1"}|>]Extract the row containing "a" in the key column:
tab[RowKey[{"a"}]]%//NormalThe List wrapper is not needed when there is a single key column:
tab[RowKey["a"]]Use RowKey[…] as a function acting on a Tabular object:
RowKey[{"b"}][Tabular[Association["RawSchema" -> Association["ColumnProperties" ->
Association["col1" -> Association["ElementType" -> "String"],
"col2" -> Association["ElementType" -> "Real64"]], "KeyColumns" -> {"col1"},
"Backend" -> "WolframKernel"], "Options" -> {},
"BackendData" -> Association["ColumnData" -> DataStructure["ColumnTable",
{{TabularColumn[Association["Data" -> {{3, {0, 1, 2}, "ab"}, {}, None},
"ElementType" -> "String"]], TabularColumn[Association["Data" -> {{2., 3.}, {}, None},
"ElementType" -> "Real64"]]}}]]]]]Take a Tabular object of populations of the G7 countries:
tab = Tabular[Association["RawSchema" -> Association["ColumnProperties" ->
Association["Year" -> Association["ElementType" -> "Integer64"],
"Country" -> Association["ElementType" -> "String"], "Population" ->
Association["ElementType" -> TypeSpecifier["Quantity"]["Real64", "People"]]],
"KeyColumns" -> None, "Backend" -> "WolframKernel"],
"BackendData" -> Association["ColumnData" -> DataStructure["ColumnTable",
{{TabularColumn[Association["Data" -> {{1950, 1950, 1950, 1950, 1950, 1950, 1950, 2000, 2000,
2000, 2000, 2000, 2000, 2000}, {}, None}, "ElementType" -> "Integer64"]],
TabularColumn[Association["Data" -> {{3, {0, 6, 12, 19, 24, 29, 42, 54, 60, 66, 73, 78, 83,
96, 108}, "CanadaFranceGermanyItalyJapanUnitedKingdomUnitedStatesCanadaFranceGermanyI\
talyJapanUnitedKingdomUnitedStates"}, {}, None}, "ElementType" -> "String"]],
TabularColumn[Association["Data" -> {14, {{{1.3737*^7, 4.1828673*^7, 6.8377*^7, 4.7104*^7,
8.31996*^7, 5.0127*^7, 1.513258*^8, 3.0529607*^7, 5.8494936*^7, 8.1561598*^7,
5.6950733*^7, 1.26664952*^8, 5.8734782*^7, 2.80816627*^8}, {}, None}}, None},
"ElementType" -> TypeSpecifier["Quantity"]["Real64", "People"]]]}}]]]];Set two columns as key columns:
Tabular[tab, <|"KeyColumns" -> {"Year", "Country"}|>]Use RowKey to extract a value for a given column:
%[RowKey[{2000, "Italy"}], "Population"]Applications (1)
Take tabular data of fatal collisions for each state:
tab = ResourceData["Sample Tabular Data: Fatal Collisions"]ColumnKeys[tab]There are no key columns specified:
Keys[tab]Reorder the columns and set the "state" column as key column:
neworder = RotateRight[ColumnKeys[tab]]newtab = Tabular[tab[All, neworder], <|"KeyColumns" -> {"state"}|>]Keys[newtab]Extract the rows for US Midwest states:
midwest = EntityValue[EntityClass["AdministrativeDivision", "USStatesMidwest"], EntityProperty["AdministrativeDivision", "StateAbbreviation"]]Tabular[newtab[RowKey[#]]& /@ midwest, <|"KeyColumns" -> {"state"}|>]Properties & Relations (4)
Take a Tabular object with a key column:
tab = Tabular[{{"one", True, "foo"}, {"two", False, "bar"}}, <|"ColumnKeys" -> {"key", "col1", "col2"}, "KeyColumns" -> {"key"}|>]Row extraction can be performed with RowKey:
tab[RowKey["one"]]Key wrappers can also be used to extract a tabular row:
tab[Key["one"]]Keys of a Tabular object returns a list of RowKey expressions if key columns are specified:
Tabular[{{"cat", 2, 3}, {"dog", 5, 6}}, <|"ColumnKeys" -> {"a", "b", "c"}, "KeyColumns" -> {"a"}|>]Keys[%]Tabular[{{"cat", 2, 3}, {"dog", 5, 6}}, <|"ColumnKeys" -> {"a", "b", "c"}, "KeyColumns" -> {"a", "b"}|>]Keys[%]RowKey[{key1,key2,…}] allows indexing rows by the values of multiple key columns:
Tabular[Association["RawSchema" -> Association["ColumnProperties" ->
Association["a" -> Association["ElementType" -> "String"],
"b" -> Association["ElementType" -> "Integer64"],
"c" -> Association["ElementType" -> "Integer64"]], "KeyColumns" -> {"a", "b"},
"Backend" -> "WolframKernel"], "BackendData" ->
Association["ColumnData" -> DataStructure["ColumnTable",
{{TabularColumn[Association["Data" -> {{3, {0, 3, 6}, "catdog"}, {}, None},
"ElementType" -> "String"]], TabularColumn[Association["Data" -> {{2, 5}, {}, None},
"ElementType" -> "Integer64"]], TabularColumn[Association["Data" -> {{3, 6}, {}, None},
"ElementType" -> "Integer64"]]}}]]]][RowKey[{"cat", 2}]]%//NormalExtendedKey[key1,key2,…] allows specifying columns by multiple values:
Tabular[Association["RawSchema" -> Association["ColumnProperties" ->
Association[ExtendedKey["female", "name"] -> Association["ElementType" -> "String"],
ExtendedKey["female", "city"] -> Association["ElementType" -> "String"]],
"KeyColumns" -> None, "Backend" -> "WolframKernel"],
"BackendData" -> Association["ColumnData" -> DataStructure["ColumnTable",
{{TabularColumn[Association["Data" -> {{3, {0, 4, 13}, "AnnaElizabeth"}, {}, None},
"ElementType" -> "String"]], TabularColumn[Association[
"Data" -> {{3, {0, 7, 12}, "ChicagoParis"}, {}, None}, "ElementType" -> "String"]]}}]]]][All, ExtendedKey["female", "city"]]%//NormalRowKey can contain keys corresponding to columns specified by ExtendedKey objects:
tab = Tabular[Association["RawSchema" -> Association["ColumnProperties" ->
Association[ExtendedKey["first", "name"] -> Association["ElementType" -> "String"],
ExtendedKey["first", "a"] -> Association["ElementType" -> "Integer64"],
ExtendedKey["first", "b"] -> Association["ElementType" -> "Integer64"],
ExtendedKey["second", "name"] -> Association["ElementType" -> "String"],
ExtendedKey["second", "a"] -> Association["ElementType" -> "Integer64"],
ExtendedKey["second", "b"] -> Association["ElementType" -> "Integer64"]],
"KeyColumns" -> {ExtendedKey["first", "name"], ExtendedKey["second", "name"]},
"Backend" -> "WolframKernel"], "Options" -> {},
"BackendData" -> Association["ColumnData" -> DataStructure["ColumnTable",
{{TabularColumn[Association["Data" -> {{3, {0, 3, 6}, "catdog"}, {}, None},
"ElementType" -> "String"]], TabularColumn[Association["Data" -> {{2, 5}, {}, None},
"ElementType" -> "Integer64"]], TabularColumn[Association["Data" -> {{3, 6}, {}, None},
"ElementType" -> "Integer64"]], TabularColumn[Association[
"Data" -> {{3, {0, 4, 9}, "rosetulip"}, {}, None}, "ElementType" -> "String"]],
TabularColumn[Association["Data" -> {{7, 10}, {}, None}, "ElementType" -> "Integer64"]],
TabularColumn[Association["Data" -> {{8, 11}, {}, None}, "ElementType" ->
"Integer64"]]}}]]]];tab[RowKey[{"cat", "rose"}]]%//NormalSee Also
Tabular Key ExtendedKey Keys ColumnKeys FromTabular TabularRow
Related Guides
History
Text
Wolfram Research (2025), RowKey, Wolfram Language function, https://reference.wolfram.com/language/ref/RowKey.html.
CMS
Wolfram Language. 2025. "RowKey." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RowKey.html.
APA
Wolfram Language. (2025). RowKey. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RowKey.html
BibTeX
@misc{reference.wolfram_2026_rowkey, author="Wolfram Research", title="{RowKey}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/RowKey.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_rowkey, organization={Wolfram Research}, title={RowKey}, year={2025}, url={https://reference.wolfram.com/language/ref/RowKey.html}, note=[Accessed: 13-June-2026]}