Tuesday 31 March 2020

TableSaw: countUnique: Count unique elements in a column

'countUnique' method returns number of unique elements in a column.

App.java
package com.sample.app;

import tech.tablesaw.api.IntColumn;

public class App {

 public static void main(String args[]) {
  int[] numbers = { 23, 45, 6, 32, 1, 43, 1, 45, 6, 1, 1 };

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

  int uniqueElements = numbersColumn.countUnique();

  System.out.println("uniqueElements : " + uniqueElements);
 }
}

Output
uniqueElements : 6


Previous                                                    Next                                                    Home

No comments:

Post a Comment