Add from/to to Index and Series
Opened this issue · 1 comments
tixxit commented
It would be nice to add efficient from
and to
methods on Index
and Series
.
scala> val s: Series[String, Int] = Series("alice" -> 1, "branden" -> 2, "dan" -> 3, "tom" -> 4, "zed" -> 5)
scala> s.from("branden").to("tom")
Series("branden" -> 2, "dan" -> 3, "tom" -> 4)
BrandenPellucid commented
Another test case to keep in mind for Series:
scala> val s: Series[String, Int] = Series("alice" -> 1, "dan" -> 2, "branden" -> 3, "tom" -> 4, "zed" -> 5)
scala> s.from("alice").to("dan")
Series("alice" -> 1, "dan" -> 2, "branden" -> 3)
It always filters the range based on sorted order, however for UnorderedIndex
(and as follows a Series
), the insertion order of the entries should be maintained with the keys outside the range filtered out.