fslaborg / Deedle

Easy to use .NET library for data and time series manipulation and for scientific programming
http://fslab.org/Deedle/
BSD 2-Clause "Simplified" License
929 stars 196 forks source link

Add Take extension method to slice a dataframe by rows and return another dataframe #316

Closed gbonventre closed 4 years ago

gbonventre commented 9 years ago

Ideally it would be nice to slice a dataframe by a range of rows and return another dataframe. Additionally, it would be nice to pass a list of row indices and return a new dataframe with only those rows listed in the list.

zyzhu commented 4 years ago

See below a sample case for slicing rows with a list of row keys

let df = frame ["A", [1..100] |> Series.ofValues]
let sliced = df.Rows.[20..30]

fsi output

val sliced : Frame<int,string> =

      A  
20 -> 21 
21 -> 22 
22 -> 23 
23 -> 24 
24 -> 25 
25 -> 26 
26 -> 27 
27 -> 28 
28 -> 29 
29 -> 30 
30 -> 31