This Q is related to this one, but now refer to the situation as irregularly distributed Keys
in lists of Associations
:
data4 = {<|"a" -> 1, "b" -> 2|>, <|"a" -> 3, "c" -> 4|>} // Dataset
Consider:
data4[All, {"a" -> Framed, "b" -> Panel}]
Of course this fails altogther:
data4[All, {"a" -> Framed, "b" -> Panel, "c" -> (Style[#, Red] &)}]
{Missing["Failed"], Missing["Failed"]}
Is there a better way than this clearly inefficient workaround using Lookup
and subsequent filter out based on matching Missing
? - To avoid having to add Missing
handlers for each function:
data4[All, ({"a", "b", "c"} // AssociationMap[Lookup]) /*
Query[{"a" -> Framed, "b" -> Panel, "c" -> (Style[#, Red] &)}]][
All, Select[FreeQ[#, Missing["KeyAbsent", "a" | "b" | "c"]] &]] // Normal
MissingBehaviour
option of Query could be amended to deal with this, or that Query needs some additional intelligence to handle non uniform keys. $\endgroup$MissingBehavior
,PartBehavior
andFailureAction
can rescue it. $\endgroup$MissingBehavior
should handle this option. Will contact support. $\endgroup$