# Dataset with more than 16 “columns”?

A Dataset with 16 columns or less is shown in a nice way:

Association @@@
Table["col" <> ToString@j -> i j, {i, 10}, {j, 16}] // Dataset


A Dataset with more than 16 columns no.

set = Association @@@
Table["col" <> ToString@j -> i j, {i, 10}, {j, 17}] // Dataset


At this point one can guess a proper subset of these 17 columns is shown in a nice way. Indeed:

set[All, 1 ;; 2]


Wrong guess :) But it's "easy" to improve this appearance:

set[All, 1 ;; 2] // Normal // Dataset


Am'I missing something or there is maybe a super-secret option to control this behavior?

• This isn't quite what you want, but you can get a bit of control over how much the Dataset typesetting shows by modifying the variable Dataset\$ElisionThreshold. However, that doesn't help here. The problem is that when going from 16 to 17 columns, the deduced type of the data goes from TypeSystemStruct to TypeSystemAssoc, which has different typesetting rules (although it probably should be displayed as nicely, perhaps a minor bug?). – Stefan R Apr 28 '15 at 20:58
• Note that you can inspect the deduced data type by using DatasetGetType, e.g. DatasetGetType[set]. – Stefan R Apr 28 '15 at 21:00
• Also, Dataset has an undocumented second argument, where you can explicitly specify the type: Dataset[data, type]. So here you could do Dataset[data, TypeSystemVector[TypeSystemStruct[{"col1",...,"col17"}, {TypeSystemAtom[Integer],....},10]] – Stefan R Apr 28 '15 at 21:04
• This is similar to the question I asked here. In this case the answer is not quite as useful but I think its still a minor improvement on what you have. Basically wrap your selection criteria in braces. set[All, {1 ;; 2}] if we are lucky @Mr.Wizard will be along shortly to improve it ;) – Gordon Coale Apr 28 '15 at 21:35
• @StefanR Consider making this an answer - it looks like a good one (to me at least). – Leonid Shifrin Apr 29 '15 at 0:03

The general "super-secret option" question was addressed by Stefan R in the comments. This is an answer to the practical problem of easily making a particular dataset show in a nice way.

Actually, it is more of a trick, and one which exploits some of the other new Mathematica machinery: semantic interpretation. It turns out that datasets created from semantically imported data are always nicely formatted, no matter the number of columns. Thus, we can use the old SemanticImportString-ExportString routine to get a proper display:

displaydataset[dataset_] := With[
{import = SemanticImportString[
ExportString[ Join[{Normal@dataset[1, Keys]}, Normal@dataset[Values]], "CSV"],
Automatic, "Dataset"]},
];


The extra structure in the last line replaces the imported keys with the old keys - imported keys come in garbled if they have any special symbols (like greek letters) in them. The rest of the data should, in most cases, be handled well by the interpreter.

With

set = Association @@@ Table["col" <> ToString@j -> i j, {i, 10}, {j, 17}] // Dataset


we get

displaydataset@set