Interface IDataFrame

All Superinterfaces:
Iterable<String>
All Known Implementing Classes:
DataFrame

public interface IDataFrame extends Iterable<String>
Interface defining a tabular data structure with labeled columns and rows, providing functionality similar to pandas DataFrame in Python.

The DataFrame stores data in a 2D grid with the following characteristics:

  • Columns have names and inferred/declared types
  • Rows can optionally have labels
  • Supports heterogeneous data (mixed types across columns)
  • Provides flexible data access and statistical operations
  • Method Summary

    Modifier and Type
    Method
    Description
    get(int... columnIndices)
    Gets a subset DataFrame containing only the specified columns by index.
    get(String... columnNames)
    Gets a subset DataFrame containing only the specified columns.
    getElem(Object rowSpec, Object columnSpec)
    Flexible element accessor supporting multiple retrieval patterns.
    boolean
    Checks if the DataFrame contains no data.
    int
    Gets the number of dimensions of the DataFrame.
    int[]
    Gets the dimensions of the DataFrame.
    int
    Gets the total number of data cells in the DataFrame.
    Returns an iterator over the column labels of the DataFrame.
    float
    Max(String columnName)
    Finds the maximum value in a numeric column.
    float
    Mean(String columnName)
    Calculates the arithmetic mean of a numeric column.
    float
    Min(String columnName)
    Finds the minimum value in a numeric column.
    pop(String columnName)
    Removes and returns a column from the DataFrame.
    Generates CSV representation of the DataFrame.

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Method Details

    • getEmpty

      boolean getEmpty()
      Checks if the DataFrame contains no data.
      Returns:
      true if the DataFrame has no rows or columns, false otherwise
      Throws:
      IllegalStateException - if the operation cannot be completed
    • iterator

      Iterator<String> iterator()
      Returns an iterator over the column labels of the DataFrame.
      Specified by:
      iterator in interface Iterable<String>
      Returns:
      Iterator of column names in their natural order
      Throws:
      IllegalStateException - if the DataFrame is empty
    • getSize

      int getSize()
      Gets the total number of data cells in the DataFrame.
      Returns:
      Calculated as rows × columns
      Throws:
      IllegalStateException - if the DataFrame is empty
    • getShape

      int[] getShape()
      Gets the dimensions of the DataFrame.
      Returns:
      2-element array in format [rowCount, columnCount]
      Throws:
      IllegalStateException - if the DataFrame is empty
    • getNDim

      int getNDim()
      Gets the number of dimensions of the DataFrame.
      Returns:
      Always returns 2 (rows and columns) for 2D structure
    • pop

      List<Object> pop(String columnName)
      Removes and returns a column from the DataFrame.
      Parameters:
      columnName - Name of the column to remove
      Returns:
      List containing all values from the removed column in row order
      Throws:
      IllegalStateException - if the DataFrame is empty
      IllegalArgumentException - if the column doesn't exist
    • get

      IDataFrame get(String... columnNames)
      Gets a subset DataFrame containing only the specified columns.
      Parameters:
      columnNames - Names of columns to include in the subset
      Returns:
      New DataFrame containing only the specified columns
      Throws:
      IllegalStateException - if the DataFrame is empty
      IllegalArgumentException - if any column name doesn't exist
      NullPointerException - if columnNames is null
    • get

      IDataFrame get(int... columnIndices)
      Gets a subset DataFrame containing only the specified columns by index.
      Parameters:
      columnIndices - 0-based indices of columns to include
      Returns:
      New DataFrame containing only the specified columns
      Throws:
      IllegalStateException - if the DataFrame is empty
      IndexOutOfBoundsException - if any index is invalid
      NullPointerException - if columnIndices is null
    • getElem

      Object getElem(Object rowSpec, Object columnSpec)
      Flexible element accessor supporting multiple retrieval patterns.

      Access Patterns:

      • Single Element: getElem(rowIndex, columnName)
      • Full Row: getElem(rowIndex, null) → returns Object[]
      • Full Column: getElem(null, columnName) → returns Object[]
      Parameters:
      rowSpec - Can be:
      • Integer (0-based row index)
      • String (row label if available)
      • null (all rows)
      columnSpec - Can be:
      • Integer (0-based column index)
      • String (column name)
      • null (all columns)
      Returns:
      Requested data in appropriate format
      Throws:
      IllegalStateException - if DataFrame is empty
      IllegalArgumentException - if:
      • Both specifiers are null
      • Invalid specifier types
      • Label not found
      IndexOutOfBoundsException - if numeric indices are invalid
    • Mean

      float Mean(String columnName)
      Calculates the arithmetic mean of a numeric column.
      Parameters:
      columnName - Name of the column to calculate
      Returns:
      Mean value as float
      Throws:
      IllegalStateException - if DataFrame is empty
      IllegalArgumentException - if:
      • Column doesn't exist
      • Column is not numeric (Integer/Float)
      • Column contains only null values
    • Max

      float Max(String columnName)
      Finds the maximum value in a numeric column.
      Parameters:
      columnName - Name of the column to analyze
      Returns:
      Maximum value as float
      Throws:
      IllegalStateException - if DataFrame is empty
      IllegalArgumentException - if:
      • Column doesn't exist
      • Column is not numeric (Integer/Float)
      • Column contains only null values
    • Min

      float Min(String columnName)
      Finds the minimum value in a numeric column.
      Parameters:
      columnName - Name of the column to analyze
      Returns:
      Minimum value as float
      Throws:
      IllegalStateException - if DataFrame is empty
      IllegalArgumentException - if:
      • Column doesn't exist
      • Column is not numeric (Integer/Float)
      • Column contains only null values
    • toCSV

      String toCSV()
      Generates CSV representation of the DataFrame.
      Returns:
      String containing CSV data with:
      • First line: column headers
      • Subsequent lines: data rows
      • Proper escaping of special characters
      Throws:
      IllegalStateException - if DataFrame is empty