# Modify a sub-part of a sub-list only

I have this list:

a = {{{0, 0}, {1, 7}, {2, 0}, {3, 2}, {4, 7}}, {{0, 0}, {1, 0}, {2, 1}, {3, 2}, {4, 7}}}


and I'd like to transform it to this:

a = {{{0, 0}, {1, 7}, {2, Na}, {3, 2}, {4, 7}}, {{0, 0}, {1, Na}, {2, 1}, {3, 2}, {4, 7}}}


ie I'd like to replace every 0 by Na except in the first sub-sub-list of each sub-list.

All I can come up with is:

Part[#, 2 ;; All, All] & /@ a  /. 0 -> Na


and it works I get

{{{1, 7}, {2, Na}, {3, 2}, {4, 7}}, {{1, Na}, {2, 1}, {3, 2}, {4, 7}}}


but the modification is not attributed to a.

How can I do that?

-
a = Part[#, 2 ;; All, All] & /@ a /. 0 -> Na or perhaps you intended to modify the original copy of a ? – image_doctor Jan 8 '13 at 12:10
yes I need to modify the original copy of a your solution below works thanks! – Sulli Jan 8 '13 at 12:58

This will work if all your first elements of the sub-lists are of the form {0,0}

a = a /. {{x_?Positive, 0} :> {x, Na}};
a


{{{0, 0}, {1, 7}, {2, Na}, {3, 2}, {4, 7}}, {{0, 0}, {1, Na}, {2, 1}, {3, 2}, {4, 7}}}

-

Another quick possibility

a=a/. {n_, r:{_Integer,_Integer}...} :> Join[{n},{ r} /. 0->Na]

-