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 the number of column names must be equal.

Examples

Basic Examples (2) 

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]=

Publisher

Christian Erichsen

Version History

  • 1.0.0 – 18 November 2019

Related Resources

Author Notes

These functions were developed in order to streamline dataset creation with custom column names. Adding support for named rows could be added in the future.

License Information