jaxlogit.utils.wide_to_long#

jaxlogit.utils.wide_to_long(dataframe, id_col, alt_list, alt_name, varying=None, sep='_', alt_is_prefix=False, empty_val=nan, panels=False)#

Reshapes pandas DataFrame from wide to long format.

Parameters#

dataframepandas DataFrame

The wide-format DataFrame.

id_colstr

Column that uniquely identifies each sample.

alt_listlist-like

List of choice alternatives.

alt_namestr

Name of the alternatives column in returned dataset.

varyinglist-like

List of column names that vary across alternatives.

sepstr, default=’_’

Separator of column names that vary across alternatives.

avail: array-like, shape (n_samples,), default=None

Availability of alternatives for the choice situations. One when available or zero otherwise.

alt_is_prefixbool

True if alternative is prefix of the variable name or False if it is suffix.

empty_valint, float or str, default=np.nan

Value to fill when alternative not available for a certain variable.

panelsbool

Whether there is panel data that needs to be taken into consideration

Returns#

DataFrame in long format.