tisane.Unit.nominal¶
method
- Unit.nominal(name, data=None, cardinality=None, number_of_instances=1, **kwargs)¶
Creates a categorical data variable that is an attribute of a
Unit
- Parameters
name (str) – the name of the variable. If you have data, this should correspond to the column’s name.
data (DataVector, optional) – For internal use only.
cardinality (int, optional) – The number of unique values that the categorical variable can take. This should correspond to the number of “categories.” If left unspecified, Tisane will infer this from the data.
number_of_instances (int, AbstractVariable, or tisane.AtMost, default=1) – This should be the number of measurements of an attribute per unique instance of the associated
Unit
. For example, if you asked how someone felt 5 different times, the**kwargs (optional) – You can optionally specify the categories using the keyword argument
categories
. This should be a list. If left unspecified, Tisane will infer this from the data.
- Returns
The categorical data variable defined as an attribute of this
Unit
- Return type
Examples
A study asked participants how they felt 5 separate times.
>>> import tisane as ts >>> participant = ts.Unit(name="participant") >>> feelings = participant.nominal(name="feeling", ... categories=["sad", "happy", "angry", "excited"], # optional, specified here as an example ... number_of_instances=5)
The study also collected participants’ eye color.
>>> eye_color = participant.nominal(name="eye_color", categories=["blue", "brown", "green", "hazel", "gray", "black"])