Rearranging a Dataset

If we assume that we are starting from the exhibited dataset:

dataset = Dataset@assoc;

... then we can reshape it like this:

dataset[All, Apply@Association]

Or, equivalently:

dataset[Map[Apply@Association]]

dataset screenshot

This will also do the trick, although it is a little messy since MapThread presently lacks an operator form:

dataset[{Keys, Values}][MapThread[Association, #]&]

Edit

And here is yet another way:

dataset[All, <| Keys@#, Values@# |> &]

test = {<|"name" -> "alpha", "group" -> "one"|> -> {<|"value" -> 459|>}, 
        <|"name" -> "beta", "group" -> "two"|> -> {<|"value" -> -338|>}, 
        <|"name" -> "gamma", "group" -> "two"|> -> {<|"value" -> 363|>}};

Association /@ Flatten /@ Normal[test /. Rule -> List] // Dataset

Dataset


Dataset[Join@@@({#,Join@@#2}&@@@test)]
(* or  Dataset[Join@@@({#,Sequence@@#2}&@@@test)] *)

enter image description here

Tags:

Dataset