tisane.Unit.ordinal

method

Unit.ordinal(name, order, cardinality=None, data=None, number_of_instances=1)

Creates a categorical data variable whose categories are ordered.

Parameters
  • name (str) – the name of the variable. If you have data, this should correspond to the column’s name.

  • order (list) – a list of the categories, in the order desired

  • cardinality (int, optional) – The number of unique values that the variable can take. If left unspecified, Tisane will automatically infer this from the data, if any, or the order argument. cardinality is required if using Tisane without providing data.

  • data (DataVector, optional) – For internal use only.

  • number_of_instances (int, AbstractVariable, or AtMost, default=1) – This should be the number of measurements of an attribute per unique instance of the associated tisane.Unit. For example, if you measure the reaction time of a person 10 times, then you should enter 10.

Returns

The categorical data variable with ordered categories

Return type

Ordinal

See also

numeric

create a numeric data variable

nominal

create an (unordered) categorical variable

Examples

Representing age ranges: <18, 18-30, 31-45, 46-64, 65+

>>> person = ts.Unit("person")
>>> ageRange = person.ordinal(name="age", order=["<18", "18-30", "31-45", "46-64", "65+"])

Representing 3 different treatments of differing amounts of vitamin E:

>>> pig = ts.Unit("Pig", cardinality=72)  # 72 pigs
>>> vitamin_e = pig.ordinal("Evit",
...                         order=["Evit000", "Evit100", "Evit200"],
...                         number_of_instances=1)

Suppose you have 100 people, and you measure using a Likert scale how well they’re feeling 10 times, for each person.

>>> person = ts.Unit("person", cardinality=100) # 100 people
>>> feeling = person.ordinal("well",
...                          order=[1, 2, 3, 4, 5],
...                          number_of_instances=10)