There are some examples of how to get a single column from a data frame like this.
people?Age
people.["Age"]
people.GetColumn("Countries")
but how can you get a subset of multiple columns? For example, I would like to be able to do something like:
people.[["age";"Countries"]]
or
people.GetColumn(["age";"Countries"])
and have it return a data frame with just those two columns/series. Is there a simple way to do this?
Using Frame.sliceCols
is one way to do this, but you can use the slicing syntax too. The trick is to use slicing on people.Columns
rather than directly on the frame:
people.Columns.[["age";"Countries"]]
The motivation for this is that you might want to slice the rows as well, in which case you can do people.Rows.[ [1;3;5 ]
. If your frame has ordered row index, you can select a range and do people.Rows.[1 .. 10]
.