2 Reference
This section defines the loaders and conversion procedures. For worked examples, see the Guide. Contracts use the notation described in The Racket Reference.
2.1 Dataset loaders
| (require datasets) | package: datasets |
All bindings from datasets/core are re-exported. Their definitions are in Datasets Core.
procedure
(load-dataset name [ #:format format #:columns columns]) → any/c name : symbol? format : (or/c 'polars 'table 'matrix 'data-frame) = 'polars columns : (or/c #f (listof string?)) = #f
When columns is #f, all columns are selected in source order. Otherwise it must be a nonempty list of distinct known column names. Selection preserves the requested order and all source rows, and takes place before conversion. An unknown dataset, format, or column, an empty selection, or a duplicate column raises exn:fail:contract.
Each dataframe load allocates independent storage. Mutating a returned dataframe cannot change later loads or the bundled observations. Table values are immutable. Matrix conversion raises an error for any selected nonnumeric or missing value; see Matrix conversion.
2.1.1 Named loaders
procedure
(load-mtcars [ #:format format #:columns columns]) → any/c format : symbol? = 'polars columns : (or/c #f (listof string?)) = #f
procedure
(load-iris [ #:format format #:columns columns]) → any/c format : symbol? = 'polars columns : (or/c #f (listof string?)) = #f
procedure
(load-faithful [ #:format format #:columns columns]) → any/c format : symbol? = 'polars columns : (or/c #f (listof string?)) = #f
procedure
(load-anscombe [ #:format format #:columns columns]) → any/c format : symbol? = 'polars columns : (or/c #f (listof string?)) = #f
procedure
(load-airquality [ #:format format #:columns columns]) → any/c format : symbol? = 'polars columns : (or/c #f (listof string?)) = #f
procedure
(load-us-arrests [ #:format format #:columns columns]) → any/c format : symbol? = 'polars columns : (or/c #f (listof string?)) = #f
procedure
(load-plant-growth [ #:format format #:columns columns]) → any/c format : symbol? = 'polars columns : (or/c #f (listof string?)) = #f
procedure
(load-tooth-growth [ #:format format #:columns columns]) → any/c format : symbol? = 'polars columns : (or/c #f (listof string?)) = #f
procedure
(load-titanic [ #:format format #:columns columns]) → any/c format : symbol? = 'polars columns : (or/c #f (listof string?)) = #f
procedure
(load-air-passengers [ #:format format #:columns columns]) → any/c format : symbol? = 'polars columns : (or/c #f (listof string?)) = #f
procedure
(load-diabetes [ #:format format #:columns columns]) → any/c format : symbol? = 'polars columns : (or/c #f (listof string?)) = #f
procedure
(load-breast-cancer [ #:format format #:columns columns]) → any/c format : symbol? = 'polars columns : (or/c #f (listof string?)) = #f
procedure
(load-wine [ #:format format #:columns columns]) → any/c format : symbol? = 'polars columns : (or/c #f (listof string?)) = #f
2.2 Value representations
Value |
| Table |
| Polars |
| Matrix |
| data-frame |
Integer |
| Exact integer |
| Int64, or Float64 in a mixed numeric column |
| Number |
| Number |
Real |
| Inexact real |
| Float64 |
| Number |
| Number |
Category / identifier |
| String |
| String |
| Error |
| String |
Missing |
| dataset-missing |
| polars-null |
| Error |
| Explicit series NA |
Category levels and their order remain in the source metadata; the Polars adapter creates string columns rather than categorical or enum columns. No adapter encodes labels, imputes missing observations, or drops selected columns. The data-frame adapter records initial column order in a property because its underlying library does not define an iteration order for column names.
2.3 Polars conversion
| (require datasets/polars) | package: datasets |
procedure
(table->polars table) → any/c
table : dataset-table?
2.4 Matrix conversion
| (require datasets/matrix) | package: datasets |
procedure
(table->matrix table) → any/c
table : dataset-table?
2.5 Data-frame conversion
| (require datasets/data-frame) | package: datasets |
procedure
(table->data-frame table) → any/c
table : dataset-table?
procedure
(data-frame-column-names frame) → (listof string?)
frame : any/c
This is a snapshot of the selection at construction time. Callers that add, remove, or rename columns must update the property themselves if they continue to use it. The underlying df-series-names procedure has unspecified order.