Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting column in Mathematica [duplicate]

I have a huge list, ex. {a,b,c},{d,e,f} and I must have only {a,c},{d,f}. I using import from url. My sentence:

Drop[Import["url"],{2}] 

And it doesn't work. Why?


2 Answers

Just use the third parameter of the Drop function, like so:

list = {{a, b, c}, {d, e, f}};
Drop[list, None, {2}]

This will return:

{{a, c}, {d, f}}
like image 120
Mr Alpha Avatar answered Feb 16 '26 06:02

Mr Alpha


You need to map drop over the list.

list = {{a, b, c}, {d, e, f}};
Map[Drop[#, {2}] &, list]

{{a, c}, {d, f}}

Alternatively, use transpose, but this is apparently less efficient because it makes copies of the list.

Transpose@Drop[Transpose@list, {2}]
like image 31
Chris Degnen Avatar answered Feb 16 '26 06:02

Chris Degnen