WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

ColumnKeys [data]

gives a list of the column keys in the tabular data.

ColumnKeys [data,spatt]

gives the column keys of data that match the string pattern spatt.

ColumnKeys [data,crit]

gives the column keys keyi of data for which crit[keyi] is True .

Details
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Applications  
Properties & Relations  
See Also
Related Guides
History
Cite this Page

ColumnKeys [data]

gives a list of the column keys in the tabular data.

ColumnKeys [data,spatt]

gives the column keys of data that match the string pattern spatt.

ColumnKeys [data,crit]

gives the column keys keyi of data for which crit[keyi] is True .

Details

  • ColumnKeys is typically used to get a list of column keys or search for specific keys.
  • Possible forms of data in ColumnKeys [data,] include:
  • Tabular [] tabular data as a list of typed columns
    Dataset [] general hierarchical data
    {assoc1,assoc2,} list of associations with common keys
    TimeSeries [] time series with several components
    EventSeries [] event series with several components
  • ColumnKeys returns column keys in the same order in which they appear in the input tabular data.
  • For a Tabular object tab with anonymous columns, ColumnKeys [tab,] returns None .
  • For a TimeSeries or EventSeries object, ColumnKeys also includes the "Timestamp" component key.
  • In ColumnKeys [data,spatt], possible string patterns include strings with wild characters such as "col*" and StringExpression objects such as "col"~~__.
  • In ColumnKeys [data,crit], the function crit takes named variables #ColumnKey, providing the column key, and #ElementType, providing the type of the elements of the column.

Examples

open all close all

Basic Examples  (3)

Get the list of column keys:

Wolfram Language code: Tabular[{<|"a" -> 1, "b" -> 2, "c" -> 3|>, <|"a" -> 4, "b" -> 5, "c" -> 6|>}]
Wolfram Language code: ColumnKeys[%]

Select the keys that have names matching a string pattern:

Wolfram Language code: tab = Tabular[{{1, 2, 3}, {4, 5, 6}}, {"ab", "bb", "ac"}]
Wolfram Language code: ColumnKeys[tab, "a*"]
Wolfram Language code: ColumnKeys[tab, "a" ~~ __]
Wolfram Language code: ColumnKeys[tab, "ab" | "ac"]

Select the keys obeying a criterion function:

Wolfram Language code: tab = Tabular[{{"cat", 1, "foo", 3.5}, {"dog", 3, "bar", -1.1}}, {"name1", "num1", "name2", "num2"}]
Wolfram Language code: ColumnKeys[tab, StringStartsQ[#ColumnKey, "num"]&]
Wolfram Language code: ColumnKeys[tab, #ElementType == "String"&]

Scope  (10)

Get the column keys of a Tabular object:

Wolfram Language code: Tabular[{{"John", 34, Entity["City", {"NewYork", "NewYork", "UnitedStates"}]}, {"Yvonne", 56, Entity["City", {"Paris", "IleDeFrance", "France"}]}}, {"name", "age", "city"}]
Wolfram Language code: ColumnKeys[%]

Get the column keys of a Dataset object:

Wolfram Language code: ds = Take[ExampleData[{"Dataset", "Titanic"}], 4]
Wolfram Language code: ColumnKeys[ds]

Get the keys of a list of associations:

Wolfram Language code: assocs = {<|"c" -> 0, "a" -> 1, "b" -> 2|>, <|"b" -> 20, "c" -> "30"|>};
Wolfram Language code: ColumnKeys[assocs]

ColumnKeys gives the unsorted union of the keys of the associations:

Wolfram Language code: DeleteDuplicates[Join@@Map[Keys, assocs]]

The result is also consistent with the corresponding Tabular object:

Wolfram Language code: Tabular[assocs]

Get the component keys of a TimeSeries object with several components:

Wolfram Language code: TimeSeries[{{1, "dog"}, {4, "cat"}, {3, "fox"}}, {Today}, ComponentKeys -> {"number", "animal"}]
Wolfram Language code: ColumnKeys[%]

Those are the column keys of the corresponding Tabular object:

Wolfram Language code: Tabular[%%]

The component keys of a simple TimeSeries object are "Timestamp" and "Value":

Wolfram Language code: TimeSeries[{2, 3, 1}, {Today}]
Wolfram Language code: ColumnKeys[%]

The column keys of a Tabular object can be arbitrary expressions:

Wolfram Language code: Tabular[Table[{x, y} ^ n, {n, 5}], {x ^ n, y ^ n}]
Wolfram Language code: ColumnKeys[%]

Take a Tabular object:

Wolfram Language code: tab = ToTabular[<|"num1" -> {1, 2, 3}, "list1" -> {{4, 5}, Missing[], {6, 7}}, "num2" -> {1.3, 4.1, 8.}, "q1" -> Quantity[10, "Days"]|>, "Columns"]

Use string patterns to select the columns whose key ends in "1":

Wolfram Language code: ColumnKeys[tab, "*1"]
Wolfram Language code: ColumnKeys[tab, __ ~~ "1"]
Wolfram Language code: ColumnKeys[tab, StringEndsQ[#ColumnKey, "1"]&]

Use a criterion function to select the keys of columns with integers:

Wolfram Language code: ColumnKeys[tab, StringStartsQ[#ElementType, "Int"]&]

Get the column keys for multilevel column names:

Wolfram Language code: data = {{Today, "fox", 1}, {Tomorrow, "lynx", 2}}; names = {ExtendedKey["obs", "date"], ExtendedKey["obs", "species"], "c"};
Wolfram Language code: Tabular[data, names]
Wolfram Language code: ColumnKeys[%]

Key columns are included in the result of ColumnKeys :

Wolfram Language code: Tabular[{{1, "foo"}, {3, "bar"}}, <|"ColumnKeys" -> {"col1", "col2"}, "KeyColumns" -> {"col1"}|>]
Wolfram Language code: ColumnKeys[%]

For a Tabular object with unspecified column keys, ColumnKeys returns None :

Wolfram Language code: Tabular[{{1, 2}, {3, 4}, {5, 6}}]
Wolfram Language code: ColumnKeys[%]

Applications  (1)

Take a Tabular object of Palmer penguin data:

Wolfram Language code: penguins = ResourceData["Sample Tabular Data: Palmer Penguins"]

Create a pivot table:

Wolfram Language code: pt = PivotTable[penguins, Length[#species]&, {"sex"}, {"species", "island"}]

Some of the column keys are ExtendedKey :

Wolfram Language code: ColumnKeys[pt]

Find all column keys for "Adelie" penguins:

Wolfram Language code: ColumnKeys[pt, MatchQ[#ColumnKey, ExtendedKey["Adelie", _]]&]

Properties & Relations  (1)

ColumnKeyExistsQ [tab,key] returns True if key is in the list ColumnKeys [tab]:

Wolfram Language code: tab = Tabular[{{"a1", "b1"}, {"a2", "b2"}}, {"colA", "colB"}]
Wolfram Language code: {ColumnKeyExistsQ[tab, "colB"], MemberQ[ColumnKeys[tab], "colB"]}
Wolfram Language code: {ColumnKeyExistsQ[tab, "B"], MemberQ[ColumnKeys[tab], "B"]}
Wolfram Research (2025), ColumnKeys, Wolfram Language function, https://reference.wolfram.com/language/ref/ColumnKeys.html (updated 2026).

Text

Wolfram Research (2025), ColumnKeys, Wolfram Language function, https://reference.wolfram.com/language/ref/ColumnKeys.html (updated 2026).

CMS

Wolfram Language. 2025. "ColumnKeys." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2026. https://reference.wolfram.com/language/ref/ColumnKeys.html.

APA

Wolfram Language. (2025). ColumnKeys. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ColumnKeys.html

BibTeX

@misc{reference.wolfram_2026_columnkeys, author="Wolfram Research", title="{ColumnKeys}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/ColumnKeys.html}", note=[Accessed: 15-August-2026]}

BibLaTeX

@online{reference.wolfram_2026_columnkeys, organization={Wolfram Research}, title={ColumnKeys}, year={2026}, url={https://reference.wolfram.com/language/ref/ColumnKeys.html}, note=[Accessed: 15-August-2026]}

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /