Helllo there,
I have encountered the same issues with Dataset. Resurecting one of my old thread (I have a tag for being a Necromancer;
([Previous post on generic display] [1]: How can I create an advanced grid interface?), I have adapted the function suggested in the link to Dataset (essentially the post was a discussion on displaying a datastructure that predated Dataset and filled its role).
Again, I like the split between static and dynamic display.
Here is the static one:
Options[DisplayTableWithHeaders]={ HeadersCols->{}, HeadersRows->{},
Title->"", SelectItems->All, SelectRows->False,
SelectCols->All, NbRows->3, NbCols->3, BuilderHeaderRows->(First[#2]&), BuilderHeaderCols->(First[#2]&), ColorBckGrd->GrayLevel[0.5`],
ItemStyle->{{Directive[FontFamily->"Helvetica",FontWeight->Bold,FontSize->Medium],None},{Directive[FontFamily->"Helvetica",FontWeight->Bold,FontSize->Medium],None},{{1,1}->Directive[FontSize->Medium],{1,2}->Directive[FontWeight->Bold]}},ItemSize->Full,Alignment->{{Left,Center},{Center,Center}},Dividers->LightGray};
DisplayDataset[ds_Dataset, opts : OptionsPattern[]] :=
DisplayTableWithHeaders[Rest@Normal@ds[[All, Values]],
Append[{opts}, HeadersCols -> Normal@Keys[ds[[1]]]]];
where the implementation of DisplayTableWithHeaders
is to be found in the post mentioned above.
And here is the dynamic one, which out of laziness, will constitute all the documentation about the options in the previous function:
DisplayDatasetLive[results_, headerscols_: {},
columnPickerCols_: True, headersrows_: {}, columnPickerRows_: False,
opts : OptionsPattern[]] :=
Module[{(*nbRows,nbCols,selRows,selCols,controlRows,controlCols*)
headerscolsFinal},
If[headerscols == {}, headerscolsFinal = Normal@Keys[results[[1]]],
headerscolsFinal = headerscols];
controlCols =
If[columnPickerCols, {{selCols, headerscolsFinal,
"Select cols from:"}, headerscolsFinal,
ControlType -> TogglerBar},
Sequence @@ {{{selCols, "StartEnd", "View cols:"}, {All,
"StartEnd", "EveryOther"}}, {{nbCols, 1,
"Number cols for display:"}, 1, Length[results\[Transpose]],
1}}];
controlRows =
If[columnPickerRows, {{selRows, headersrows, "Select rows from:"},
headersrows, ControlType -> TogglerBar},
Sequence @@ {{{selRows, "StartEnd", "View rows:"}, {All,
"StartEnd", "EveryOther"}}, {{nbRows, 1,
"Number of rows for display:"}, 1, Length[results], 1}}];
Manipulate[
DisplayDataset[results, HeadersCols -> headerscolsFinal,
HeadersRows -> headersrows, SelectRows -> selRows,
NbRows -> nbRows, NbRows -> If[columnPickerRows, 1, nbRows],
SelectCols -> selCols, NbCols -> If[columnPickerCols, 1, nbCols],
FilterRules[Flatten[{opts}], Options[DisplayTableWithHeaders]]],
Evaluate[controlRows], Evaluate[controlCols]]]
The end result is a dynamic display that have features that extend gwr's one
to allow very common investigation cases: seeing the begining and the end, every other row (every n rows actually), pick the colums and so on....
The hope is that Taliesin reads this post and find some features interesting enough to recycle them into a proper, solid, native implementation.
Best
Trad
TableForm
, just pair it withNormal
to get a simple dump of the dataset. E.g.Normal[titanic[[;;100]]]//TableForm
for the first hundred rows. $\endgroup$