Which optional Dataset argument yields the following output format?
Discussion
Given the following nested data
Given the following nested data
c1=<|"Ca""ca1","Cb""cb1","Cc""cc1"|>;c2=<|"Ca""ca2","Cb""cb2","Cc""cc2"|>;
Failing to achieve the desired Dataset display format
Failing to achieve the desired Dataset display format
In[]:=
row1="A""a1","B""b1","C"c1,"D""d1";row2="A""a2","B""b2","C"c2,"D""d2";Dataset[{row1,row2}]
Out[]=
The default output (above) is undesired because displaying {Ca, Cb, and Cc”} creates three inner rows per entry.
Achieving the desired Dataset display format ... by inserting a Quantity in each row ?!?
Achieving the desired Dataset display format ... by inserting a Quantity in each row ?!?
In[]:=
c1Q=<|"Ca"Quantity[1,"ca"],"Cb""cb1","Cc""cc1"|>;c2Q=<|"Ca"Quantity[2,"ca"],"Cb""cb2","Cc""cc2"|>;Dataset@{"A""a1","B""b1","C"c1Q,"D""d1","A""a2","B""b2","C"c2Q,"D""d2"}
Out[]=
Why does inserting a Quantity change the Dataset format ?
What optional argument to Dataset avoids my having to insert Quantity values?
Why does inserting a Quantity change the Dataset format ?
What optional argument to Dataset avoids my having to insert Quantity values?
What optional argument to Dataset avoids my having to insert Quantity values?
How did I discover this oddity?
A desired nested table is seen in ExampleData’s Planets format:
In[]:=
ExampleData[{"Dataset","Planets"}][3;;4]
Out[]=
Simplifying the table (above) to align it with my example
In[]:=
Dataset[<|"Earth" -> <| "A" -> "a1", "B" -> "b1", "C" -> <|"Moon" -> <| "Ca" -> "Ca1", "Cb" -> Quantity[1737.5`5., "Kilometers"], "Cc" -> "Cc1"|>|>|>, "Mars" -> <| "A" -> "a2", "B" -> "b2", "C" -> <|"Phobos" -> <| "Ca" -> "Ca2", "Cb" -> Quantity[11.1`3., "Kilometers"], "Cc" -> "Cc2"|>|>|>|>]
Out[]=
The following is identical to the above, except I eliminated ALL of the Quantity values and lo! The nested table is gone.
In[]:=
Dataset[<|"Earth" -> <| "A" -> "a1", "B" -> "b1", "C" -> <|"Moon" -> <| "Ca" -> "Ca1", "Cb" -> "Cb1", "Cc" -> "Cc1"|>|>|>, "Mars" -> <| "A" -> "a2", "B" -> "b2", "C" -> <|"Phobos" -> <| "Ca" -> "Ca2", "Cb" -> "Cb2", "Cc" -> "Cc2"|>|>|>|>]
Out[]=