Package-level declarations

Types

Link copied to clipboard
internal interface CellContent
Link copied to clipboard
enum class ColType : Enum<ColType>

Column types that DataFrame can parse from a String.

Link copied to clipboard
internal data class ColumnDataForJs(val column: AnyCol, val nested: List<ColumnDataForJs>, val rightAlign: Boolean, val values: List<CellContent>, val headerStyle: String?)
Link copied to clipboard
fun interface Compression<I : InputStream>

Compression algorithm to use when reading files. We support GZIP and ZIP compression out of the box.

Link copied to clipboard
class CSV(delimiter: Char = ',') : SupportedDataFrameFormat
Link copied to clipboard
enum class CSVType : Enum<CSVType>
Link copied to clipboard
internal class DataFrameFormatter(val formattedClass: String, val nullClass: String, val structuralClass: String, val numberClass: String, val dataFrameClass: String)
Link copied to clipboard
class DataFrameHtmlData(val style: String = "", val body: String = "", val script: String = "")

Container for HTML data, often containing a dataframe table.

Link copied to clipboard
internal data class DataFrameReference(val dfId: Int, val size: DataFrameSize) : CellContent
Link copied to clipboard
data class DisplayConfiguration(var rowsLimit: Int? = 20, var nestedRowsLimit: Int? = 5, var cellContentLimit: Int = 40, var cellFormatter: RowColFormatter<*, *>? = null, var headerFormatter: HeaderColFormatter<*>? = null, var decimalFormat: RendererDecimalFormat = RendererDecimalFormat.DEFAULT, var isolatedOutputs: Boolean = flagFromEnv("LETS_PLOT_HTML_ISOLATED_FRAME"), val localTesting: Boolean = flagFromEnv("KOTLIN_DATAFRAME_LOCAL_TESTING"), var useDarkColorScheme: Boolean = false, var enableFallbackStaticTables: Boolean = true, var downsizeBufferedImage: Boolean = true)

A collection of settings for rendering dataframes as HTML tables or native Kotlin Notebook table output.

Link copied to clipboard
internal data class GeneratedCode(val format: SupportedCodeGenerationFormat, val code: Code)
Link copied to clipboard
internal data class HtmlContent(val html: String, val style: String?) : CellContent
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

This strategy defines how the repeatable name column will be handled during the creation new dataframe from the IO sources.

Link copied to clipboard
internal class PreparedTable(val header: List<String>, val types: List<String>?, val values: List<List<String>>, val rowsCount: Int, val totalRows: Int)
Link copied to clipboard
internal data class ReadAnyFrame(val format: SupportedDataFrameFormat, val df: AnyFrame)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Implement this interface to provide additional DataSchema interface generation formats for DataFrames (such as OpenAPI). Note, this doesn't add functionality to DataFrame.Companion.read, just ImportDataSchema and Gradle plugin.

Link copied to clipboard

Deprecated: As a result of Issue #450 and the removal of our old Gradle/KSP plugin and DataFrame.read(), the SupportedDataFrameFormat system is deprecated and will be removed in version 1.0.

Link copied to clipboard
sealed interface SupportedFormat
Link copied to clipboard
sealed interface SupportedFormatSample
Link copied to clipboard

Properties

Link copied to clipboard
internal const val DEFAULT_PRECISION: Int = 6
Link copied to clipboard
Link copied to clipboard
internal var sessionId: Int
Link copied to clipboard

NOTE: Needs to have fully qualified name in resources/META-INF/services/org.jetbrains.kotlinx.dataframe.io.SupportedFormat to be detected here.

Link copied to clipboard
internal var tableInSessionId: Int
Link copied to clipboard
internal val tooltipLimit: Int = 1000
Link copied to clipboard
internal const val VALUE_TO_STRING_LIMIT_DEFAULT: Int = 1000
Link copied to clipboard

Functions

Link copied to clipboard
fun asFileOrNull(url: URL): File?
Link copied to clipboard
fun asURL(fileOrUrl: String): URL
Link copied to clipboard
fun asUrl(fileOrUrl: String): URL

Converts a file path or URL String to a URL. If the path is a file path, the file is checked for existence and not being a directory.

Link copied to clipboard

Opens a stream to url to create a DataFrame from it. If the URL is a file URL, the file is read directly. If the URL is an HTTP URL, it's also read directly, but if the server returns an error code, the error response is read and parsed as DataFrame too.

Link copied to clipboard
Link copied to clipboard
internal fun String.escapeHTML(): String
Link copied to clipboard
internal fun String.escapeNewLines(): String
Link copied to clipboard
internal fun BigDecimal.format(decimalFormat: RendererDecimalFormat): String
internal fun Double.format(decimalFormat: RendererDecimalFormat): String
internal fun Float.format(decimalFormat: RendererDecimalFormat): String
Link copied to clipboard
internal fun getResources(vararg resource: String): String
Link copied to clipboard
internal fun getResourceText(resource: String, vararg replacement: Pair<String, Any>): String
Link copied to clipboard
Link copied to clipboard
internal fun guessFormat(url: URL, formats: List<SupportedFormat> = supportedFormats, sample: SupportedFormatSample.DataUrl? = SupportedFormatSample.DataUrl(url)): SupportedFormat?
internal fun guessFormat(path: Path, formats: List<SupportedFormat> = supportedFormats, sample: SupportedFormatSample.DataPath? = SupportedFormatSample.DataPath(path)): SupportedFormat?
internal fun guessFormat(path: String, formats: List<SupportedFormat> = supportedFormats, sample: SupportedFormatSample.PathString? = SupportedFormatSample.PathString(path)): SupportedFormat?
Link copied to clipboard
internal fun guessFormatForExtension(ext: String, formats: List<SupportedFormat> = supportedFormats, sample: SupportedFormatSample? = null): SupportedFormat?
Link copied to clipboard
internal fun isCompressed(file: File): Boolean
internal fun isCompressed(url: URL): Boolean
internal fun isCompressed(fileOrUrl: String): Boolean
Link copied to clipboard
fun isFile(url: URL): Boolean
Link copied to clipboard
Link copied to clipboard
fun isURL(path: String): Boolean
Link copied to clipboard
fun isUrl(path: String): Boolean
Link copied to clipboard
internal fun AnyFrame.maxDepth(startingAt: Int = 0): Int

Returns the depth of the most-nested column in this df/group, starting at 0

Link copied to clipboard
internal fun BaseColumn<*>.maxWidth(): Int

Returns the max number of columns needed to display this column flattened

Link copied to clipboard
internal fun nextTableId(): Int
Link copied to clipboard
internal fun AnyFrame.prepareTable(rowsLimit: Int?, valueLimit: Int?, columnTypes: Boolean, rowIndex: Boolean, escapeValue: (String) -> String = { it }): PreparedTable
Link copied to clipboard
internal fun DataFrameHtmlData.print()
Link copied to clipboard
fun DataFrame.Companion.read(file: File, header: List<String> = emptyList()): AnyFrame
fun DataFrame.Companion.read(url: URL, header: List<String> = emptyList()): AnyFrame
fun DataFrame.Companion.read(path: Path, header: List<String> = emptyList()): AnyFrame
fun DataFrame.Companion.read(path: String, header: List<String> = emptyList()): AnyFrame
fun DataRow.Companion.read(file: File, header: List<String> = emptyList()): AnyRow
fun DataRow.Companion.read(url: URL, header: List<String> = emptyList()): AnyRow
fun DataRow.Companion.read(path: Path, header: List<String> = emptyList()): AnyRow
fun DataRow.Companion.read(path: String, header: List<String> = emptyList()): AnyRow
internal fun DataFrame.Companion.read(stream: InputStream, format: SupportedDataFrameFormat? = null, header: List<String> = emptyList(), formats: List<SupportedDataFrameFormat> = supportedFormats.filterIsInstance<SupportedDataFrameFormat>()): ReadAnyFrame
internal fun DataFrame.Companion.read(path: Path, format: SupportedDataFrameFormat? = null, header: List<String> = emptyList(), formats: List<SupportedDataFrameFormat> = supportedFormats.filterIsInstance<SupportedDataFrameFormat>()): ReadAnyFrame
fun DataFrame.Companion.read(fileOrUrl: String, delimiter: Char, header: List<String> = listOf(), colTypes: Map<String, ColType> = mapOf(), skipLines: Int = 0, readLines: Int? = null, duplicate: Boolean = true, charset: Charset = Charsets.UTF_8): DataFrame<*>
Link copied to clipboard
internal fun readCodeForGeneration(stream: InputStream, name: String, format: SupportedCodeGenerationFormat? = null, generateHelperCompanionObject: Boolean = false, formats: List<SupportedCodeGenerationFormat> = supportedFormats.filterIsInstance<SupportedCodeGenerationFormat>()): GeneratedCode
Link copied to clipboard
fun DataFrame.Companion.readCSV(file: File, delimiter: Char = ',', header: List<String> = listOf(), colTypes: Map<String, ColType> = mapOf(), skipLines: Int = 0, readLines: Int? = null, duplicate: Boolean = true, charset: Charset = Charsets.UTF_8, parserOptions: ParserOptions? = null): DataFrame<*>
fun DataFrame.Companion.readCSV(url: URL, delimiter: Char = ',', header: List<String> = listOf(), colTypes: Map<String, ColType> = mapOf(), skipLines: Int = 0, readLines: Int? = null, duplicate: Boolean = true, charset: Charset = Charsets.UTF_8, parserOptions: ParserOptions? = null): DataFrame<*>
fun DataFrame.Companion.readCSV(fileOrUrl: String, delimiter: Char = ',', header: List<String> = listOf(), colTypes: Map<String, ColType> = mapOf(), skipLines: Int = 0, readLines: Int? = null, duplicate: Boolean = true, charset: Charset = Charsets.UTF_8, parserOptions: ParserOptions? = null): DataFrame<*>
fun DataFrame.Companion.readCSV(stream: InputStream, delimiter: Char = ',', header: List<String> = listOf(), isCompressed: Boolean = false, colTypes: Map<String, ColType> = mapOf(), skipLines: Int = 0, readLines: Int? = null, duplicate: Boolean = true, charset: Charset = Charsets.UTF_8, parserOptions: ParserOptions? = null): DataFrame<*>
Link copied to clipboard
fun File.readDataFrame(header: List<String> = emptyList()): AnyFrame
fun URL.readDataFrame(header: List<String> = emptyList()): AnyFrame
fun Path.readDataFrame(header: List<String> = emptyList()): AnyFrame
Link copied to clipboard
fun File.readDataRow(header: List<String> = emptyList()): AnyRow
fun URL.readDataRow(header: List<String> = emptyList()): AnyRow
fun Path.readDataRow(header: List<String> = emptyList()): AnyRow
Link copied to clipboard
fun DataFrame.Companion.readDelim(reader: Reader, format: CSVFormat = CSVFormat.DEFAULT.builder() .setHeader() .build(), colTypes: Map<String, ColType> = mapOf(), skipLines: Int = 0, readLines: Int? = null, parserOptions: ParserOptions? = null): AnyFrame
fun DataFrame.Companion.readDelim(inStream: InputStream, delimiter: Char = ',', header: List<String> = listOf(), isCompressed: Boolean = false, csvType: CSVType, colTypes: Map<String, ColType> = mapOf(), skipLines: Int = 0, readLines: Int? = null, duplicate: Boolean = true, charset: Charset = defaultCharset, parserOptions: ParserOptions? = null): AnyFrame
Link copied to clipboard
fun DataFrame.Companion.readTSV(file: File, header: List<String> = listOf(), colTypes: Map<String, ColType> = mapOf(), skipLines: Int = 0, readLines: Int? = null, duplicate: Boolean = true, charset: Charset = Charsets.UTF_8): DataFrame<*>
fun DataFrame.Companion.readTSV(url: URL, header: List<String> = listOf(), colTypes: Map<String, ColType> = mapOf(), skipLines: Int = 0, readLines: Int? = null, duplicate: Boolean = true, charset: Charset = Charsets.UTF_8, parserOptions: ParserOptions? = null): DataFrame<*>
fun DataFrame.Companion.readTSV(fileOrUrl: String, header: List<String> = listOf(), colTypes: Map<String, ColType> = mapOf(), skipLines: Int = 0, readLines: Int? = null, duplicate: Boolean = true, charset: Charset = Charsets.UTF_8, parserOptions: ParserOptions? = null): DataFrame<*>
fun DataFrame.Companion.readTSV(stream: InputStream, header: List<String> = listOf(), isCompressed: Boolean = false, colTypes: Map<String, ColType> = mapOf(), skipLines: Int = 0, readLines: Int? = null, duplicate: Boolean = true, charset: Charset = Charsets.UTF_8, parserOptions: ParserOptions? = null): DataFrame<*>
Link copied to clipboard
internal fun renderCollectionName(value: Collection<*>): String?
Link copied to clipboard
Link copied to clipboard
fun AnyFrame.renderToMarkdown(rowsLimit: Int? = 20, valueLimit: Int? = 40, alignment: MarkdownAlignment = MarkdownAlignment.UNSPECIFIED, columnTypes: Boolean = false, title: Boolean = false, rowIndex: Boolean = true): String
Link copied to clipboard
internal fun AnyRow.renderToString(decimalFormat: RendererDecimalFormat = RendererDecimalFormat.DEFAULT): String
fun AnyFrame.renderToString(rowsLimit: Int? = 20, valueLimit: Int? = 40, borders: Boolean = false, alignLeft: Boolean = false, columnTypes: Boolean = true, title: Boolean = false, rowIndex: Boolean = true, borderStyle: StringBorderStyle = StringBorderStyle.DottedLineWithRounderCorners): String
Link copied to clipboard
internal fun AnyRow.renderToStringTable(forHtml: Boolean = false): String
Link copied to clipboard
internal fun renderValueForHtml(value: Any?, truncate: Int, format: RendererDecimalFormat): RenderedContent
Link copied to clipboard
internal fun renderValueForRowTable(value: Any?, forHtml: Boolean): RenderedContent
Link copied to clipboard
internal fun renderValueForStdout(value: Any?, limit: Int = VALUE_TO_STRING_LIMIT_DEFAULT, decimalFormat: RendererDecimalFormat = RendererDecimalFormat.DEFAULT): RenderedContent
Link copied to clipboard
internal fun renderValueToString(value: Any?, decimalFormat: RendererDecimalFormat): String
Link copied to clipboard

Skips BOM characters if present.

Link copied to clipboard
internal fun tableJs(columns: List<ColumnDataForJs>, id: Int, rootId: Int, nrow: Int): String
Link copied to clipboard
Link copied to clipboard
fun AnyFrame.toCsv(format: CSVFormat = CSVFormat.DEFAULT): String
Link copied to clipboard
fun <T> List<List<T>>.toDataFrame(containsColumns: Boolean = false): AnyFrame
Link copied to clipboard
fun <T> DataFrame<T>.toHTML(configuration: DisplayConfiguration = DisplayConfiguration.DEFAULT, cellRenderer: CellRenderer = DefaultCellRenderer, getFooter: (DataFrame<T>) -> String? = { "DataFrame [${it.size}]" }): DataFrameHtmlData
Link copied to clipboard
fun <T> DataFrame<T>.toHtml(configuration: DisplayConfiguration = DisplayConfiguration.DEFAULT, cellRenderer: CellRenderer = DefaultCellRenderer, getFooter: (DataFrame<T>) -> String? = { "DataFrame [${it.size}]" }): DataFrameHtmlData

Returns a DataFrameHtmlData without additional definitions. Can be rendered in Jupyter kernel (Kotlin Notebook) environments or other environments that already have CSS- and script definitions for DataFrame.

Link copied to clipboard
internal fun AnyFrame.toHtmlData(defaultConfiguration: DisplayConfiguration = DisplayConfiguration.DEFAULT, cellRenderer: CellRenderer): DataFrameHtmlData
Link copied to clipboard
Link copied to clipboard
fun <T> DataFrame<T>.toStandaloneHTML(configuration: DisplayConfiguration = DisplayConfiguration.DEFAULT, cellRenderer: CellRenderer = DefaultCellRenderer, getFooter: (DataFrame<T>) -> String? = { "DataFrame [${it.size}]" }): DataFrameHtmlData
Link copied to clipboard
fun <T> DataFrame<T>.toStandaloneHtml(configuration: DisplayConfiguration = DisplayConfiguration.DEFAULT, cellRenderer: CellRenderer = DefaultCellRenderer, getFooter: (DataFrame<T>) -> String? = { "DataFrame [${it.size}]" }): DataFrameHtmlData

Returns a DataFrameHtmlData with CSS- and script definitions for DataFrame.

Link copied to clipboard
fun AnyFrame.toStaticHtml(configuration: DisplayConfiguration = DisplayConfiguration.DEFAULT, cellRenderer: CellRenderer = DefaultCellRenderer, includeCss: Boolean = true, openNestedDfs: Boolean = false): DataFrameHtmlData

Renders this DataFrame as static HTML (meaning no JS is used). CSS rendering is enabled by default but can be turned off using includeCss

Link copied to clipboard
Link copied to clipboard
fun urlAsFile(url: URL): File
Link copied to clipboard
inline fun <T, I : InputStream> InputStream.useDecompressed(compression: Compression<I>, block: (InputStream) -> T): T

Decompresses the input stream with the given compression algorithm.

Link copied to clipboard
fun AnyFrame.writeCSV(file: File, format: CSVFormat = CSVFormat.DEFAULT)
fun AnyFrame.writeCSV(writer: Appendable, format: CSVFormat = CSVFormat.DEFAULT)
fun AnyFrame.writeCSV(path: String, format: CSVFormat = CSVFormat.DEFAULT)