Wolfram Research

Function Repository Resource:

DatasetForm

Source Notebook

Display data formatted like a dataset

Contributed by: Bob Sandheinrich

ResourceFunction["DatasetForm"][data]

gives data formatted like a Dataset, but still interpreted as data.

Details and Options

ResourceFunction["DatasetForm"] only changes the formatting of the output. It does not change the computable nature of the data or optimize it for queries like Dataset.
Unlike Dataset, the output of ResourceFunction["DatasetForm"] can be copied and reused.
ResourceFunction["DatasetForm"] accepts any data structure supported by Dataset, including a Dataset.

Examples

Basic Examples

Output rows of data as a dataset:

In[1]:=
ResourceFunction["DatasetForm"][
 Table[<|"x" -> RandomInteger[1000], "y" -> RandomReal[]|>, {3}]]
Out[1]=

Copying the result and reevaluating gives the original data:

In[2]:=
{
Association["x" -> 773, "y" -> 0.9758129606815749], 
Association["x" -> 767, "y" -> 0.7936232581210563], 
Association["x" -> 884, "y" -> 0.2519684558814408]}
Out[2]=

Scope

A row of values:

In[3]:=
ResourceFunction["DatasetForm"][Range[15]]
Out[3]=

Labeled rows and columns:

In[4]:=
ResourceFunction["DatasetForm"][
 EntityValue[
  EntityClass["Element", "NobleGas"], {"BoilingPoint", "Density"}, "Dataset"]]
Out[4]=

A larger dataset creates a larger output with scroll bars:

In[5]:=
ResourceFunction["DatasetForm"][
 ResourceData["IBRD Statement of Loans"]]
Out[5]=

Properties and Relations

Dataset gives a result that cannot be copied:

In[6]:=
dataset = Dataset[{<|"a" -> 1, "b" -> "x", "c" -> {1}|>}]
Out[6]=
In[7]:=
Dataset[ <> ]

Use DatasetForm on the dataset to make it copyable:

In[8]:=
ResourceFunction["DatasetForm"][dataset]
Out[8]=
In[9]:=
Removed["Dataset"][{
Association["a" -> 1, "b" -> "x", "c" -> {1}]}, 
TypeSystem`Vector[
TypeSystem`Struct[{"a", "b", "c"}, {
TypeSystem`Atom[Integer], 
TypeSystem`Atom[String], 
TypeSystem`Vector[
TypeSystem`Atom[Integer], 1]}], 1], 
Association["ID" -> 103354260748847]]
Out[9]=

The result of DatasetForm is a DatasetForm object:

In[10]:=
Head[ResourceFunction["DatasetForm"][Range[100]]]
Out[10]=

The output of DatasetForm is not computable like a Dataset:

In[11]:=
ResourceFunction["DatasetForm"][
  Table[<|"x" -> RandomInteger[1000], "y" -> RandomReal[]|>, {10}]][
 Select[#x < 100 &]]
Out[11]=
In[12]:=
Dataset[Table[<|"x" -> RandomInteger[1000], "y" -> RandomReal[]|>, {10}]][Select[#x < 100 &]]
Out[12]=

Resource History

See Also

License Information