This question is an extension of the 43122. I’ve looked through many interesting post (like this) but (as always) missed the direct matching. So the setting is simple:
datum = {{{2, g}, {6, h}, {7, k}},
{{2, a}, {4, b}, {7, d}},
{{4, e}, {7, f}}}
Note: numbers {2, 4, 6, 7}
are ordered but arbitrary (that differs with related question that seems promising).
I need reliable and possibly concise method suitable for working with matrices of the size around 1000 x 1000 (that are as a rule time series). May be some specific ad hoc build-in methods.
Expected result ("X" any constant, i.e. Missing[]
):
{
{{2, g}, {4, "X"}, {6, h}, {7, k}},
{{2, a}, {4, b}, {6, "X"}, {7, d}},
{{2, "X"}, {4, e}, {6, "X"}, {7, f}}
}
PS. My current method seems, sort of, naive and long.
sample = Union @@ (#[[All, 1]] & /@ datum)
(* {2, 4, 6, 7} *)
step1 = Complement[sample, #[[All, 1]]] & /@ datum;
step2 = Thread[{#, Array["X" &, Length[#]]}] & /@ step1;
MapThread[Union, {datum, step2}]
Thanks in advance to everyone who respond.