Dataset#

The Dataset class is the primary data structure in Larch. It is an extension of xarray.Dataset, with additional methods and attributes specific to discrete choice modeling, collected under the dc accessor. All of the larch-specific discrete choice methods and attributes on the Dataset documented here are invoked using Dataset.dc.*.

Dataset.dc Constructors#

Dataset.dc.from_idca(df, *[, crack, ...])

Construct a Dataset from an idca-format DataFrame.

Dataset.dc.from_idce(df[, crack, altnames, ...])

Construct a Dataset from a sparse idca-format DataFrame.

Dataset.dc.from_idco(df[, alts])

Construct a Dataset from an idco-format DataFrame.

Dataset.dc Attributes#

Dataset.dc.n_cases

The number of discrete choice cases in this Dataset.

Dataset.dc.n_alts

The number of discrete choice alternatives in this Dataset.

Dataset.dc.CASEID

Str : The _caseid_ dimension of this Dataset, if defined.

Dataset.dc.ALTID

The _altid_ dimension of this Dataset, if defined.

Dataset.dc.alts_mapping

Mapping of alternative codes to names.

Dataset.dc Methods#

Dataset.dc.caseids()

Access the caseids coordinates as an index.

Dataset.dc.dissolve_zero_variance([dim, inplace])

Dissolve dimension on variables where it has no variance.

Dataset.dc.query_cases(query[, parser, engine])

Return a new dataset with each array indexed along the CASEID dimension.

Dataset.dc.set_altids(altids[, dim_name, ...])

Set the alternative ids for this Dataset.

Dataset.dc.set_altnames(altnames[, inplace])

Set the alternative names for this Dataset.

Dataset.dc.set_dtypes(dtypes[, inplace, ...])

Set the dtypes for the variables in this Dataset.

Dataset.dc.setup_flow(*args, **kwargs)

Set up a new Flow for analysis using the structure of this DataTree.

Dataset.dc.get_expr(expression)

Access or evaluate an expression.