SurveyVariable#
- class tangles.convenience.SurveyVariable(name: str, var_type: str = 'unknown', label: str | None = None, valid_values: dict | None = None, invalid_values: dict | None = None, is_usable: bool = False)#
A variable (column) of a
Survey
.Parameters#
- namestr
The name of the variable.
- var_typestr
The type of the variable.
- labelstr
The label of the variable (often the question text or some brief version of it).
- valid_valuesdict
A dictionary containing the possible ‘raw’ valid values as keys and (possibly meaningful) labels as values.
- invalid_valuesdict
A dictionary containing the possible ‘raw’ invalid values as keys and (possibly meaningful) labels as values.
- is_usablebool
A flag that is True, if we are sure that we can automatically create nice features for this question.
Methods
Add valid_values and invalid_values to this survey variable’s valid and invalid values, respectively
Return all (raw) values as a list
Create a
SurveyVariableValues
object for this variableReturn the (raw) invalid values as a list
Check if this variable is nominal
Check if this variable is numeric
Check if this variable is ordinal
Check the validity of this variable’s type string
A static function that checks if a string is a valid variable typename
Replace values by other values
Replace value labels by other labels, if the corresponding values are in the mapping
Set this survey variable’s valid and invalid values
Return the information contained in this object as a row
Return the (raw) valid values as a list
Return the
SurveyVariableValues
subclass that this variable is an instance of