Message Boards Message Boards

0
|
3666 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to extract only one specific column out of a dataset?

Posted 3 years ago

Hello Community, as I am new to Wolfram and the Documentation does not help, I would like to consider your help:

From an Excel sheet, I have a simple dataset for a lake (depth vs. temperatures), e.g.:

data=MatrixForm[{{1,20},{10,20},{30,19},{40,17},{50,15},{60,15}}]

Besides a x,y plot, I would like to make a histogram for y-values (temperatures) only.

How do I extract the second column (y-values) here in Wolfram?

Thanks for any help. Best regards, Niels

POSTED BY: Niels Brall
3 Replies

Remember that MatrixForm is a wrapper function that affects how lists display in the notebook. Once you wrap your data in MatrixForm (or TableForm), you can't work with it easily. If you did want to enter some data and display it as a matrix, but still be able to work with it, you can do this:

MatrixForm[data={{1,20},{10,20},{30,19},{40,17},{50,15},{60,15}}]

This defines the data first, and then displays it as a matrix. (I.e., it is equivalent to)

data={{1,20},{10,20},{30,19},{40,17},{50,15},{60,15}};
MatrixForm[data]

Then you can still do data[[All,2]], etc.

POSTED BY: Gareth Russell

I would do it this way:

data = {{1, 20}, {10, 20}, {30, 19}, {40, 17}, {50, 15}, {60, 15}};
data[[All, 2]]

You can have a look at the linear algebra tutorial

POSTED BY: Gianluca Gorni

Check out Part

under Scope->Multilevel Specifications

POSTED BY: Ahmed Elbanna
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract