Picking a different column in each row of a Dataset[]
With Dataset
's syntax sugar you may implicitly use Query
.
ds
as in OP, then
ds[
GroupBy["x"],
All,
KeyDrop["x"] /*
Normal /*
Curry[SelectFirst, {3, 1, 2}][FreeQ[_Missing], "x" -> Missing[]]
] //Normal
<|1 -> {"b" -> 10, "x" -> Missing[], "a" -> 11}, 2 -> {"a" -> 12}|>
Hope this helps.
foo = Select[MatchQ[Except[_Missing]]] /*
(# /. Association[] -> Association["x" -> Missing[]] &) /*
KeyValueMap[Rule] /*
First;
ds2 = ds[Select[#x == 1 &], {"a", "b", "c"} /* <|"fc" -> foo|>];
Join[ds[Select[#x == 1 &]], ds2, 2]