Demographics

hemlock_demographics.demographics

def hemlock_demographics.demographics(*items, page=False, require=False, record_index=False) [source]

Parameters: *items : str

Names of demographic items to return. See the full list of available items.

page : bool, default=False

Indicates that a page should be returned containing the demographics items. If False, a list of questions is returned.

require : bool, default=False

Indicates that participants are required to respond to the items.

record_index : bool, default=False

Indicates that the dataframe should record the order in which the demographic items appear on the page.

Returns: demographics : hemlock.Page or list of hemlock.Question

A page containing the requested demographics items if page, otherwise a list of demographics questions.

Examples

from hemlock import push_app_context
from hemlock_demographics import demographics

app = push_app_context()

demographics('age', 'gender', 'race', page=True).preview()

hemlock_demographics.comprehensive_demographics

def hemlock_demographics.comprehensive_demographics(**kwargs) [source]

Parameters: **kwargs :

Keyword arguments are passed to demographics.

Returns: demographics :

A comprehensive demographics questionnaire including basic demographics, family demographics, country demographics, and SES demographics.

hemlock_demographics.basic_demographics

def hemlock_demographics.basic_demographics(**kwargs) [source]

Parameters: **kwargs :

Keyword arguments are passed to demographics.

Returns: basic demographics :

Gender, age, and race.

hemlock_demographics.family_demographics

def hemlock_demographics.family_demographics(**kwargs) [source]

Parameters: **kwargs :

Keyword arguments are passed to demographics.

Returns: family demographics :

Number of household residents, number of children, living with parents or in-laws, marital status.

hemlock_demographics.country_demographics

def hemlock_demographics.country_demographics(**kwargs) [source]

Parameters: **kwargs :

Keyword arguments are passed to demographics.

Returns: country demographics :

Country of residence, origin, citizenship, and household language.

hemlock_demographics.status_demographics

def hemlock_demographics.status_demographics(**kwargs) [source]

Parameters: **kwargs :

Keyword arguments are passed to demographics.

Returns: SES demographics :

Education, employment, occupation, work sector, savings, subjective social class and income group.

hemlock_demographics.register

def hemlock_demographics.register(key=None) [source]

Register a demographics item.

Parameters: key : str or None, default=None

String key for the item. If None, the name of the function is used.

Examples

@register()
def gender(require=False):
    gender = Check(
        '<p>What is your gender?</p>',
        ['Male', 'Female', 'Other'],
        var='Gender'
    )