Given a hierarchical data set, I am looking for a way to extract a list of values by their keys. When I use the Part syntax for a single key, I get the value. But when I use a list of keys, I get a Dataset. Is there a succinct way to get a list of values instead?
In[1]:= as = Association /@ {
{"a" -> 1, "b" -> 2, "c" -> 3},
{"d" -> 2, "e" -> 3, "f" -> 1}
};
In[2]:= ds = Dataset[as]
Out[2]= Dataset[{__Association}]
In[3]:= ds[[1, "b"]]
Out[3]= 2
In[4]:= ds[[1, {"b", "c"}]]
Out[4]= Dataset[_Association]
What I want is {2,3}
And thanks, David. I also am unsure as to when to use structured lists and when to use associations or datasets. In this case I like the dataset just because of its default display form. I am really processing ray files from an optical simulation. The files consist of descriptions of rays, where each ray is defined by a sequence of ray segments, with 31 items of interest for each segment, and it is these that benefit from descriptive names. So a single ray can be extracted from the database and seen as a list of segments, with a header representing identifying the segment data. And the segment detials can be extracted by keys. I also suspect I will have use for the Query capabilities.