Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Table of values e.g.


How do I replace the the "z" column with a List of values?

share|improve this question
up vote 1 down vote accepted
fun[u_, c_, r_] := Transpose@ReplacePart[Transpose[u], c -> r]


list = {{a, b, c}, {a, b, c}, {a, b, c}};
fun[list, 1, Range[3]]


{{1, b, c}, {2, b, c}, {3, b, c}}

This requires the replacement column be the same length (which I have assumed as intention) as final transpose will fail if this is not the case.

share|improve this answer

If you mean each column in each respective sublist with the respective value from the value list, the first, if you mean replacing all with a literal list, the second.

test = {{a, b, c}, {d, e, f}, {g, h, i}}
test[[All, 3]] = {1, 2, 3};
test[[All, 3]] = Sequence[{1, 2, 3}];

{{a, b, 1}, {d, e, 2}, {g, h, 3}}

{a, b, {1, 2, 3}}, {d, e, {1, 2, 3}}, {g, h, {1, 2, 3}}

share|improve this answer
Thanks, I meant the first. However my List of values is really long, so in your example: List1={1,2,3,…..n}. However test[[All, 3]] = List1 doesn't seem to work? – Ren Feb 14 '14 at 0:59
@ren: When doing the first type of replacement, the target list must have as many sublists as the replacement values list, i.e., if you have ten sublists of three values each, and you want to replace the last in each, the replacement list must be ten values. If it isn't, the behavior will mimic the second. Perhaps you could update your question with more concrete examples? – ciao Feb 14 '14 at 1:03
That sorted it, thanks! – Ren Feb 14 '14 at 1:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.