ColumnKeyExistsQ[data,key]
returns True if the specified key exists in the tabular data, and False otherwise.
ColumnKeyExistsQ[key]
represents an operator form of ColumnKeyExistsQ that can be applied to an expression.
ColumnKeyExistsQ
ColumnKeyExistsQ[data,key]
returns True if the specified key exists in the tabular data, and False otherwise.
ColumnKeyExistsQ[key]
represents an operator form of ColumnKeyExistsQ that can be applied to an expression.
Details
- ColumnKeyExistsQ is typically used to find out whether a column key exists before attempting to use it.
- Possible forms of data in ColumnKeyExistsQ[data,key] 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 - ColumnKeyExistsQ[key][data] is equivalent to ColumnKeyExistsQ[data,key].
Examples
open all close allBasic Examples (1)
Check whether a column key exists in a Tabular object:
Tabular[{{1, 2, 3}, {4, 5, 6}}, {"a", "b", "c"}]ColumnKeyExistsQ[%, "b"]ColumnKeyExistsQ[%%, "d"]Scope (8)
Data Forms (6)
Check the presence of a column key in a Tabular object:
tab = Tabular[{{1.2, "a", True}, {-3.5, "f", False}}, {"col1", "col2", "col3"}]ColumnKeyExistsQ[tab, "col3"]ColumnKeyExistsQ[tab, "col"]For a Tabular object without column keys, ColumnKeyExistsQ always returns False:
tab = Tabular[{{1, 2, 3}, {4, 5, 6}}]ColumnKeyExistsQ[tab, 2]ColumnKeyExistsQ[tab, "2"]ColumnKeyExistsQ[tab, "Column2"]Check the presence of a key in any of the associations of a list of them:
assocs = {<|"a" -> 1, "b" -> 1.5|>, <|"a" -> 2, "c" -> 3.5|>};ColumnKeyExistsQ[assocs, "a"]ColumnKeyExistsQ[assocs, "b"]ColumnKeyExistsQ[assocs, "c"]ColumnKeyExistsQ[assocs, "d"]ColumnKeyExistsQ effectively assumes Missing[…] values, as Tabular would do:
Tabular[assocs]Check the presence of a column key in a Dataset object:
ds = Dataset[{<|"a" -> 1, "b" -> True|>, <|"a" -> 3, "b" -> False|>}]ColumnKeyExistsQ[ds, "b"]ColumnKeyExistsQ[ds, "c"]Check the presence of a component key in an EventSeries object:
EventSeries[{{1, "dog"}, {2, "cat"}, {4, "fox"}}, {{0, 0.1, 0.5}}, ComponentKeys -> {"number", "animal"}]ColumnKeyExistsQ[%, "animal"]ColumnKeyExistsQ[%%, "foo"]Use ColumnKeyExistsQ as an operator form:
Tabular[{{1.2, "a"}, {-3.5, "f"}}, {"col1", "col2"}]%//ColumnKeyExistsQ["col2"]%%//ColumnKeyExistsQ["COL2"]Key Forms (2)
Check whether a given column key is present in a Tabular object:
tab = Tabular[{{1, "a", True}, {2, "b", False}}, {"col1", "col2", "col3"}]ColumnKeyExistsQ[tab, "col2"]The key in ColumnKeyExistsQ[tab,key] can be wrapped in Key or ExtendedKey:
ColumnKeyExistsQ[tab, Key["col2"]]ColumnKeyExistsQ[tab, ExtendedKey["col2"]]Take a Tabular object with extended column keys:
tab = Tabular[{{1, "a", 3.2}, {2, "b", 7.5}}, {ExtendedKey["col1", "number"], ExtendedKey["col1", "string"], ExtendedKey["col2", "number"]}]Check whether a given extended key is present:
ColumnKeyExistsQ[tab, ExtendedKey["col1", "string"]]ColumnKeyExistsQ[tab, ExtendedKey["col2", "string"]]Extended keys can be addressed by their last argument if they are unique:
ColumnKeyExistsQ[tab, "string"]ColumnKeyExistsQ[tab, "number"]Properties & Relations (2)
ColumnKeyExistsQ[tab,key] is equivalent to MemberQ[ColumnKeys[tab],key]:
tab = Tabular[{{1, "a", True}, {2, "b", False}}, {"col1", "col2", "col3"}]{ColumnKeyExistsQ[tab, "col2"], ColumnKeyExistsQ[tab, "col4"]}keys = ColumnKeys[tab]{MemberQ[keys, "col2"], MemberQ[keys, "col4"]}For a list assocs of associations, ColumnKeyExistsQ[assocs,key] is equivalent to using KeyExistsQ in the associations:
assocs = {<|"a" -> 1, "b" -> True|>, <|"a" -> 4, "c" -> Today|>}ColumnKeyExistsQ["a"]@assocsKeyExistsQ["a"] /@ assocsColumnKeyExistsQ returns True if the key exists in any of the associations:
ColumnKeyExistsQ["b"]@assocsKeyExistsQ["b"] /@ assocsSee Also
ColumnKeys KeyExistsQ Key ExtendedKey Tabular MemberQ FreeQ Missing
Related Guides
Text
Wolfram Research (2025), ColumnKeyExistsQ, Wolfram Language function, https://reference.wolfram.com/language/ref/ColumnKeyExistsQ.html (updated 2026).
CMS
Wolfram Language. 2025. "ColumnKeyExistsQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2026. https://reference.wolfram.com/language/ref/ColumnKeyExistsQ.html.
APA
Wolfram Language. (2025). ColumnKeyExistsQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ColumnKeyExistsQ.html
BibTeX
@misc{reference.wolfram_2026_columnkeyexistsq, author="Wolfram Research", title="{ColumnKeyExistsQ}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/ColumnKeyExistsQ.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_columnkeyexistsq, organization={Wolfram Research}, title={ColumnKeyExistsQ}, year={2026}, url={https://reference.wolfram.com/language/ref/ColumnKeyExistsQ.html}, note=[Accessed: 13-June-2026]}