ColumnwiseValue[cbody]
denotes that cbody, a part of the body of a function, will be evaluated once in columnwise form before using that function to transform rows in TransformColumns or ConstructColumns operations.
ColumnwiseValue
ColumnwiseValue[cbody]
denotes that cbody, a part of the body of a function, will be evaluated once in columnwise form before using that function to transform rows in TransformColumns or ConstructColumns operations.
Details
- ColumnwiseValue is typically used as part of the Function body of the transformations performed on tabular data, to precompute some partial results.
- When transforming a Tabular object tab with Function[head[…,ColumnwiseValue[cbody],…]], any instances of #col in cbody will be replaced with the entire column tab[[All,col]] and then evaluated to get the value cval. The transformation function becomes Function[head[…,cval,…]].
Examples
open all close allBasic Examples (1)
Scope (2)
Use ColumnwiseValue to subtract the mean of a column from its values:
tab = ToTabular[<|"c" -> {3.71, -2.7, -5.29, 9.33, 6.26}|>, "Columns"]ConstructColumns[tab, "c-μ" -> (#c - ColumnwiseValue[Mean[#c]]&)]This is equivalent to first computing the mean value once and then subtracting it in every row:
mean = Mean[tab[[All, 1]]]ConstructColumns[tab, "c-μ" -> (#c - mean&)]Find which elements in a column are above the median:
tab = ToTabular[<|"c" -> {4.24, 1.14, -7.38, 6.74, 6.22, 7.5}|>, "Columns"];TransformColumns[tab, "above median" -> (#c > ColumnwiseValue[Median[#c]]&)]Include a constant column with the median value:
TransformColumns[tab, {"median" -> (ColumnwiseValue[Median[#c]]&), "above median" -> (#c > ColumnwiseValue[Median[#c]]&)}]Compute the median only once by using the operator form:
(TransformColumns["median" -> (ColumnwiseValue[Median[#c]]&)] /* TransformColumns["above_median" -> (#c > #median&)])[tab]Applications (1)
Take a Tabular object of numbers:
tab = ToTabular[<|"obs" -> RandomReal[{-10, 10}, 5]|>, "Columns"]Standardize the "obs" column by acting on the column as a whole:
TransformColumns[tab, "z-score" -> Function[ColumnwiseValue[Standardize[#obs]]]]Properties & Relations (2)
Use ColumnwiseThread to compute a vector-valued transformation of an entire column:
tab = ToTabular[<|"v" -> {2.07, -0.75, 4.16, 7.28, 8.63, 7.93}|>, "Columns"];
ConstructColumns[tab, "z" -> (ColumnwiseThread[Accumulate[#v]]&)]With ColumnwiseValue, you get the same list for each row:
ConstructColumns[tab, "zlist" -> (ColumnwiseValue[Accumulate[#v]]&)]Take a Tabular object:
tab = ToTabular[{"old" -> {a, b, c}}, "Columns"]TransformColumns by default operates sequentially on each row:
TransformColumns[tab, "new" -> Function[Echo[#old, "row: "] + Echo[RandomInteger[5], " random: "]]]TransformColumns with ColumnwiseValue[expr] evaluates expr once first, then acts on each row:
TransformColumns[tab, "new" -> Function[Echo[#old, "row: "] + ColumnwiseValue[Echo[Total[#old], "total: "]]]]TransformColumns with ColumnwiseThread[expr] evaluates expr once, acting on whole columns:
TransformColumns[tab, "new" -> Function[ColumnwiseThread[Echo[#old, "column: "] + Echo[RandomInteger[5], " random: "]]]]Related Guides
History
Text
Wolfram Research (2025), ColumnwiseValue, Wolfram Language function, https://reference.wolfram.com/language/ref/ColumnwiseValue.html.
CMS
Wolfram Language. 2025. "ColumnwiseValue." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ColumnwiseValue.html.
APA
Wolfram Language. (2025). ColumnwiseValue. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ColumnwiseValue.html
BibTeX
@misc{reference.wolfram_2026_columnwisevalue, author="Wolfram Research", title="{ColumnwiseValue}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/ColumnwiseValue.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_columnwisevalue, organization={Wolfram Research}, title={ColumnwiseValue}, year={2025}, url={https://reference.wolfram.com/language/ref/ColumnwiseValue.html}, note=[Accessed: 12-June-2026]}