Class NumberColumn<C extends NumberColumn<C,T>,T extends Number>

java.lang.Object
tech.tablesaw.columns.AbstractColumn<C,T>
tech.tablesaw.api.NumberColumn<C,T>
Type Parameters:
C - The column type
T - The (boxed) type of data in the column
All Implemented Interfaces:
Iterable<T>, Comparator<T>, NumericColumn<T>, Column<T>, NumberFilters, NumberMapFunctions, FilterSpec<Selection>, NumberFilterSpec<Selection>
Direct Known Subclasses:
DoubleColumn, FloatColumn, IntColumn, LongColumn, ShortColumn

public abstract class NumberColumn<C extends NumberColumn<C,T>,T extends Number> extends AbstractColumn<C,T> implements NumericColumn<T>
An abstract class that provides a partial implementation for columns of numeric data
  • Field Details

    • locale

      protected Locale locale
    • comparator

      protected final it.unimi.dsi.fastutil.ints.IntComparator comparator
  • Constructor Details

  • Method Details

    • createCol

      protected abstract C createCol(String name, int size)
    • createCol

      protected abstract C createCol(String name)
    • set

      public NumberColumn<C,T> set(DoublePredicate condition, NumberColumn<C,T> other)
      Updates this column where values matching the selection are replaced with the corresponding value from the given column
    • set

      public NumberColumn<C,T> set(DoublePredicate condition, T newValue)
      Sets the value of all elements in this column matching condition to be equal to newValue and returns this column
    • setPrintFormatter

      public void setPrintFormatter(NumberFormat format, String missingValueIndicator)
      Sets the print formatter to a new ColumnFormatter constructed from the given number format and missing value indicator TODO: make these return the column?
      Specified by:
      setPrintFormatter in interface NumericColumn<C extends NumberColumn<C,T>>
    • setPrintFormatter

      public void setPrintFormatter(NumberColumnFormatter formatter)
      Sets the print formatter to the argument
      Specified by:
      setPrintFormatter in interface NumericColumn<C extends NumberColumn<C,T>>
    • getPrintFormatter

      protected NumberColumnFormatter getPrintFormatter()
      Returns the NumbetPrintFormatter for this column, or null
    • top

      public abstract NumericColumn<T> top(int n)
      Returns the largest ("top") n values in the column TODO(lwhite): Consider whether this should exclude missing
      Parameters:
      n - The maximum number of records to return. The actual number will be smaller if n is greater than the number of observations in the column
      Returns:
      A list, possibly empty, of the largest observations
    • bottom

      public abstract NumericColumn<T> bottom(int n)
      Returns the smallest ("bottom") n values in the column TODO(lwhite): Consider whether this should exclude missing
      Parameters:
      n - The maximum number of records to return. The actual number will be smaller if n is greater than the number of observations in the column
      Returns:
      A list, possibly empty, of the smallest n observations
    • getString

      public String getString(int row)
      Returns a string representation of the value at the given row.
      Specified by:
      getString in interface Column<C extends NumberColumn<C,T>>
      Parameters:
      row - The index of the row.
      Returns:
      value as String
    • emptyCopy

      public C emptyCopy()
      Returns a copy of the receiver with no data. The column name and type are the same.
      Specified by:
      emptyCopy in interface Column<C extends NumberColumn<C,T>>
      Returns:
      a empty copy of Column
    • emptyCopy

      public C emptyCopy(int rowSize)
      Returns an empty copy of the receiver, with its internal storage initialized to the given row size.
      Specified by:
      emptyCopy in interface Column<C extends NumberColumn<C,T>>
      Parameters:
      rowSize - the initial row size
      Returns:
      a Column
    • rowComparator

      public it.unimi.dsi.fastutil.ints.IntComparator rowComparator()
      Compares the given ints, which refer to the indexes of the doubles in this column, according to the values of the doubles themselves
      Specified by:
      rowComparator in interface Column<C extends NumberColumn<C,T>>
    • byteSize

      public int byteSize()
      Returns the width of a cell in this column, in bytes.
      Specified by:
      byteSize in interface Column<C extends NumberColumn<C,T>>
      Returns:
      width in bytes
    • countMissing

      public int countMissing()
      Returns the count of missing values in this column
      Specified by:
      countMissing in interface Column<C extends NumberColumn<C,T>>
      Returns:
      missing values as int