Create a Dataset object, Association or SparesArray from a matrix [closed]

I need to make queries and operations on a large dataset. What is the easiest way to add keys to matrix so that it is transformed to a dataset, which can later be used to make queries?

Let’s take this matrix:

mat = RandomInteger[{0, 1}, {50, 20}];
v = RandomInteger[{100, 110}, 50];
mat1 = Join[List /@ v, mat, 2] // MatrixForm

Now I want to insert “column names” and thereby change tha matrix to a Dataset object/SparseArray type without making an association with every entry by hand, like in the basic example in the help function.

dataset =
Dataset[
{<|"a" -> 101, “b” -> 1, “c” -> 0|>,
<|"a" -> 101, “b” -> 1, “c” -> 0|>,
<|"a" -> 107, “b” -> 1, “c” -> 1|>,
<|"a" -> 106, “b” -> 1, “c” -> 0|>,
<|"a" -> 102, “b” -> 0, “c” -> 1|>,
<|"a" -> 101, “b” -> 0, “c” -> 0|>}]

I’m sure there is an easy way to do this basic operation. I would also be grateful if you would point me to some resources with example code operations like this.

=================

=================

1 Answer
1

=================

mat = RandomInteger[{0, 1}, {5, 10}];
v = RandomInteger[{100, 110}, 5];
(mat1 = Join[List /@ v, mat, 2]) // MatrixForm

ds=Dataset[mat1]

colnames=CharacterRange[“a”,”z”][[;;11]];
ds2=Dataset[AssociationThread[colnames->#]&/@mat1]