larch.Dataset.dc.from_idce#
- static Dataset.dc.from_idce(df: DataFrame, crack: bool = True, altnames: Mapping[int, str] | Sequence[str] | None = None, dim_name: str | None = None, alt_index: str = 'alt_idx', case_index: str | None = None, case_pointer=None)#
Construct a Dataset from a sparse idca-format DataFrame.
- Parameters:
df (DataFrame) – The input data should be an idca-format or idce-format DataFrame, with the caseid’s and altid’s in a two-level pandas MultiIndex.
crack (bool, default False) – If True, the dissolve_zero_variance method is applied before repairing dtypes, to ensure that missing value are handled properly.
altnames (Mapping, optional) – If given as a mapping, links alternative codes to names. An array or list of strings gives names for the alternatives, sorted in the same order as the codes.
dim_name (str, optional) – Name to apply to the sparse index dimension.
alt_index (str, default 'alt_idx') – Add the alt index (position) for each sparse data row as a coords array with this name.
case_index (str, optional) – Add the case index (position) for each sparse data row as a coords array with this name. If not given, this array is not stored but it can still be reconstructed later from the case pointers.
case_pointer (str, optional) – Use this name for the case_ptr dimension, overriding the default.
- Returns:
Dataset
See also
Dataset.from_idca
Construct a dense Dataset from a idca-format DataFrame.