Class AbstractColumn<C extends Column<T>,T>

java.lang.Object
tech.tablesaw.columns.AbstractColumn<C,T>
All Implemented Interfaces:
Iterable<T>, Comparator<T>, Column<T>
Direct Known Subclasses:
AbstractStringColumn, BooleanColumn, DateColumn, DateTimeColumn, InstantColumn, NumberColumn, TimeColumn

public abstract class AbstractColumn<C extends Column<T>,T> extends Object implements Column<T>
Partial implementation of the Column interface
  • Field Details

  • Constructor Details

  • Method Details

    • name

      public String name()
      Returns the column's name.
      Specified by:
      name in interface Column<C extends Column<T>>
      Returns:
      name as String
    • setName

      public C setName(String name)
      Sets the columns name to the given string
      Specified by:
      setName in interface Column<C extends Column<T>>
      Parameters:
      name - The new name MUST be unique for any table containing this column
      Returns:
      this Column to allow method chaining
    • parser

      public AbstractColumnParser<T> parser()
      Returns the parser used by Column.appendCell(String) ()}.
      Specified by:
      parser in interface Column<C extends Column<T>>
      Returns:
      AbstractColumnParser
    • setParser

      public C setParser(AbstractColumnParser<T> parser)
      Sets the parser used by Column.appendCell(String)
      Specified by:
      setParser in interface Column<C extends Column<T>>
      Parameters:
      parser - a column parser that converts text input to the column data type
      Returns:
      this Column to allow method chaining
    • type

      public ColumnType type()
      Returns this column's ColumnType
      Specified by:
      type in interface Column<C extends Column<T>>
      Returns:
      ColumnType
    • emptyCopy

      public abstract Column<T> 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 Column<T>>
      Returns:
      a empty copy of Column
    • filter

      public C filter(Predicate<? super T> test)
      Returns a new Column of the same type with only those rows satisfying the predicate
      Specified by:
      filter in interface Column<C extends Column<T>>
      Parameters:
      test - the predicate
      Returns:
      a new Column of the same type with only those rows satisfying the predicate
    • sorted

      public C sorted(Comparator<? super T> comp)
      Returns a new Column of the same type sorted according to the provided Comparator
      Specified by:
      sorted in interface Column<C extends Column<T>>
      Parameters:
      comp - the Comparator
      Returns:
      a sorted Column
    • map

      public C map(Function<? super T,? extends T> fun)
      Maps the function across all rows, appending the results to a new Column of the same type
      Specified by:
      map in interface Column<C extends Column<T>>
      Parameters:
      fun - function to map
      Returns:
      the Column with the results
    • min

      public C min(Column<T> other)
      Returns a column containing the element-wise min between this column and other column

      TODO(lwhite) Override in column subtypes for better performance

      Specified by:
      min in interface Column<C extends Column<T>>
    • max

      public C max(Column<T> other)
      Returns a column containing the element-wise min between this column and other column

      TODO(lwhite) Override in column subtypes for better performance

      Specified by:
      max in interface Column<C extends Column<T>>
    • set

      public C set(Selection condition, Column<T> other)
      Updates this column where values matching the selection are replaced with the corresponding value from the given column
      Specified by:
      set in interface Column<C extends Column<T>>
    • set

      public C set(Selection rowSelection, T newValue)
      Conditionally update this column, replacing current values with newValue for all rows where the current value matches the selection criteria
      Specified by:
      set in interface Column<C extends Column<T>>
    • first

      public C first(int numRows)
      Returns a column of the same type containing the first numRows of this column.
      Specified by:
      first in interface Column<C extends Column<T>>
    • last

      public C last(int numRows)
      Returns a column of the same type containing the last numRows of this column.
      Specified by:
      last in interface Column<C extends Column<T>>
    • sampleN

      public C sampleN(int n)
      Returns a column containing a random sample of the values in this column
      Specified by:
      sampleN in interface Column<C extends Column<T>>
      Parameters:
      n - the number of values to select
      Returns:
      A column of the same type as the receiver
    • sampleX

      public C sampleX(double proportion)
      Returns a table consisting of randomly selected values from this column. The sample size is based on the given proportion of the total number of cells in this column
      Specified by:
      sampleX in interface Column<C extends Column<T>>
      Parameters:
      proportion - The proportion to go in the sample
    • subset

      public C subset(int[] rows)
      Return a column of the same type containing just those elements whose indexes are included in the given array
      Specified by:
      subset in interface Column<C extends Column<T>>
    • inRange

      public C inRange(int start, int end)
      Returns a column containing the rows in this column beginning with start inclusive, and ending with end exclusive
      Specified by:
      inRange in interface Column<C extends Column<T>>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • asStringColumn

      public StringColumn asStringColumn()
      Returns a StringColumn consisting of the (unformatted) String representation of this column values
      Specified by:
      asStringColumn in interface Column<C extends Column<T>>
      Returns:
      a StringColumn built using the column Column.getUnformattedString(int) method
    • indexOf

      public int indexOf(Object o)
      Returns the index of the first occurrence of o in the column or -1 if the element is not in the column.
      Specified by:
      indexOf in interface Column<C extends Column<T>>