Skip to main content
2 of 4
added 93 characters in body
E. Chan-López
  • 31.2k
  • 3
  • 29
  • 50

Using ReplacePart and Cases as follows:

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

patt = {x1_, x2_} /; x1 != 0 && x2 == 0;

ReplacePart[#, Thread[Position[#, patt] -> Cases[#, patt -> {x1, Na}, 2]]] &@a

(*{{{0, 0}, {1, 7}, {2, Na}, {3, 2}, {4, 7}}, 
 {{0, 0}, {1, Na}, {2, 1}, {3, 2}, {4, 7}}}*)
E. Chan-López
  • 31.2k
  • 3
  • 29
  • 50