Wolfram Research

Function Repository Resource:

DatasetWithHeaders

Source Notebook

One-step creation of a Dataset with named columns

Contributed by: Christian Erichsen

ResourceFunction["DatasetWithHeaders"][data]

creates a dataset from tabular data, using the first row as column names.

ResourceFunction["DatasetWithHeaders"][data,columnNames]

creates a dataset of the data with column names as specified in the list columnNames.

Details and Options

The number of columns and number of column names must be equal.

Examples

Basic Examples

Have all data in one list, with the first row defining the column names:

In[1]:=
data = {{"a", "b", "c"}, {1, 2, 3}, {1, 2, 3}};
ResourceFunction["DatasetWithHeaders"][data]
Out[2]=

Data and column names stored in separate lists:

In[3]:=
values = {{1, 2, 3}, {1, 2, 3}};
names = {"a", "b", "c"};
ResourceFunction["DatasetWithHeaders"][values, names]
Out[5]=

Resource History

Related Resources