Python SDK
Dataset
SDK Reference: the normalized dataset model
A normalized, immutable view of a loaded tabular dataset. fs.load() returns a Dataset, and it is also what fs.profile(), fs.analyze(), and fs.review() accept as their primary input. The class is a frozen, slotted dataclass so every instance is read-only and safely serializable.
The Dataset type lives in featuresmith.core.dataset. It is not re-exported from the top-level featuresmith package, so import it explicitly:
from featuresmith.core.dataset import DatasetDataclass Fields
@dataclass(frozen=True, slots=True)class Dataset: dataframe: Any # pandas or Polars dataframe (memory is not copied) backend: str # "pandas" or "polars" schema: DatasetSchema # columns: tuple[ColumnSchema(name, dtype), ...] metadata: Mapping[str, object] row_count: int # default 0 column_count: int # default 0 dtypes: Mapping[str, str] # column name -> backend dtype string source: str | None # original local file path, if any (default None) file_size: int | None # source file size in bytes, if known (default None)In practice every field except dataframe, backend, and schema is computed for you during loading, so you normally construct a Dataset via fs.load() or Dataset.from_dataframe() rather than directly.
from_dataframe()
@classmethoddef from_dataframe( cls, dataframe: Any, *, backend: str, source: str | None = None, file_size: int | None = None, metadata: Mapping[str, object] | None = None,) -> Dataset:Creates a normalized dataset from a pandas or Polars dataframe, inferring the schema and dtype mapping. Used internally by the connectors; the public way to obtain a Dataset is fs.load().
preview(rows=5)
def preview(self, rows: int = 5) -> Any:Returns the first rows rows of the underlying dataframe (same backend as the source). Raises ValueError when rows is negative.
Example
import featuresmith as fsdataset = fs.load("train.parquet")print(dataset.row_count) # number of rowsprint(dataset.column_count) # number of columnsprint(dataset.backend) # "pandas" or "polars"print(dataset.source) # original file path, if loaded from disk# Inspect the normalized schema and preview rowsfor column in dataset.schema.columns: print(column.name, column.dtype)print(dataset.preview(5)) # first 5 rows as a dataframe