16
$\begingroup$

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

$\endgroup$
11
  • $\begingroup$ @gwr Same occurs with Missing[]. $\endgroup$
    – Edmund
    Apr 20, 2017 at 18:34
  • $\begingroup$ The All does seem logical, since you are using a list of a list of associations, so there is somehow a key missing on that level. $\endgroup$
    – gwr
    Apr 20, 2017 at 19:34
  • $\begingroup$ @gwr I agree but it is in the wrong position and has no details under it. $\endgroup$
    – Edmund
    Apr 20, 2017 at 20:19
  • $\begingroup$ I have deleted my answer. While the behavior is disappointing, there are some ways to tackle this imo: For queries everything should work as expected and I would follow WReach's advice to not wrap the structure in a Dataset. For Display a workaround may be to Inactivate[ asscList ], which can always be removed by Activate. $\endgroup$
    – gwr
    Apr 21, 2017 at 10:45
  • $\begingroup$ Take out the extra parentheses: asscList = {<|"v1" -> 6, "v2" -> Null|>, <|"v1" -> 3, "v2" -> Null|>} $\endgroup$ May 14, 2018 at 5:07

3 Answers 3

1
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ Nope. I mean the values of "V" a List of Lists of Associations. The list in the OP is the simplest example to illustrate the issue. $\endgroup$
    – Edmund
    May 17, 2017 at 21:48
1
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

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?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.