Tuesday 31 March 2020

TableSaw: Selection.withoutRange: Select elements that are not in given range

static Selection withoutRange(int totalRangeStart, int totalRangeEnd, int excludedRangeStart, int excludedRangeEnd)
Select the elements from ‘totalRangeStart’ (inclusive) to totalRangeEnd (Exclusive) and exclude the elements fro ‘excludedRangeStart’ to ‘excludedRangeEnd’.

App.java
package com.sample.app;

import tech.tablesaw.api.IntColumn;
import tech.tablesaw.selection.Selection;

public class App {

 public static void main(String args[]) {
  int[] numbers = { 2, 4, 103, 24, 53, 23, 12, 11, 56, 6 };

  IntColumn intColumn = IntColumn.create("My Numbers", numbers);

  IntColumn filteredElements = intColumn.where(Selection.withoutRange(2, 8, 3, 6));

  System.out.println(intColumn.print() + "\n");

  filteredElements.setName("Filtered Elements");
  System.out.println(filteredElements.print());
 }
}

Output
Column: My Numbers
2
4
103
24
53
23
12
11
56
6


Column: Filtered Elements
103
12
11





Previous                                                    Next                                                    Home

No comments:

Post a Comment