TransWikia.com

Dataset shows an "All" Key when it contains a List of Associations

Mathematica Asked by Edmund on March 24, 2021

From a process I have a Dataset similar to this minimal example.

asscList = {{<|"v1" -> 6, "v2" -> Null|>}, {<|"v1" -> 3, "v2" -> Null|>}};
data = <|"N" -> 1, "V" -> asscList|>;
ds1 = Dataset[<|"A" -> data, "B" -> data|>]

Mathematica graphics

As can be seen above, Dataset has added an All key and moved the subkeys under this key. The unused area beneath this is greyed.

The Dataset is usable so I think it is just a formatting issue.

ds1["A", "V", 1, 1, "v1"]
6
ds1["A", "V", All, 1, "v1"] // Normal
{6, 3}

If the Nulls are removed then it does remove the All key but still has a greyed area to the along the right-hand side. Also, the subkeys no longer display in the header.

asscList2 = {{<|"v1" -> 6, "v2" -> 4|>}, {<|"v1" -> 3, "v2" -> 5|>}};
data2 = <|"N" -> 1, "V" -> asscList2|>;
ds2 = Dataset[<|"A" -> data2, "B" -> data2|>]

Mathematica graphics

If the All needs to be seen I would expect it under the "V" key. Is there a way to have ds1 display as ds2? It is not ideal but it is a better presentation.

version 11.1 on Win 7 Ent

CASE:3892468

3 Answers

Don't you mean to do this:

asscList = <|<|"v1" -> 6, "v2" -> Null|>, <|"v1" -> 3,"v2" -> Null|>|>;
data = <|"N" -> 1, "V" -> asscList|>; 
ds1 = Dataset[<|"A" -> data, "B" -> data|>]

enter image description here

Answered by Lou on March 24, 2021

Further exploration the answer looks like something like this based on the question and exploration above leaving out the Null

asscList2 = {{<|"v1" -> 6, "v2" -> 4|>}, {<|"v1" -> 3, "v2" -> 5|>}};
data2 = <|"N" -> 1, "V" -> asscList2|>;
ds2 = Dataset[<|"A" -> data2, "B" -> data2|>]

enter image description here

Extending Naming A and B with C and D you get

data3 = <|"A" -> <|"N" -> 1, "v1" -> 6, "v2" -> 4|>,
"B" -> <|"N" -> 1, "v1" -> 3, "v2" -> 5|>,
<|"C" -> <|"N" -> 1, "v1" -> 6, "v2" -> 4|>,
<|"D" -> <|"N" -> 1, "v1" -> 3, "v2" -> 5|>|>|>|>
ds3 = Dataset[data3]

ds3

Is that the idea?

Answered by ps1 on March 24, 2021

In V12.2 this seems to be improved, a little:

asscList = {{<|"v1" -> 6, "v2" -> Null|>}, {<|"v1" -> 3, 
     "v2" -> Null|>}};
data = <|"N" -> 1, "V" -> asscList|>;
ds1 = Dataset[<|"A" -> data, "B" -> data|>]

It says columns 1-2 of 3, but click the next/advance buttons does nothing. It does not show the "v1" and "v2" keys either.

Answered by Michael E2 on March 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP