{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# DataFrame\n", "\n", "Many Smile algorithms take simple `double[]` as input. But we also use the encapsulation class `DataFrame`. As shown in [Data](data.ipynb) notebook, the output of most Smile data parsers is a `DataFrame` object. DataFrames are immutable and contain a fixed number of named columns." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import $ivy.`com.github.haifengl::smile-scala:3.0.2`\n", "import $ivy.`org.slf4j:slf4j-simple:2.0.7` \n", "\n", "import scala.language.postfixOps\n", "import org.apache.commons.csv.CSVFormat\n", "import java.nio.file.{Files, Paths}\n", "import smile._\n", "import smile.data._\n", "\n", "def display(df: DataFrame, limit: Int = 20, truncate: Boolean = true) = {\n", " import xml.Utility.escape\n", " val header = df.names\n", " val rows = df.toStrings(limit, truncate)\n", " kernel.publish.html(\n", " s\"\"\"\n", "
${escape(h)} | \").mkString}
---|
${escape(c)} | \" }.mkString}