Class DefaultDataFrame<V>

  • Type Parameters:
    V - the type of values
    All Implemented Interfaces:
    DataFrame<java.lang.Integer,​java.lang.String,​V>, MutableDataFrame<java.lang.Integer,​java.lang.String,​V>, java.io.Externalizable, java.io.Serializable

    public class DefaultDataFrame<V>
    extends AbstractDataFrame<java.lang.Integer,​java.lang.String,​V>
    implements MutableDataFrame<java.lang.Integer,​java.lang.String,​V>, java.io.Externalizable
    A data frame with direct integer indexing on the rows and textual indexing on the columns.
    See Also:
    Serialized Form
    • Constructor Detail

      • DefaultDataFrame

        public DefaultDataFrame()
      • DefaultDataFrame

        @Deprecated
        public DefaultDataFrame​(java.io.File file)
                         throws java.io.IOException
        Deprecated.
        Deserialize the DataFrame in optimized binary format. This works, but has never been put into production.
        Parameters:
        file -
        Throws:
        java.io.IOException
      • DefaultDataFrame

        public DefaultDataFrame​(javax.swing.table.TableModel tableModel,
                                boolean autoConvert)
      • DefaultDataFrame

        public DefaultDataFrame​(DataFrame<java.lang.Integer,​java.lang.String,​V> dataFrame,
                                boolean autoConvert)
      • DefaultDataFrame

        public DefaultDataFrame​(javax.swing.table.TableModel tableModel)
      • DefaultDataFrame

        public DefaultDataFrame​(java.lang.String[] names,
                                java.lang.Class[] classes,
                                V[][] data)
      • DefaultDataFrame

        public DefaultDataFrame​(DataFrame dataFrame)
    • Method Detail

      • freeze

        public void freeze​(java.io.File file)
                    throws java.io.IOException
        Throws:
        java.io.IOException
      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        Specified by:
        writeExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
      • readExternal

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Specified by:
        readExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • freeze

        @Deprecated
        public void freeze​(java.io.OutputStream os)
                    throws java.io.IOException
        Deprecated.
        Serialize the DataFrame in optimized binary format. This works, but has never been put into production.
        Parameters:
        os -
        Throws:
        java.io.IOException
      • getColumnIndex

        public DefaultUniqueIndex<java.lang.String> getColumnIndex()
        Description copied from interface: DataFrame
        Gets the index used to access the columns.
        Specified by:
        getColumnIndex in interface DataFrame<java.lang.Integer,​java.lang.String,​V>
        Returns:
        the column index
      • getRowIndex

        public UniqueIndex<java.lang.Integer> getRowIndex()
        Description copied from interface: DataFrame
        Gets the index used to access the rows.
        Specified by:
        getRowIndex in interface DataFrame<java.lang.Integer,​java.lang.String,​V>
        Returns:
        the row index
      • columns

        public java.lang.Iterable<java.lang.String> columns()
        Description copied from interface: DataFrame
        Returns the column keys.
        Specified by:
        columns in interface DataFrame<java.lang.Integer,​java.lang.String,​V>
        Overrides:
        columns in class AbstractDataFrame<java.lang.Integer,​java.lang.String,​V>
        Returns:
        the column keys
      • getRowClass

        public java.lang.Class getRowClass​(java.lang.Integer row)
        Description copied from interface: DataFrame
        Returns the most specific superclass for all cell values in a row.
        Specified by:
        getRowClass in interface DataFrame<java.lang.Integer,​java.lang.String,​V>
        Parameters:
        row - the key of the row
        Returns:
        the common ancestor class of the object values in the row.
      • getColumnClass

        public java.lang.Class getColumnClass​(java.lang.String column)
        Description copied from interface: DataFrame
        Returns the most specific superclass for all cell values in a column
        Specified by:
        getColumnClass in interface DataFrame<java.lang.Integer,​java.lang.String,​V>
        Parameters:
        column - the key of the column
        Returns:
        the common ancestor class of the object values in the column.
      • getRow

        public Series<java.lang.String,​?> getRow​(java.lang.Integer row)
        Description copied from interface: DataFrame
        Returns a series of all the values of a given row.
        Specified by:
        getRow in interface DataFrame<java.lang.Integer,​java.lang.String,​V>
        Parameters:
        row - the row key
        Returns:
        a Series object
      • getColumn

        public Series<java.lang.Integer,​V> getColumn​(java.lang.String column)
        Description copied from interface: DataFrame
        Returns a series of all the values of a given column.
        Specified by:
        getColumn in interface DataFrame<java.lang.Integer,​java.lang.String,​V>
        Overrides:
        getColumn in class AbstractDataFrame<java.lang.Integer,​java.lang.String,​V>
        Parameters:
        column - the row key
        Returns:
        a Series object
      • getValueAt

        public V getValueAt​(java.lang.Integer row,
                            java.lang.String column)
        Description copied from interface: DataFrame
        Returns the value for the cell at the intersection of the column key and row key.
        Specified by:
        getValueAt in interface DataFrame<java.lang.Integer,​java.lang.String,​V>
        Parameters:
        row - the row key whose value is to be queried
        column - the column key whose value is to be queried
        Returns:
        the value Object at the specified cell
      • setValueAt

        public void setValueAt​(java.lang.Integer row,
                               java.lang.String column,
                               V value)
        Description copied from interface: MutableDataFrame
        Sets the value for the cell at the intersection of the column key and row key.
        Specified by:
        setValueAt in interface MutableDataFrame<java.lang.Integer,​java.lang.String,​V>
        Parameters:
        row - the row key whose value is to be changed
        column - the column key whose value is to be changed
        value - the new value at the specified cell
      • rows

        public java.lang.Iterable<java.lang.Integer> rows()
        Description copied from interface: DataFrame
        Returns the row keys.
        Specified by:
        rows in interface DataFrame<java.lang.Integer,​java.lang.String,​V>
        Overrides:
        rows in class AbstractDataFrame<java.lang.Integer,​java.lang.String,​V>
        Returns:
        the row keys
      • getRowKey

        public java.lang.Integer getRowKey​(int index)
        Description copied from interface: DataFrame
        Returns the row key at the specified absolute index. This is the inverse of DataFrame.getRowAddress(Object).
        Specified by:
        getRowKey in interface DataFrame<java.lang.Integer,​java.lang.String,​V>
        Overrides:
        getRowKey in class AbstractDataFrame<java.lang.Integer,​java.lang.String,​V>
        Parameters:
        index - the index
        Returns:
        the row key
      • getColumnKey

        public java.lang.String getColumnKey​(int index)
        Description copied from interface: DataFrame
        Returns the column key at the specified absolute index. This is the inverse of DataFrame.getColumnAddress(Object).
        Specified by:
        getColumnKey in interface DataFrame<java.lang.Integer,​java.lang.String,​V>
        Overrides:
        getColumnKey in class AbstractDataFrame<java.lang.Integer,​java.lang.String,​V>
        Parameters:
        index - the index
        Returns:
        the column key
      • getRowAddress

        public int getRowAddress​(java.lang.Integer row)
        Description copied from interface: DataFrame
        Returns the absolute index for the specified row key. This is the inverse of DataFrame.getRowKey(int).
        Specified by:
        getRowAddress in interface DataFrame<java.lang.Integer,​java.lang.String,​V>
        Overrides:
        getRowAddress in class AbstractDataFrame<java.lang.Integer,​java.lang.String,​V>
        Parameters:
        row - the row key
        Returns:
        the absolute index of the specified key.
      • getColumnAddress

        public int getColumnAddress​(java.lang.String column)
        Description copied from interface: DataFrame
        Returns the absolute index for the specified column key. This is the inverse of DataFrame.getColumnKey(int).
        Specified by:
        getColumnAddress in interface DataFrame<java.lang.Integer,​java.lang.String,​V>
        Overrides:
        getColumnAddress in class AbstractDataFrame<java.lang.Integer,​java.lang.String,​V>
        Parameters:
        column - the column key
        Returns:
        the absolute index of the specified key.
      • getRowCount

        public int getRowCount()
        Description copied from interface: DataFrame
        Returns the number of rows contained by the this data frame.
        Specified by:
        getRowCount in interface DataFrame<java.lang.Integer,​java.lang.String,​V>
        Overrides:
        getRowCount in class AbstractDataFrame<java.lang.Integer,​java.lang.String,​V>
        Returns:
        the number of rows.
      • getColumnCount

        public int getColumnCount()
        Description copied from interface: DataFrame
        Returns the number of columns contained by this data frame.
        Specified by:
        getColumnCount in interface DataFrame<java.lang.Integer,​java.lang.String,​V>
        Overrides:
        getColumnCount in class AbstractDataFrame<java.lang.Integer,​java.lang.String,​V>
        Returns:
        the number of columns.
      • reindexRows

        public MutableDataFrame<MultiKey,​java.lang.String,​V> reindexRows​(java.lang.String... rows)
        Description copied from interface: DataFrame
        Returns a new data frame reindexed using the values coming from the specified rows.
        Specified by:
        reindexRows in interface DataFrame<java.lang.Integer,​java.lang.String,​V>
        Specified by:
        reindexRows in interface MutableDataFrame<java.lang.Integer,​java.lang.String,​V>
        Overrides:
        reindexRows in class AbstractDataFrame<java.lang.Integer,​java.lang.String,​V>
        Parameters:
        rows - the columns to use for the label values
        Returns:
        the reindexed data frame.
      • join

        public DataFrame join​(Series series,
                              java.lang.String[] columns)
        Specified by:
        join in interface DataFrame<java.lang.Integer,​java.lang.String,​V>
      • leftJoin

        public DefaultDataFrame<V> leftJoin​(DataFrame<java.lang.Object,​java.lang.String,​V> dataFrame,
                                            java.lang.String c)
      • leftJoin

        public DataFrame<java.lang.Integer,​java.lang.String,​V> leftJoin​(DataFrame<MultiKey,​java.lang.String,​V> dataFrame,
                                                                                    java.lang.String[] cs)