QuantipyViews¶
-
class
quantipy.
QuantipyViews
(views=None, template=None)¶ A collection of extendable MR aggregation and statistic methods.
View methods are used to generate various numerical or categorical data aggregations. Their behaviour is controlled via
kwargs
.-
coltests
(link, name, kwargs)¶ Will test appropriate views from a Stack for stat. sig. differences.
Tests can be performed on frequency aggregations (generated by
frequency
) and means (fromsummarize
) and will compare all unique column pair combinations.Parameters: - link (Quantipy Link object.) –
- name (str) – The shortname applied to the view.
- kwargs (dict) –
- arguments (specific) (Keyword) –
- text (str, optional, default None) – Sets an optional label in the meta component of the view that is used when the view is passed into a Quantipy build (e.g. Excel, Powerpoint).
- metric ({'props', 'means'}, default 'props') – Determines whether a proportion or means test algorithm is performed.
- test_total (bool, deafult False) – If True, the each View’s y-axis column will be tested against the uncoditional total of its x-axis.
- mimic ({'Dim', 'askia'}, default 'Dim') – It is possible to mimic the test logics used in other statistical software packages by passing them as instructions. The method will then choose the appropriate test parameters.
- level ({'high', 'mid', 'low'} or float) – Sets the level of significance to which the test is carried out.
Given as str the levels correspond to
'high'
= 0.01,'mid'
= 0.05 and'low'
= 0.1. If a float is passed the specified level will be used. - flags (list of two int, default None) – Base thresholds for Dimensions-like tests, e.g. [30, 100]. First int is minimum base for reported results, second int controls small base indication.
Returns: - None – Adds requested View to the Stack, storing it under the full view name notation key.
- .. note:: – Mimicking the askia software (
mimic
='askia'
) restricts the values to be one of'high'
,'low'
,'mid'
. Any other value passed will make the algorithm fall back to'low'
. Mimicking Dimensions (mimic
='Dim'
) can use either the str or float version.
-
default
(link, name, kwargs)¶ Adds a file meta dependent aggregation to a Stack.
Checks the Link definition against the file meta and produces either a numerical or categorical summary tabulation including marginal the results.
Parameters: - link (Quantipy Link object.) –
- name (str) – The shortname applied to the view.
- kwargs (dict) –
Returns: Adds requested View to the Stack, storing it under the full view name notation key.
Return type: None
-
descriptives
(link, name, kwargs)¶ Adds num. distribution statistics of a Link defintion to the Stack.
descriptives
views can apply a range of summary statistics. Measures include statistics of centrality, dispersion and mass.Parameters: - link (Quantipy Link object.) –
- name (str) – The shortname applied to the view.
- kwargs (dict) –
- arguments (specific) (Keyword) –
- text (str, optional, default None) – Sets an optional label suffix for the meta component of the view which will be appended to the statistic name and used when the view is passed into a Quantipy build (e.g. Excel, Powerpoint).
- stats (str, default 'mean') – The measure to compute.
- exclude (list of int) – Codes that will not be considered calculating the result.
- rescale (dict) –
A mapping of {old code: new code}, e.g.:
{ 1: 0, 2: 25, 3: 50, 4: 75, 5: 100 }
- drop (bool) – If
rescale
provides a new scale defintion,drop
will remove all codes that are not transformed. Acts as a shorthand for manually passing any remaining codes inexclude
.
Returns: Adds requested View to the Stack, storing it under the full view name notation key.
Return type: None
-
frequency
(link, name, kwargs)¶ Adds count-based views on a Link defintion to the Stack object.
frequency
is able to compute several aggregates that are based on the count of code values in uni- or bivariate Links. This includes bases / samples sizes, raw or normalized cell frequencies and code summaries like simple and complex nets.Parameters: - link (Quantipy Link object.) –
- name (str) – The shortname applied to the view.
- kwargs (dict) –
- arguments (specific) (Keyword) –
- text (str, optional, default None) – Sets an optional label in the meta component of the view that is used when the view is passed into a Quantipy build (e.g. Excel, Powerpoint).
- logic (list of int, list of dicts or core.tools.view.logic operation) –
If a list is passed this instructs a simple net of the codes given as int. Multiple nets can be generated via a list of dicts that map names to lists of ints. For complex logical statements, expression are parsed to identify the qualifying rows in the data. For example:
# simple net 'logic': [1, 2, 3] # multiple nets/code groups 'logic': [{'A': [1, 2]}, {'B': [3, 4]}, {'C', [5, 6]}] # code logic 'logic': has_all([1, 2, 3])
- calc (TODO) –
- calc_only (TODO) –
Returns: - None – Adds requested View to the Stack, storing it under the full view name notation key.
- .. note:: Net codes take into account if a variable is – multi-coded. The net will therefore consider qualifying cases and not the raw sum of the frequencies per category, i.e. no multiple counting of cases.
-