Message Boards Message Boards

0
|
791 Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Dataset output is not as expected

Posted 3 months ago
POSTED BY: Karl Fraser
5 Replies
Posted 3 months ago

The "group" header doesn't add anything semantically relevant. Are you doing this purely for display purposes?

The simplest thing that is semantically equivalent would be just:

Join[data]
(* <|"on" -> <|"A" -> <|Length -> 19, Total -> 8|>, "B" -> <|Length -> 19, Total -> 8|>, "C" -> <|Length -> 7, Total -> 0|>|>, 
     "off" -> <|"A" -> <|Length -> 9, Total -> 42|>, "B" -> <|Length -> 7, Total -> 11|>, "C" -> <|Length -> 9, Total -> 27|>|>|> *)

Or wrapping that with Dataset:

enter image description here

If you really want the "group", you could do something like this:

<|"group" -> #|> & /@ Join[data]

or with Dataset:

Dataset[<|"group" -> #|> & /@ Join[data]]

enter image description here

If you really want the Length and Total headers to be at at the top under group, then it would take me more time than I'm willing to spend fiddling with it. Dataset has very strong "opinions" on how things should be displayed. Maybe just transposing Length-Total with A-B-C would work. If your main concern is just display, then I'd use some other structure, maybe even just Grid.

POSTED BY: Eric Rimbey
Posted 3 months ago

Thanks guys, this is helpful. I have the Dataset as you show, but went down the rabbit hole of nicer display. I may checkout this Grid structure, thanks again.

POSTED BY: Karl Fraser
Posted 3 months ago

Could you also add the exact output that you want to achieve? I am not sure of what you want to do, but I am sure it is easier than what you are doing.

POSTED BY: Gustavo Delfino
Posted 3 months ago

Your data variable seems to be missing a |> just before the "Closed" key. And what is data["on"] ? There is no "on" key in the data association.

POSTED BY: Gustavo Delfino
Posted 3 months ago

Hi, I have corrected the "on/off" key and the missing |> in data now (last minute edits). But the final dataset still generates a duplicate row?

POSTED BY: Karl Fraser
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract