Package smile.data

Class IndexDataFrame

java.lang.Object
smile.data.IndexDataFrame
All Implemented Interfaces:
Iterable<Tuple>, DataFrame

public class IndexDataFrame extends Object implements DataFrame
A data frame with a new index instead of the default [0, n) row index.
  • Constructor Details

    • IndexDataFrame

      public IndexDataFrame(DataFrame df, int[] index)
      Constructor.
      Parameters:
      df - The underlying data frame.
      index - The row index.
  • Method Details

    • schema

      public StructType schema()
      Description copied from interface: DataFrame
      Returns the schema of DataFrame.
      Specified by:
      schema in interface DataFrame
      Returns:
      the schema.
    • toString

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

      public int indexOf(String name)
      Description copied from interface: DataFrame
      Returns the index of a given column name.
      Specified by:
      indexOf in interface DataFrame
      Parameters:
      name - the column name.
      Returns:
      the index of column.
    • size

      public int size()
      Description copied from interface: DataFrame
      Returns the number of rows.
      Specified by:
      size in interface DataFrame
      Returns:
      the number of rows.
    • ncol

      public int ncol()
      Description copied from interface: DataFrame
      Returns the number of columns.
      Specified by:
      ncol in interface DataFrame
      Returns:
      the number of columns.
    • get

      public Object get(int i, int j)
      Description copied from interface: DataFrame
      Returns the cell at (i, j).
      Specified by:
      get in interface DataFrame
      Parameters:
      i - the row index.
      j - the column index.
      Returns:
      the cell value.
    • stream

      public Stream<Tuple> stream()
      Description copied from interface: DataFrame
      Returns a (possibly parallel) Stream of rows.
      Specified by:
      stream in interface DataFrame
      Returns:
      a (possibly parallel) Stream of rows.
    • iterator

      public Iterator<Tuple> iterator()
      Specified by:
      iterator in interface Iterable<Tuple>
    • column

      public BaseVector column(int i)
      Description copied from interface: DataFrame
      Selects column based on the column index.
      Specified by:
      column in interface DataFrame
      Parameters:
      i - the column index.
      Returns:
      the column vector.
    • vector

      public <T> Vector<T> vector(int i)
      Description copied from interface: DataFrame
      Selects column based on the column index.
      Specified by:
      vector in interface DataFrame
      Type Parameters:
      T - the data type of column.
      Parameters:
      i - the column index.
      Returns:
      the column vector.
    • booleanVector

      public BooleanVector booleanVector(int i)
      Description copied from interface: DataFrame
      Selects column based on the column index.
      Specified by:
      booleanVector in interface DataFrame
      Parameters:
      i - the column index.
      Returns:
      the column vector.
    • charVector

      public CharVector charVector(int i)
      Description copied from interface: DataFrame
      Selects column based on the column index.
      Specified by:
      charVector in interface DataFrame
      Parameters:
      i - the column index.
      Returns:
      the column vector.
    • byteVector

      public ByteVector byteVector(int i)
      Description copied from interface: DataFrame
      Selects column based on the column index.
      Specified by:
      byteVector in interface DataFrame
      Parameters:
      i - the column index.
      Returns:
      the column vector.
    • shortVector

      public ShortVector shortVector(int i)
      Description copied from interface: DataFrame
      Selects column based on the column index.
      Specified by:
      shortVector in interface DataFrame
      Parameters:
      i - the column index.
      Returns:
      the column vector.
    • intVector

      public IntVector intVector(int i)
      Description copied from interface: DataFrame
      Selects column based on the column index.
      Specified by:
      intVector in interface DataFrame
      Parameters:
      i - the column index.
      Returns:
      the column vector.
    • longVector

      public LongVector longVector(int i)
      Description copied from interface: DataFrame
      Selects column based on the column index.
      Specified by:
      longVector in interface DataFrame
      Parameters:
      i - the column index.
      Returns:
      the column vector.
    • floatVector

      public FloatVector floatVector(int i)
      Description copied from interface: DataFrame
      Selects column based on the column index.
      Specified by:
      floatVector in interface DataFrame
      Parameters:
      i - the column index.
      Returns:
      the column vector.
    • doubleVector

      public DoubleVector doubleVector(int i)
      Description copied from interface: DataFrame
      Selects column based on the column index.
      Specified by:
      doubleVector in interface DataFrame
      Parameters:
      i - the column index.
      Returns:
      the column vector.
    • stringVector

      public StringVector stringVector(int i)
      Description copied from interface: DataFrame
      Selects column based on the column index.
      Specified by:
      stringVector in interface DataFrame
      Parameters:
      i - the column index.
      Returns:
      the column vector.
    • select

      public DataFrame select(int... cols)
      Description copied from interface: DataFrame
      Returns a new DataFrame with selected columns.
      Specified by:
      select in interface DataFrame
      Parameters:
      cols - the column indices.
      Returns:
      a new DataFrame with selected columns.
    • drop

      public DataFrame drop(int... cols)
      Description copied from interface: DataFrame
      Returns a new DataFrame without selected columns.
      Specified by:
      drop in interface DataFrame
      Parameters:
      cols - the column indices.
      Returns:
      a new DataFrame without selected columns.
    • merge

      public DataFrame merge(DataFrame... dataframes)
      Description copied from interface: DataFrame
      Merges data frames horizontally by columns.
      Specified by:
      merge in interface DataFrame
      Parameters:
      dataframes - the data frames to merge.
      Returns:
      a new data frame that combines this DataFrame with one more other DataFrames by columns.
    • merge

      public DataFrame merge(BaseVector... vectors)
      Description copied from interface: DataFrame
      Merges vectors with this data frame.
      Specified by:
      merge in interface DataFrame
      Parameters:
      vectors - the vectors to merge.
      Returns:
      a new data frame that combines this DataFrame with one more additional vectors.
    • union

      public DataFrame union(DataFrame... dataframes)
      Description copied from interface: DataFrame
      Unions data frames vertically by rows.
      Specified by:
      union in interface DataFrame
      Parameters:
      dataframes - the data frames to union.
      Returns:
      a new data frame that combines all the rows.
    • get

      public Tuple get(int i)
      Description copied from interface: DataFrame
      Returns the row at the specified index.
      Specified by:
      get in interface DataFrame
      Parameters:
      i - the row index.
      Returns:
      the i-th row.