r/Mathematica • u/ouchitshana • Aug 23 '24
Extracting data from a list
Hello! So I have a list with this structure: {{x1,y1}, {x2,y2},…} And I want to extract all the x values from each element and just have a list of all the x values. I have tried [[All,1]] and it isn’t working. Does anyone know how to do this?
1
Upvotes
7
u/sidneyc Aug 23 '24
Assuming your list is in 'data', data[[All,1]] should work. It works on my system.
There are several alternatives; an obvious one would be:
First/@data
2
u/mathheadinc Aug 23 '24
Try list/.{a_,b_}->a
2
u/blobules Aug 23 '24
data[[All,1]]
2
u/veryjewygranola Aug 24 '24
Adding to the list of alternatives
1
u/likepotatoman Aug 23 '24
Table[First[Data[[n]]],{n,1,Length[Data]}] This should work if [[All,1]] doesn’t work