I am starting to use the new Associations, so this maybe an easy question, but I haven't figured it out. I have a list of associations, like:

{<|k1->v1,k2->v2, ..., k3->v3|>, <|q1->w1,q2->w2, ..., q3->w3|>, ...}

and I would like to extract a list of data pairs of the form

{{v1,v2}, {w1,w2}, ...}

How can I do this?


2 Answers 2


There are pure association forms using Part with key names or positions for this.

(* Using key names *)
Values[assoc[[All, {"one", "two"}]]]

(* using positions *)
Values[assoc[[All, 1 ;; 2]]]
  • $\begingroup$ this doesn't seem to work if the keys in the association are arbitrary real numbers $\endgroup$
    – Michael
    Commented May 15, 2019 at 23:02

Building an example association:

tab = Table[{"one" -> i, "two" -> i^2, "three" -> i^3}, {i, 1, 10}];


assoc = Association @@@ tab;

If I understand your question right you are only interested in the first two values, so you can do the following:

vals = Values @ tab


Take[#, 2] & /@ vals

But if you want to process further on, it might be a good idea to store the information in a dataset ds = Dataset[assoc] then you can simply extract the columns you want.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.