RowKey
例題
すべて開く すべて閉じる例 (2)
3列のTabularオブジェクトを作成する:
Tabular[{{1, "a", 2.}, {4, "b", 3.}}, {"col1", "col2", "col3"}]tab = Tabular[%, <|"KeyColumns" -> {"col2"}|>]tab[RowKey[{"b"}]]%//NormalRowKey[…]を関数として使ってキー列があるTabularオブジェクトから行を抽出する:
EntityValue[{Entity["Country", "France"], Entity["Country", "Italy"]}, {"GDP", "Area"}, "Tabular"]%//RowKey[Entity["Country", "France"]]// Normalスコープ (3)
キー列がある Tabularオブジェクトを作成する:
tab = Tabular[{{"a", 2.}, {"b", 3.}}, <|"ColumnKeys" -> {"col1", "col2"}, "KeyColumns" -> {"col1"}|>]tab[RowKey[{"a"}]]%//Normalキー列が1列だけのときは,Listラッパーは必要ない:
tab[RowKey["a"]]RowKey[…]をTabularオブジェクトに作用する関数として使う:
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"]]}}]]]]]G7諸国の人口のTabularオブジェクトを取る:
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"], "Options" -> {},
"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"]]]}}]]]];Tabular[tab, <|"KeyColumns" -> {"Year", "Country"}|>]RowKeyを使って指定された列の値を抽出する:
%[RowKey[{2000, "Italy"}], "Population"]アプリケーション (1)
tab = ResourceData["Sample Tabular Data: Fatal Collisions"]ColumnKeys[tab]Keys[tab]neworder = RotateRight[ColumnKeys[tab]]newtab = Tabular[tab[All, neworder], <|"KeyColumns" -> {"state"}|>]Keys[newtab]midwest = EntityValue[EntityClass["AdministrativeDivision", "USStatesMidwest"], EntityProperty["AdministrativeDivision", "StateAbbreviation"]]Tabular[newtab[RowKey[#]]& /@ midwest, <|"KeyColumns" -> {"state"}|>]特性と関係 (4)
キー列があるTabularオブジェクトを取る:
tab = Tabular[{{"one", True, "foo"}, {"two", False, "bar"}}, <|"ColumnKeys" -> {"key", "col1", "col2"}, "KeyColumns" -> {"key"}|>]行の抽出はRowKeyを使って行える:
tab[RowKey["one"]]Keyラッパーは,表形式の行を抽出する際にも使うことができる:
tab[Key["one"]]TabularオブジェクトのKeysは,キー列が指定されている際はRowKey式のリストを返す:
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,…}]を使うと複数のキー列の値で行にインデックスを付けることができる:
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,…]を使うと複数の値で列を指定することができる:
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は,ExtendedKeyオブジェクトで指定された列に対応するキーを含むことができる:
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"}]]%//Normal関連するガイド
テキスト
Wolfram Research (2025), RowKey, Wolfram言語関数, 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: 14-November-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: 14-November-2026]}