# Data Table Manipulation in Mathematica 10

I would like to select columns from a table by column name. I tried the solution described here: Data Table Manipulation in Mathematica: Step 2 . I am using Mathematica 10.

(I would write a comment there, instead of a new question, but StackExchange doesn't let me write comments yet.)

• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– user9660
Commented Mar 19, 2015 at 7:25
• look at Association in mathematica's documentation
– k_v
Commented Mar 19, 2015 at 7:36
• Ah! I realized that I couldn't use the solution described in (mathematica.stackexchange.com/questions/29336/…) because my data was in TableForm. Commented Mar 19, 2015 at 7:38
• Thanks for pointing Association, @k_v! Commented Mar 19, 2015 at 7:47

Whilst valid Leonid's code has been superseded by new functionality in Mathematica 10. As well as Association take a look at the Dataset, Select and Query functions in the help. But basically try some of the following :

data = {{"1", "Cat", "Tiddles"}, {"2", "Dog", "Spot"}};

cols = {"id", "animal", "name"};

(* turns a list of animals into an association and then into a
dataset with column headings specified by cols *)

animalsDS = Dataset[AssociationThread[cols -> #] & /@ data]


(* Just select cats *)

animalsDS[Select[#animal == "Cat" &]]


(* select cats with wildcards *)

animalsDS[Select[StringMatchQ[#"animal", "Ca*" ] &]]

(* selects animals that are cats AND (&&) called tiddles *)

animalsDS[Select[#animal == "Cat" && #name == "Tiddles" &]]

(* selects animals that are cats OR (||) dogs *)

animalsDS[Select[#animal == "Cat" ||  #animal == "Dog" &]]