Take a list of Associations. Using the Dataset function, this can be converted to a structured dataset.
associationList={
<|"a"->1,"b"->"x","c"->9|>,
<|"a"->2,"b"->"y","c"->8|>,
<|"a"->3,"b"->"z","c"->7|>}
dataset=Dataset[associationList]
Consider these three functions which can perform simple operations on each association.
function1=Function[{input},input[[{"c","b"}]]];
function2=Function[{input},Keys[input]];
function3=Function[{input},input[[Keys[input]]]];
When the first function is applied, it Takes elements based on hard-coded Keys.
dataset[All,function1]
Map[function1,associationList]
When the second function is applied, it programmatically gives all Keys.
dataset[All,function2]
Map[function2,associationList]
However, when the final function is applied, something peculiar occurs. For the list of Associations, it evaluates the Keys and uses these to Take elements, as I expected. For the Dataset, it gives an error.
dataset[All,function3]
Map[function3,associationList]
I initially assumed a Dataset was just a wrapper for a list of (nested) Associations. And that dataset[All, func] would loop over all internal Associations and apply func, similar to Map. This idea was too naive.
Can someone explain why the current behaviour makes sense?
Note that I am not looking for a work-around to apply function3 to my Dataset. I know I can obtain the desired answer in multiple ways. I am trying to understand the connection between Associations and Dataset.





Needs["Dataset"],Needs["TypeSystem"]andGetType[dataset]givesStruct[{"a", "b", "c"}, {Atom[Integer], Atom[String], Atom[Integer]}]. – LBogaardt Nov 06 '19 at 15:36Datasetisn't just a wrapper forAssociationsbut rather includes information on the types of data contained within. It is interesting to note at the WTC this year, we were told that this extra information causes more problems than it solves and is being done away with. In fact, lots of major changes are coming toDataset. FYI, you can see the structure in your example above by usingInputForm[dataset]. – kickert Nov 06 '19 at 15:54