Association
keys are supposed to be transparent, but in this reduced example SplitBy
fails:
ds = <|t1 -> <|"a" -> 1|>, t2 -> <|"a" -> 1|>, t3 -> <|"a" -> 2|> |>
This works:
ds // Values // SplitBy[#, #a &]&
{{<|"a" -> 1|>, <|"a" -> 1|>}, {<|"a" -> 2|>}}
But the following fail for the same reason:
ds // SplitBy[#, #a &] &
ds // Map[Normal] // SplitBy[#, #a &]&
Split::normal: "Nonatomic expression expected at position 1 in !(Split[<|t1 -> {\"a\" -> 1}, t2 -> {\"a\" -> 1}, t3 -> {\"a\" -> 2}|>, ((#a &))[#1] === ((#a &))[#2] &]). "
Is there a workaround that doesn't involve injecting keys t1
, t2
etc as key-value pairs in each row?
SplitBy
expects aList
as the first argument, no? $\endgroup$