diff --git a/.gitignore b/.gitignore index 8d826cfc6..e14a58638 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /tests/StackName.stack /tests/ChainName.chain /tests/ClusterName.cluster +dist/ .coverage htmlcov/ @@ -23,12 +24,13 @@ temp.chain tests/Example Data (A).cache *.css *.ttf +*.js *.eot *.svg *.woff + *.js -docs/API/_build/ docs/API/_static/ docs/API/_templates/ @@ -36,5 +38,5 @@ docs/API/_templates/ *.egg .eggs/ .cache - -build \ No newline at end of file +.pytest_cache/* +build diff --git a/.pytest_cache/README.md b/.pytest_cache/README.md new file mode 100644 index 000000000..bb78ba07e --- /dev/null +++ b/.pytest_cache/README.md @@ -0,0 +1,8 @@ +# pytest cache directory # + +This directory contains data from the pytest's cache plugin, +which provides the `--lf` and `--ff` options, as well as the `cache` fixture. + +**Do not** commit this to version control. + +See [the docs](https://docs.pytest.org/en/latest/cache.html) for more information. diff --git a/.pytest_cache/v/cache/nodeids b/.pytest_cache/v/cache/nodeids new file mode 100644 index 000000000..203477c9a --- /dev/null +++ b/.pytest_cache/v/cache/nodeids @@ -0,0 +1,278 @@ +[ + "tests/test_banked_chains.py::TestBankedChains::test_banked_chain_structure_unweighted", + "tests/test_banked_chains.py::TestBankedChains::test_banked_chain_structure_weighted", + "tests/test_banked_chains.py::TestBankedChains::test_cluster_add_chain", + "tests/test_banked_chains.py::TestBankedChains::test_verify_banked_chain", + "tests/test_batch.py::TestBatch::test_add_crossbreak", + "tests/test_batch.py::TestBatch::test_add_downbreak", + "tests/test_batch.py::TestBatch::test_add_filter", + "tests/test_batch.py::TestBatch::test_add_open_ends", + "tests/test_batch.py::TestBatch::test_add_y_on_y", + "tests/test_batch.py::TestBatch::test_as_addition", + "tests/test_batch.py::TestBatch::test_copy", + "tests/test_batch.py::TestBatch::test_dataset_add_batch", + "tests/test_batch.py::TestBatch::test_dataset_get_batch", + "tests/test_batch.py::TestBatch::test_extend_filter", + "tests/test_batch.py::TestBatch::test_extend_y", + "tests/test_batch.py::TestBatch::test_from_batch", + "tests/test_batch.py::TestBatch::test_hiding", + "tests/test_batch.py::TestBatch::test_level", + "tests/test_batch.py::TestBatch::test_replace_y", + "tests/test_batch.py::TestBatch::test_set_cell_items", + "tests/test_batch.py::TestBatch::test_set_language", + "tests/test_batch.py::TestBatch::test_set_sigtest", + "tests/test_batch.py::TestBatch::test_set_weight", + "tests/test_batch.py::TestBatch::test_slicing", + "tests/test_batch.py::TestBatch::test_sorting", + "tests/test_batch.py::TestBatch::test_transpose", + "tests/test_chain.py::TestChainConstructor::()::test_init", + "tests/test_chain.py::TestChainConstructor::()::test_str", + "tests/test_chain.py::TestChainConstructor::()::test_repr", + "tests/test_chain.py::TestChainConstructor::()::test_len", + "tests/test_chain.py::TestChainExceptions::()::test_get_non_existent_columns", + "tests/test_chain.py::TestChainGet::()::test_get_x_orientation[params_getx0]", + "tests/test_chain.py::TestChainGet::()::test_get_x_orientation[params_getx1]", + "tests/test_chain.py::TestChainGet::()::test_get_x_orientation[params_getx2]", + "tests/test_chain.py::TestChainGet::()::test_get_x_orientation[params_getx3]", + "tests/test_chain.py::TestChainGet::()::test_sig_transformation_simple", + "tests/test_chain.py::TestChainGet::()::test_annotations_fields", + "tests/test_chain.py::TestChainGet::()::test_annotations_populated", + "tests/test_chain.py::TestChainGet::()::test_annotations_list_append", + "tests/test_chain.py::TestChainGet::()::test_sig_transformation_large", + "tests/test_chain.py::TestChainUnnamedAdd::()::test_unnamed", + "tests/test_chain.py::TestChainAdd::()::test_named", + "tests/test_chain.py::TestChainAdd::()::test_str[params_structure0]", + "tests/test_chain.py::TestChainAdd::()::test_str[params_structure1]", + "tests/test_chain.py::TestChainAddRepaint::()::test_str[params_structure0]", + "tests/test_chain.py::TestChainAddRepaint::()::test_str[params_structure1]", + "tests/test_chain_old.py::TestChainObject::test_auto_orientation", + "tests/test_chain_old.py::TestChainObject::test_dervie_attributes", + "tests/test_chain_old.py::TestChainObject::test_describe", + "tests/test_chain_old.py::TestChainObject::test_lazy_name", + "tests/test_chain_old.py::TestChainObject::test_save_chain", + "tests/test_cluster.py::TestClusterObject::test_add_chain", + "tests/test_cluster.py::TestClusterObject::test_add_chain_exceptions", + "tests/test_cluster.py::TestClusterObject::test_add_dataframe", + "tests/test_cluster.py::TestClusterObject::test_add_multiple_chains", + "tests/test_cluster.py::TestClusterObject::test_add_multiple_chains_exceptions", + "tests/test_cluster.py::TestClusterObject::test_dataframe_exceptions", + "tests/test_cluster.py::TestClusterObject::test_save_cluster", + "tests/test_complex_logic.py::TestStackObject::test___eq", + "tests/test_complex_logic.py::TestStackObject::test___ge", + "tests/test_complex_logic.py::TestStackObject::test___gt", + "tests/test_complex_logic.py::TestStackObject::test___le", + "tests/test_complex_logic.py::TestStackObject::test___lt", + "tests/test_complex_logic.py::TestStackObject::test___ne", + "tests/test_complex_logic.py::TestStackObject::test__has_not_all", + "tests/test_complex_logic.py::TestStackObject::test__has_not_all_errors", + "tests/test_complex_logic.py::TestStackObject::test__has_not_any", + "tests/test_complex_logic.py::TestStackObject::test__has_not_any_errors", + "tests/test_complex_logic.py::TestStackObject::test__has_not_count", + "tests/test_complex_logic.py::TestStackObject::test__has_not_count_errors", + "tests/test_complex_logic.py::TestStackObject::test_difference", + "tests/test_complex_logic.py::TestStackObject::test_get_logic_key", + "tests/test_complex_logic.py::TestStackObject::test_get_logic_key_chunk", + "tests/test_complex_logic.py::TestStackObject::test_has_all", + "tests/test_complex_logic.py::TestStackObject::test_has_all_errors", + "tests/test_complex_logic.py::TestStackObject::test_has_not_any", + "tests/test_complex_logic.py::TestStackObject::test_has_not_any_errors", + "tests/test_complex_logic.py::TestStackObject::test_has_not_count", + "tests/test_complex_logic.py::TestStackObject::test_has_not_count_errors", + "tests/test_complex_logic.py::TestStackObject::test_intersection", + "tests/test_complex_logic.py::TestStackObject::test_is_eq", + "tests/test_complex_logic.py::TestStackObject::test_is_ge", + "tests/test_complex_logic.py::TestStackObject::test_is_gt", + "tests/test_complex_logic.py::TestStackObject::test_is_le", + "tests/test_complex_logic.py::TestStackObject::test_is_lt", + "tests/test_complex_logic.py::TestStackObject::test_is_ne", + "tests/test_complex_logic.py::TestStackObject::test_logic_list", + "tests/test_complex_logic.py::TestStackObject::test_nested_logic", + "tests/test_complex_logic.py::TestStackObject::test_nested_logic_list", + "tests/test_complex_logic.py::TestStackObject::test_symmetric_difference", + "tests/test_complex_logic.py::TestStackObject::test_union", + "tests/test_complex_logic.py::TestStackObject::test_wildcards", + "tests/test_dataset.py::TestDataSet::test_array_metadata", + "tests/test_dataset.py::TestDataSet::test_categorical_metadata_additions", + "tests/test_dataset.py::TestDataSet::test_categorical_to_delimited_set", + "tests/test_dataset.py::TestDataSet::test_compare", + "tests/test_dataset.py::TestDataSet::test_copy_via_masks_full", + "tests/test_dataset.py::TestDataSet::test_copy_via_masks_sliced_and_reduced", + "tests/test_dataset.py::TestDataSet::test_crosstab", + "tests/test_dataset.py::TestDataSet::test_derotate_df", + "tests/test_dataset.py::TestDataSet::test_derotate_freq", + "tests/test_dataset.py::TestDataSet::test_derotate_meta", + "tests/test_dataset.py::TestDataSet::test_dichotomous_to_delimited_set", + "tests/test_dataset.py::TestDataSet::test_extend_values_autocodes", + "tests/test_dataset.py::TestDataSet::test_extend_values_no_texts", + "tests/test_dataset.py::TestDataSet::test_extend_values_raises_on_dupes", + "tests/test_dataset.py::TestDataSet::test_extend_values_usercodes", + "tests/test_dataset.py::TestDataSet::test_fileinfo", + "tests/test_dataset.py::TestDataSet::test_filter", + "tests/test_dataset.py::TestDataSet::test_force_texts", + "tests/test_dataset.py::TestDataSet::test_get_item_texts", + "tests/test_dataset.py::TestDataSet::test_get_value_texts", + "tests/test_dataset.py::TestDataSet::test_get_variable_text", + "tests/test_dataset.py::TestDataSet::test_interlock", + "tests/test_dataset.py::TestDataSet::test_order_full_change", + "tests/test_dataset.py::TestDataSet::test_order_repos_change", + "tests/test_dataset.py::TestDataSet::test_read_quantipy", + "tests/test_dataset.py::TestDataSet::test_remove_values", + "tests/test_dataset.py::TestDataSet::test_rename_via_masks", + "tests/test_dataset.py::TestDataSet::test_reorder_values", + "tests/test_dataset.py::TestDataSet::test_reorder_values_raises_on_incomplete_list", + "tests/test_dataset.py::TestDataSet::test_set_item_texts", + "tests/test_dataset.py::TestDataSet::test_set_missings_flagging", + "tests/test_dataset.py::TestDataSet::test_set_missings_results", + "tests/test_dataset.py::TestDataSet::test_set_value_texts", + "tests/test_dataset.py::TestDataSet::test_set_variable_text", + "tests/test_dataset.py::TestDataSet::test_sorting_rules_meta", + "tests/test_dataset.py::TestDataSet::test_subset_from_varlist", + "tests/test_dataset.py::TestDataSet::test_text_replacements_non_array", + "tests/test_dataset.py::TestDataSet::test_transpose", + "tests/test_dataset.py::TestDataSet::test_uncode", + "tests/test_dataset.py::TestDataSet::test_validate", + "tests/test_excel.py::TestExcel::()::test_structure[params0]", + "tests/test_excel.py::TestExcel::()::test_structure[params1]", + "tests/test_excel.py::TestExcel::()::test_structure[params2]", + "tests/test_excel.py::TestExcel::()::test_structure[params3]", + "tests/test_excel.py::TestExcel::()::test_structure[params4]", + "tests/test_io_dimensions.py::TestDimLabels::test_dimlabels", + "tests/test_link.py::TestLinkObject::test_get_data", + "tests/test_link.py::TestLinkObject::test_get_meta", + "tests/test_link.py::TestLinkObject::test_link_behaves_like_a_dict", + "tests/test_link.py::TestLinkObject::test_link_is_a_subclassed_dict", + "tests/test_logic_views.py::TestViewObject::test_simple_or", + "tests/test_merging.py::TestMerging::test_hmerge_basic", + "tests/test_merging.py::TestMerging::test_hmerge_vmerge_basic", + "tests/test_merging.py::TestMerging::test_subset_dataset", + "tests/test_merging.py::TestMerging::test_vmerge_basic", + "tests/test_merging.py::TestMerging::test_vmerge_blind_append", + "tests/test_merging.py::TestMerging::test_vmerge_blind_append_row_id", + "tests/test_merging.py::TestMerging::test_vmerge_row_id", + "tests/test_recode.py::TestRecodes::test_recode_parameters", + "tests/test_rim.py::TestScheme::test_cap", + "tests/test_rim.py::TestScheme::test_constructor", + "tests/test_rim.py::TestScheme::test_groups", + "tests/test_rules.py::TestRules::test_dropx", + "tests/test_rules.py::TestRules::test_rules_coltests", + "tests/test_rules.py::TestRules::test_rules_coltests_flag_bases", + "tests/test_rules.py::TestRules::test_rules_crosstab", + "tests/test_rules.py::TestRules::test_rules_frequency", + "tests/test_rules.py::TestRules::test_rules_get_chain", + "tests/test_rules.py::TestRules::test_rules_get_dataframe", + "tests/test_rules.py::TestRules::test_slicex", + "tests/test_rules.py::TestRules::test_sortx", + "tests/test_rules.py::TestRules::test_sortx_expand_net_between", + "tests/test_rules.py::TestRules::test_sortx_expand_net_within", + "tests/test_rules.py::TestRules::test_sortx_expand_net_within_between", + "tests/test_rules.py::TestRules::test_sortx_summaries_items", + "tests/test_rules.py::TestRules::test_sortx_summaries_mean", + "tests/test_rules.py::TestRules::test_sortx_summaries_value", + "tests/test_stack.py::TestStackObject::test_add_data", + "tests/test_stack.py::TestStackObject::test_add_data_as_arg", + "tests/test_stack.py::TestStackObject::test_add_link_exceptions", + "tests/test_stack.py::TestStackObject::test_add_link_generates_links_and_views", + "tests/test_stack.py::TestStackObject::test_add_link_lazy", + "tests/test_stack.py::TestStackObject::test_add_link_x_y_equal", + "tests/test_stack.py::TestStackObject::test_add_nets", + "tests/test_stack.py::TestStackObject::test_add_stats", + "tests/test_stack.py::TestStackObject::test_cache_is_created", + "tests/test_stack.py::TestStackObject::test_cumulative_sum", + "tests/test_stack.py::TestStackObject::test_describe", + "tests/test_stack.py::TestStackObject::test_factor_labels", + "tests/test_stack.py::TestStackObject::test_filters", + "tests/test_stack.py::TestStackObject::test_get_chain_generates_chains", + "tests/test_stack.py::TestStackObject::test_get_chain_lazy", + "tests/test_stack.py::TestStackObject::test_get_chain_orient_on_gives_correct_orientation", + "tests/test_stack.py::TestStackObject::test_get_chain_preserves_link_orientation", + "tests/test_stack.py::TestStackObject::test_getting_1D_views", + "tests/test_stack.py::TestStackObject::test_recode_from_net_def", + "tests/test_stack.py::TestStackObject::test_recode_from_stat_def", + "tests/test_stack.py::TestStackObject::test_reduce", + "tests/test_stack.py::TestStackObject::test_refresh", + "tests/test_stack.py::TestStackObject::test_refresh_remove_weight", + "tests/test_stack.py::TestStackObject::test_save_and_load_stack", + "tests/test_stack.py::TestStackObject::test_save_and_load_stack_path_expectations", + "tests/test_stack.py::TestStackObject::test_save_and_load_with_and_without_cache", + "tests/test_stack.py::TestStackObject::test_save_dataset", + "tests/test_stack.py::TestStackObject::test_save_describe", + "tests/test_stack.py::TestStackObject::test_save_load_stack_improved", + "tests/test_stack.py::TestStackObject::test_stack_aggregate", + "tests/test_stack.py::TestStackObject::test_stack_behaves_like_a_dict", + "tests/test_stack.py::TestStackObject::test_stack_is_a_subclassed_dict", + "tests/test_view_manager.py::TestViewManager::test_vm_c_b", + "tests/test_view_manager.py::TestViewManager::test_vm_c_b_w_auto", + "tests/test_view_manager.py::TestViewManager::test_vm_c_b_w_both", + "tests/test_view_manager.py::TestViewManager::test_vm_cp_b", + "tests/test_view_manager.py::TestViewManager::test_vm_cp_b_n_s_w_both", + "tests/test_view_manager.py::TestViewManager::test_vm_cp_b_n_t_w_both", + "tests/test_view_manager.py::TestViewManager::test_vm_cp_b_n_w_both", + "tests/test_view_manager.py::TestViewManager::test_vm_cp_b_s_w_both", + "tests/test_view_manager.py::TestViewManager::test_vm_cp_b_t_w_both", + "tests/test_view_manager.py::TestViewManager::test_vm_cp_b_w_auto", + "tests/test_view_manager.py::TestViewManager::test_vm_cp_b_w_both", + "tests/test_view_manager.py::TestViewManager::test_vm_cp_n_s_t_w_both", + "tests/test_view_manager.py::TestViewManager::test_vm_cp_s_t_w_both", + "tests/test_view_manager.py::TestViewManager::test_vm_p_b", + "tests/test_view_manager.py::TestViewManager::test_vm_p_b_n_s_t_w_both", + "tests/test_view_manager.py::TestViewManager::test_vm_p_b_n_s_w_both", + "tests/test_view_manager.py::TestViewManager::test_vm_p_b_n_t_w_both", + "tests/test_view_manager.py::TestViewManager::test_vm_p_b_n_w_both", + "tests/test_view_manager.py::TestViewManager::test_vm_p_b_s_t_w_both", + "tests/test_view_manager.py::TestViewManager::test_vm_p_b_s_w_both", + "tests/test_view_manager.py::TestViewManager::test_vm_p_b_t_w_both", + "tests/test_view_manager.py::TestViewManager::test_vm_p_b_w_auto", + "tests/test_view_manager.py::TestViewManager::test_vm_p_b_w_both", + "tests/test_view_mapper.py::TestViewObject::test__apply_to", + "tests/test_view_mapper.py::TestViewObject::test__custom_methods", + "tests/test_view_mapper.py::TestViewObject::test__get_method_types", + "tests/test_view_mapper.py::TestViewObject::test_add_method", + "tests/test_view_mapper.py::TestViewObject::test_get_view_iterations", + "tests/test_view_mapper.py::TestViewObject::test_iterations_object", + "tests/test_view_maps.py::TestViewObject::test_bases_float_on_single_w", + "tests/test_view_maps.py::TestViewObject::test_combined_codes_delimited_on_single_w", + "tests/test_view_maps.py::TestViewObject::test_cumulative_sum_counts", + "tests/test_view_maps.py::TestViewObject::test_cumulative_sum_cpercent", + "tests/test_view_maps.py::TestViewObject::test_default_delimited_at_no_w", + "tests/test_view_maps.py::TestViewObject::test_default_delimited_at_w", + "tests/test_view_maps.py::TestViewObject::test_default_delimited_on_delimited_w", + "tests/test_view_maps.py::TestViewObject::test_default_float_at_no_w", + "tests/test_view_maps.py::TestViewObject::test_default_float_at_w", + "tests/test_view_maps.py::TestViewObject::test_default_int_at_no_w", + "tests/test_view_maps.py::TestViewObject::test_default_int_at_w", + "tests/test_view_maps.py::TestViewObject::test_default_int_on_int_no_w", + "tests/test_view_maps.py::TestViewObject::test_default_single_at_no_w", + "tests/test_view_maps.py::TestViewObject::test_default_single_at_w", + "tests/test_view_maps.py::TestViewObject::test_ebase", + "tests/test_view_maps.py::TestViewObject::test_exclude_and_rescale_on_means_categorical_w", + "tests/test_view_maps.py::TestViewObject::test_frequencies_delimited_on_delimited_no_w", + "tests/test_view_maps.py::TestViewObject::test_frequencies_single_on_delimited_w", + "tests/test_view_maps.py::TestViewObject::test_frequencies_single_on_single_no_w", + "tests/test_view_maps.py::TestViewObject::test_means_test_level_10_unweighted_ovlp_no_missings", + "tests/test_view_maps.py::TestViewObject::test_means_test_level_20_weighted_no_missings", + "tests/test_view_maps.py::TestViewObject::test_means_test_level_5_weighted_all_codes", + "tests/test_view_maps.py::TestViewObject::test_means_test_level_high_askia_unweighted_all_codes", + "tests/test_view_maps.py::TestViewObject::test_means_tests_code_exclusion_base_flags_incl_total", + "tests/test_view_maps.py::TestViewObject::test_means_tests_code_exclusion_incl_total", + "tests/test_view_maps.py::TestViewObject::test_nps_single_on_delimited_no_w", + "tests/test_view_maps.py::TestViewObject::test_props_blocknet_calc_incl_total", + "tests/test_view_maps.py::TestViewObject::test_props_changed_meta_nets_incl_total", + "tests/test_view_maps.py::TestViewObject::test_props_means_tests_incl_total", + "tests/test_view_maps.py::TestViewObject::test_props_test_level_1_ovlp_weighted", + "tests/test_view_maps.py::TestViewObject::test_props_test_level_20_weighted", + "tests/test_view_maps.py::TestViewObject::test_props_test_level_5_ovlp_unweighted", + "tests/test_view_maps.py::TestViewObject::test_props_test_level_low_askia_weighted", + "tests/test_view_maps.py::TestViewObject::test_simple_means_all_types_no_w", + "tests/test_view_maps.py::TestViewObject::test_source_kwarg_descriptives", + "tests/test_view_maps.py::TestViewObject::test_source_kwarg_descriptives_sigtest", + "tests/test_weight_engine.py::TestEngine::test_add_scheme_and_dataframe", + "tests/test_weight_engine.py::TestEngine::test_add_scheme_no_key", + "tests/test_weight_engine.py::TestEngine::test_constructor", + "tests/test_weight_engine.py::TestEngine::test_group_targets", + "tests/test_weight_engine.py::TestEngine::test_vaidate_targets", + "tests/test_weight_engine.py::TestEngine::test_wdf_structure", + "tests/test_weight_engine.py::TestEngine::test_weight_lazy", + "tests/test_xlsx_formats.py::TestXlsxFormatsObject::test_create_formats_dict", + "tests/test_xlsx_formats.py::TestXlsxFormatsObject::test_initialisation", + "tests/test_xlsx_formats.py::TestXlsxFormatsObject::test_initialisation_properties" +] \ No newline at end of file diff --git a/README.md b/README.md index 5d1ce7342..c5a328e60 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,10 @@ Quantipy is an open-source data processing, analysis and reporting software proj #### Contributors - Alexander Buchhammer, Alasdair Eaglestone, James Griffiths, Kerstin Müller : https://yougov.co.uk -- Datasmoothie’s Birgir Hrafn Sigurðsson and Geir Freysson: http://datasmoothie.io/ +- Datasmoothie’s Birgir Hrafn Sigurðsson and Geir Freysson: http://datasmoothie.com/ + +### Python 3 compatability +Efforts are underway to port Quantipy to Python 3 in a [seperate repository](https://www.github.com/quantipy/quantipy3). ## Docs [View the documentation at readthedocs.org](http://quantipy.readthedocs.io/) diff --git a/docs/API/_build/doctrees/environment.pickle b/docs/API/_build/doctrees/environment.pickle index fe0765657..64f6f6e1f 100644 Binary files a/docs/API/_build/doctrees/environment.pickle and b/docs/API/_build/doctrees/environment.pickle differ diff --git a/docs/API/_build/doctrees/index.doctree b/docs/API/_build/doctrees/index.doctree index 12e3b17cf..9f4fe9a21 100644 Binary files a/docs/API/_build/doctrees/index.doctree and b/docs/API/_build/doctrees/index.doctree differ diff --git a/docs/API/_build/doctrees/sites/api_ref/00overview.doctree b/docs/API/_build/doctrees/sites/api_ref/00overview.doctree new file mode 100644 index 000000000..4f0fe3ca4 Binary files /dev/null and b/docs/API/_build/doctrees/sites/api_ref/00overview.doctree differ diff --git a/docs/API/_build/doctrees/sites/api_ref/Chain.doctree b/docs/API/_build/doctrees/sites/api_ref/Chain.doctree index 141e03c1d..efe850331 100644 Binary files a/docs/API/_build/doctrees/sites/api_ref/Chain.doctree and b/docs/API/_build/doctrees/sites/api_ref/Chain.doctree differ diff --git a/docs/API/_build/doctrees/sites/api_ref/Cluster.doctree b/docs/API/_build/doctrees/sites/api_ref/Cluster.doctree index e1206fb92..1f57483fa 100644 Binary files a/docs/API/_build/doctrees/sites/api_ref/Cluster.doctree and b/docs/API/_build/doctrees/sites/api_ref/Cluster.doctree differ diff --git a/docs/API/_build/doctrees/sites/api_ref/DataSet.doctree b/docs/API/_build/doctrees/sites/api_ref/DataSet.doctree new file mode 100644 index 000000000..3e3d842aa Binary files /dev/null and b/docs/API/_build/doctrees/sites/api_ref/DataSet.doctree differ diff --git a/docs/API/_build/doctrees/sites/api_ref/QuantipyViews.doctree b/docs/API/_build/doctrees/sites/api_ref/QuantipyViews.doctree index f4249e049..a881ddc1f 100644 Binary files a/docs/API/_build/doctrees/sites/api_ref/QuantipyViews.doctree and b/docs/API/_build/doctrees/sites/api_ref/QuantipyViews.doctree differ diff --git a/docs/API/_build/doctrees/sites/api_ref/Rim_scheme.doctree b/docs/API/_build/doctrees/sites/api_ref/Rim_scheme.doctree index f9a074649..8a1d981ef 100644 Binary files a/docs/API/_build/doctrees/sites/api_ref/Rim_scheme.doctree and b/docs/API/_build/doctrees/sites/api_ref/Rim_scheme.doctree differ diff --git a/docs/API/_build/doctrees/sites/api_ref/View.doctree b/docs/API/_build/doctrees/sites/api_ref/View.doctree index c3148af34..a067c5e58 100644 Binary files a/docs/API/_build/doctrees/sites/api_ref/View.doctree and b/docs/API/_build/doctrees/sites/api_ref/View.doctree differ diff --git a/docs/API/_build/doctrees/sites/api_ref/ViewMapper.doctree b/docs/API/_build/doctrees/sites/api_ref/ViewMapper.doctree index e9f4a199b..f19f90a24 100644 Binary files a/docs/API/_build/doctrees/sites/api_ref/ViewMapper.doctree and b/docs/API/_build/doctrees/sites/api_ref/ViewMapper.doctree differ diff --git a/docs/API/_build/doctrees/sites/api_ref/quantify_engine.doctree b/docs/API/_build/doctrees/sites/api_ref/quantify_engine.doctree index 907215308..5928c5ab8 100644 Binary files a/docs/API/_build/doctrees/sites/api_ref/quantify_engine.doctree and b/docs/API/_build/doctrees/sites/api_ref/quantify_engine.doctree differ diff --git a/docs/API/_build/doctrees/sites/api_ref/stack.doctree b/docs/API/_build/doctrees/sites/api_ref/stack.doctree index ca33de829..f4da88860 100644 Binary files a/docs/API/_build/doctrees/sites/api_ref/stack.doctree and b/docs/API/_build/doctrees/sites/api_ref/stack.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/batch/00_overview.doctree b/docs/API/_build/doctrees/sites/lib_doc/batch/00_overview.doctree new file mode 100644 index 000000000..fdcf28510 Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/batch/00_overview.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/batch/01_create_load.doctree b/docs/API/_build/doctrees/sites/lib_doc/batch/01_create_load.doctree new file mode 100644 index 000000000..aaf7e6ddb Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/batch/01_create_load.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/batch/02_variables.doctree b/docs/API/_build/doctrees/sites/lib_doc/batch/02_variables.doctree new file mode 100644 index 000000000..5ff828149 Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/batch/02_variables.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/batch/03_properties.doctree b/docs/API/_build/doctrees/sites/lib_doc/batch/03_properties.doctree new file mode 100644 index 000000000..949a699ae Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/batch/03_properties.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/batch/04_subclass.doctree b/docs/API/_build/doctrees/sites/lib_doc/batch/04_subclass.doctree new file mode 100644 index 000000000..99e63e0a0 Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/batch/04_subclass.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/builds/00_overview.doctree b/docs/API/_build/doctrees/sites/lib_doc/builds/00_overview.doctree new file mode 100644 index 000000000..8519ce31f Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/builds/00_overview.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/builds/01_chains.doctree b/docs/API/_build/doctrees/sites/lib_doc/builds/01_chains.doctree new file mode 100644 index 000000000..c5437f323 Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/builds/01_chains.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/00_overview.doctree b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/00_overview.doctree new file mode 100644 index 000000000..c58fef7f9 Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/00_overview.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/01_components.doctree b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/01_components.doctree new file mode 100644 index 000000000..6af8447f9 Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/01_components.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/02_io.doctree b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/02_io.doctree new file mode 100644 index 000000000..4826feade Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/02_io.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/02a_management.doctree b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/02a_management.doctree new file mode 100644 index 000000000..903c2776e Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/02a_management.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/03_inspection.doctree b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/03_inspection.doctree new file mode 100644 index 000000000..1ce54f715 Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/03_inspection.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/04_editing.doctree b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/04_editing.doctree new file mode 100644 index 000000000..b4f271307 Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/04_editing.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/05_transforming.doctree b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/05_transforming.doctree new file mode 100644 index 000000000..25b73906e Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/05_transforming.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/06_logics.doctree b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/06_logics.doctree new file mode 100644 index 000000000..7fcce1615 Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/06_logics.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/07_custom_recoding.doctree b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/07_custom_recoding.doctree new file mode 100644 index 000000000..7cfdd591e Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/07_custom_recoding.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/engine/00_overview.doctree b/docs/API/_build/doctrees/sites/lib_doc/engine/00_overview.doctree new file mode 100644 index 000000000..3aa4625fe Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/engine/00_overview.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/engine/01_links_stacks.doctree b/docs/API/_build/doctrees/sites/lib_doc/engine/01_links_stacks.doctree new file mode 100644 index 000000000..62ac65e5e Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/engine/01_links_stacks.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/engine/02_quantity.doctree b/docs/API/_build/doctrees/sites/lib_doc/engine/02_quantity.doctree new file mode 100644 index 000000000..304b2ff28 Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/engine/02_quantity.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/engine/03_test.doctree b/docs/API/_build/doctrees/sites/lib_doc/engine/03_test.doctree new file mode 100644 index 000000000..cd96c4826 Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/engine/03_test.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/engine/04_agg_methods.doctree b/docs/API/_build/doctrees/sites/lib_doc/engine/04_agg_methods.doctree new file mode 100644 index 000000000..2f84217e9 Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/engine/04_agg_methods.doctree differ diff --git a/docs/API/_build/doctrees/sites/lib_doc/overview.doctree b/docs/API/_build/doctrees/sites/lib_doc/overview.doctree new file mode 100644 index 000000000..307b00ce9 Binary files /dev/null and b/docs/API/_build/doctrees/sites/lib_doc/overview.doctree differ diff --git a/docs/API/_build/doctrees/sites/release_notes/00_overview.doctree b/docs/API/_build/doctrees/sites/release_notes/00_overview.doctree new file mode 100644 index 000000000..51bffc687 Binary files /dev/null and b/docs/API/_build/doctrees/sites/release_notes/00_overview.doctree differ diff --git a/docs/API/_build/doctrees/sites/release_notes/01_latest.doctree b/docs/API/_build/doctrees/sites/release_notes/01_latest.doctree new file mode 100644 index 000000000..31139a5ef Binary files /dev/null and b/docs/API/_build/doctrees/sites/release_notes/01_latest.doctree differ diff --git a/docs/API/_build/doctrees/sites/release_notes/02_archive.doctree b/docs/API/_build/doctrees/sites/release_notes/02_archive.doctree new file mode 100644 index 000000000..89e0682ec Binary files /dev/null and b/docs/API/_build/doctrees/sites/release_notes/02_archive.doctree differ diff --git a/docs/API/_build/doctrees/sites/release_notes/03_how_to_snippets.doctree b/docs/API/_build/doctrees/sites/release_notes/03_how_to_snippets.doctree new file mode 100644 index 000000000..cb1aca326 Binary files /dev/null and b/docs/API/_build/doctrees/sites/release_notes/03_how_to_snippets.doctree differ diff --git a/docs/API/_build/doctrees/sites/release_notes/how_to_snippets/create_categorical_meta.doctree b/docs/API/_build/doctrees/sites/release_notes/how_to_snippets/create_categorical_meta.doctree new file mode 100644 index 000000000..5c9dcd8ea Binary files /dev/null and b/docs/API/_build/doctrees/sites/release_notes/how_to_snippets/create_categorical_meta.doctree differ diff --git a/docs/API/_build/doctrees/sites/release_notes/how_to_snippets/derotate.doctree b/docs/API/_build/doctrees/sites/release_notes/how_to_snippets/derotate.doctree new file mode 100644 index 000000000..43ceaad15 Binary files /dev/null and b/docs/API/_build/doctrees/sites/release_notes/how_to_snippets/derotate.doctree differ diff --git a/docs/API/_build/doctrees/sites/release_notes/how_to_snippets/dimensions_comp.doctree b/docs/API/_build/doctrees/sites/release_notes/how_to_snippets/dimensions_comp.doctree new file mode 100644 index 000000000..1fc4bea95 Binary files /dev/null and b/docs/API/_build/doctrees/sites/release_notes/how_to_snippets/dimensions_comp.doctree differ diff --git a/docs/API/_build/html/.buildinfo b/docs/API/_build/html/.buildinfo index 145d7a01e..959860160 100644 --- a/docs/API/_build/html/.buildinfo +++ b/docs/API/_build/html/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 0288e8257f20bf0e318a1e13f4f950ad +config: 3c8d31b3ee2b61e092a93342a4c7e2d0 tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/API/_build/html/_sources/sites/api_ref/00overview.rst.txt b/docs/API/_build/html/_sources/sites/api_ref/00overview.rst.txt new file mode 100644 index 000000000..c4882fa5d --- /dev/null +++ b/docs/API/_build/html/_sources/sites/api_ref/00overview.rst.txt @@ -0,0 +1,16 @@ + +API references +============== + +.. toctree:: + :maxdepth: 3 + + Chain + Cluster + DataSet + quantify_engine + QuantipyViews + Rim_scheme + Stack + View + ViewMapper \ No newline at end of file diff --git a/docs/API/_build/html/_sources/sites/api_ref/DataSet.rst.txt b/docs/API/_build/html/_sources/sites/api_ref/DataSet.rst.txt new file mode 100644 index 000000000..f463db588 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/api_ref/DataSet.rst.txt @@ -0,0 +1,8 @@ +.. toctree:: + :maxdepth: 3 + +DataSet +======= + +.. autoclass:: quantipy.DataSet + :members: \ No newline at end of file diff --git a/docs/API/_build/html/_sources/sites/lib_doc/batch/00_overview.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/batch/00_overview.rst.txt new file mode 100644 index 000000000..99ba6909b --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/batch/00_overview.rst.txt @@ -0,0 +1,35 @@ + +========= +``Batch`` +========= + +``qp.Batch`` is a subclass of ``qp.DataSet`` and is a container for +structuring a ``qp.Link`` collection's specifications. + +``qp.Batch`` is not only a subclass of ``qp.DataSet``, it also takes a +DataSet instance as input argument, inheriting a few of its attributes, e.g. +``_meta``, ``_data``, ``valid_tks`` and ``text_key``. +All other ``Batch`` attributes are used as construction plans for populating a +``qp.Stack``, these get stored in the belonging ``DataSet`` meta component in +``_meta['sets']['batches'][batchname]``. + +In general, it does not matter in which order ``Batch`` attributes are set by +methods, the class ensures that all attributes are kept consistent. + +All next sections are working with the following ``qp.DataSet`` instance:: + + import quantipy as qp + + dataset = qp.DataSet('Example Data (A)') + dataset.read_quantipy('Example Data (A).json', 'Example Data (A).csv') + +The json and csv files you can find in ``quantipy/tests``. + +.. toctree:: + :maxdepth: 5 + :includehidden: + + 01_create_load + 02_variables + 03_properties + 04_subclass diff --git a/docs/API/_build/html/_sources/sites/lib_doc/batch/01_create_load.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/batch/01_create_load.rst.txt new file mode 100644 index 000000000..70ba8ef63 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/batch/01_create_load.rst.txt @@ -0,0 +1,27 @@ +.. toctree:: + :maxdepth: 5 + :includehidden: + +========================================= +Creating/ Loading a ``qp.Batch`` instance +========================================= + +As mentioned, a ``Batch`` instance has a close connection to its belonging +``DataSet`` instance and we can easily create a new ``Batch`` from a ``DataSet`` +as per:: + + batch1 = dataset.add_batch(name='batch1') + batch2 = dataset.add_batch(name='batch2', ci=['c'], weights='weight') + +It is also possible to load an already existing instance out of the meta +stored in ``dataset._meta['sets']['batches']``:: + + batch = dataset.get_batch('batch1') + +Both methods, ``.add_batch()`` and ``.get_batch()``, are an easier way to +use the ``__init__()`` method of ``qp.Batch``. + +An other way to get a new ``qp.Batch`` instance is to copy an existing one, in +that case all added open ends are removed from the new instance:: + + copy_batch = batch.copy('copy_of_batch1') diff --git a/docs/API/_build/html/_sources/sites/lib_doc/batch/02_variables.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/batch/02_variables.rst.txt new file mode 100644 index 000000000..201d8c374 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/batch/02_variables.rst.txt @@ -0,0 +1,119 @@ +.. toctree:: + :maxdepth: 5 + :includehidden: + +=========================================== +Adding variables to a ``qp.Batch`` instance +=========================================== + +----------------- +x-keys and y-keys +----------------- + +The included variables in a ``Batch`` constitute the main structure for the +``qp.Stack`` construction plan. Variables can be added as x-keys or y-keys, for +arrays all belonging items are automatically added and the ``qp.Stack`` gets +populated with all cross-tabulations of these keys: + +>>> batch.add_x(['q1', 'q2', 'q6']) +>>> batch.add_y(['gender', 'q1']) +Array summaries setup: Creating ['q6']. + +x-specific y-keys can be produced by manipulating the main y-keys, this edit +can be extending or replacing the existing keys: + +>>> batch.extend_y(['locality', 'ethnicity'], on=['q1']) +>>> batch.replace_y(['locality', 'ethnicity'], on=['q2']) + +With these settings the construction plan looks like that: + +>>> print batch.x_y_map +OrderedDict([('q1', ['@', 'gender', 'q1', 'locality', 'ethnicity']), + ('q2', ['locality', 'ethnicity']), + ('q6', ['@']), + (u'q6_1', ['@', 'gender', 'q1']), + (u'q6_2', ['@', 'gender', 'q1']), + (u'q6_3', ['@', 'gender', 'q1'])]) + +------ +Arrays +------ + +A special case exists if the added variables contain arrays. As default for all +arrays in x-keys array summaries are created (array as x-key and ``'@'``-referenced total as +y-key), see the output below (``Array summaries setup: Creating ['q6'].``). +If array summaries are requested only for a selection of variables or for none, +use ``.make_summaries()``: + +>>> batch.make_summaries(None) +Array summaries setup: Creating no summaries! + +Arrays can also be transposed (``'@'``-referenced total as x-key and array name +as y-key). If they are not in the batch summary list before, they are +automatically added and depending on the ``replace`` parameter only the +transposed or both types of summaries are added to the ``qp.Stack``: + +>>> batch.transpose_array('q6', replace=False) +Array summaries setup: Creating ['q6']. + +The construction plan now shows that both summary types are included: + +>>> print batch.x_y_map +OrderedDict([('q1', ['@', 'gender', 'q1', 'locality', 'ethnicity']), + ('q2', ['locality', 'ethnicity']), + ('q6', ['@']), + ('@', ['q6']), + (u'q6_1', ['@', 'gender', 'q1']), + (u'q6_2', ['@', 'gender', 'q1']), + (u'q6_3', ['@', 'gender', 'q1'])]) + +-------------------- +Verbatims/ open ends +-------------------- + +Another special case are verbatims. They will not be aggregated in a ``qp.Stack``, +but they have to be defined in a ``qp.Batch`` to add them later to a ``qp.Cluster``. + +There are two different ways to add verbatims: Either all to one ``qp.Cluster`` +key or each gets its own key. But both options can be done with the same method. + +For splitting the verbatims, set ``split=True`` and insert as many titles as +included verbatims/ open ends: + +>>> batch.add_open_ends(['q8a', 'q9a'], break_by=['record_number', 'age'], + split=True, title=['oe_q8', 'oe_q9']) + +For collecting all verbatims in one Cluster key, set ``split=False`` and add +only one ``title`` or use the default parameters: + +>>> batch.add_open_ends(['q8a', 'q9a'], break_by=['record_number', 'age']) + +-------------------- +Special aggregations +-------------------- + +It is possible to add some special aggregations to a ``qp.Batch``, that are +not stored in the main construction plan ``.x_y_map``. One option is to give a +name for a Cluster key in which all y-keys are cross-tabulated against each +other: + +>>> batch.add_y_on_y('y-keys') + +Another possibility is to add a ``qp.Batch`` instance to an other instance. +The added Batch loses all information about verbatims and ``.y_on_y``, that +means only the main construction plan in ``.x_y_map`` gets adopted. Each of +the two batches is aggregated discretely in the ``qp.Stack``, but the added +instance gets included into the ``qp.Cluster`` of the first ``qp.Batch`` in +a key named by its instance name. + +>>> batch1 = dataset.get_batch('batch1') +>>> batch2 = dataset.get_batch('batch2') +>>> batch2.add_x('q2b') +Array summaries setup: Creating no summaries! +>>> batch2.add_y('gender') +>>> batch2.as_addition('batch1') +Batch 'batch2' specified as addition to Batch 'batch1'. Any open end summaries and 'y_on_y' agg. have been removed! + +The connection between the two ``qp.Batch`` instances you can see in ``.additional`` +for the added instance and in ``._meta['sets']['batches']['batchname']['additions']`` +for the first instance. \ No newline at end of file diff --git a/docs/API/_build/html/_sources/sites/lib_doc/batch/03_properties.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/batch/03_properties.rst.txt new file mode 100644 index 000000000..d4c43175e --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/batch/03_properties.rst.txt @@ -0,0 +1,58 @@ +.. toctree:: + :maxdepth: 5 + :includehidden: + +================================ +Set properties of a ``qp.Batch`` +================================ + +The section before explained how the main construction plan (``batch.x_y_map``) +is built, that describes which x-keys and y-keys are used to add ``qp.Link``\s +to a ``qp.Stack``. Now you will get to know how the missing information for the +``Link``\s are defined and which specific views get extracted for the +``qp.Cluster`` by adding some property options the ``qp.Batch`` instance. + +---------------------------------------- +Filter, weights and significance testing +---------------------------------------- + +``qp.Link``\s can be added to a ``qp.Stack`` data_key-level by defining its x +and y-keys, which is already done in ``.x_y_map``, and setting a filter. +This property can be edited in a ``qp.Batch`` instance with the +following methods: + +>>> batch.add_filter('men only', {'gender': 1}) +>>> batch.extend_filter({'q1': {'age': [20, 21, 22, 23, 24, 25]}}) + +Filters can be added globally or for a selection of x-keys only. Out of the +global filter, ``.sample_size`` is automatically calculated for each ``qp.Batch`` +defintion. + +Now all information are collected in the ``qp.Batch`` instance and the ``Stack`` +can be populated with ``Link``\s in form of ``stack[data_key][filter_key][x_key][y_key]``. + +For each ``Link`` ``qp.View``\s can be added, these views depend on a weight +definition, which is also defined in the ``qp.Batch``: + +>>> batch.set_weights(['weight_a']) + +Significance tests are a special ``View``; the sig. levels which they are +calculated on can be added to the ``qp.Batch`` like this: + +>>> batch.set_sigtests(levels=[0.05]) + +----------------------- +Cell items and language +----------------------- + +As ``qp.Stack`` is a container for a large amount of aggregations, it will +accommodate various ``qp.View``\s. The ``qp.Batch`` property ``.cell_items`` is +used to define which specfic ``Views`` will be taken to create a ``qp.Cluster``: + +>>> batch.set_cell_items(['c', 'p']) + +The property ``.language`` allows the user to define which ``text`` labels from +the meta data should be used for the extracted ``Views`` by entering a valid +text key: + +>>> batch.set_language('en-GB') diff --git a/docs/API/_build/html/_sources/sites/lib_doc/batch/04_subclass.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/batch/04_subclass.rst.txt new file mode 100644 index 000000000..a47c4d828 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/batch/04_subclass.rst.txt @@ -0,0 +1,26 @@ +.. toctree:: + :maxdepth: 5 + :includehidden: + +================================ +Inherited ``qp.DataSet`` methods +================================ + +Being a ``qp.DataSet`` subclasss, ``qp.Batch`` inherits some of its methods. +The important ones are these which allow the manipulation of the meta component. +That means meta-edits can be applied globally (run methods on ``qp.DataSet``) or +``Batch``-specific (run methods on ``qp.Batch``). Batch meta-edits +always overwrite global meta-edits and while building a ``qp.Cluster`` from a +``qp.Batch``, the modified meta information is taken from ``.meta_edits``. + +The following methods can be used to create meta-edits for a ``qp.Batch``: + +>>> batch.hiding('q1', [2], axis='y') +>>> batch.sorting('q2', fix=[97, 98]) +>>> batch.slicing('q1', [1, 2, 3, 4, 5], axis='x') +>>> batch.set_variable_text('gender', 'Gender???') +>>> batch.set_value_texts('gender', {1: 'Men', 2: 'Women'}) +>>> batch.set_property('q1', 'base_text', 'This var has a second filter.') + +Some methods are not allowed to be used for a ``Batch``. These will raise a +``NotImplementedError`` to prevent inconsistent case and meta data states. diff --git a/docs/API/_build/html/_sources/sites/lib_doc/builds/00_overview.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/builds/00_overview.rst.txt new file mode 100644 index 000000000..365bfbcd5 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/builds/00_overview.rst.txt @@ -0,0 +1,9 @@ +====== +Builds +====== + +.. toctree:: + :maxdepth: 5 + :includehidden: + + 01_chains diff --git a/docs/API/_build/html/_sources/sites/lib_doc/builds/01_chains.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/builds/01_chains.rst.txt new file mode 100644 index 000000000..c7af8e55f --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/builds/01_chains.rst.txt @@ -0,0 +1,21 @@ +.. toctree:: + :maxdepth: 5 + :includehidden: + +================= +Combining results +================= + +-------------------------------- +Organizing ``View`` aggregations +-------------------------------- + +------------------------------- +Creating ``Chain`` aggregations +------------------------------- + +What is a ``Chain``? +-------------------- + +Customizing results +------------------- diff --git a/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/00_overview.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/00_overview.rst.txt new file mode 100644 index 000000000..aa4b136a8 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/00_overview.rst.txt @@ -0,0 +1,16 @@ +--------------- +Data processing +--------------- + +.. toctree:: + :maxdepth: 5 + :includehidden: + + 01_components + 02_io + 02a_management + 03_inspection + 04_editing + 05_transforming + 06_logics + 07_custom_recoding diff --git a/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/01_components.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/01_components.rst.txt new file mode 100644 index 000000000..3dc724552 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/01_components.rst.txt @@ -0,0 +1,141 @@ +.. toctree:: + :maxdepth: 5 + :includehidden: + +================== +DataSet components +================== + +------------------ +Case and meta data +------------------ + +``Quantipy`` builds upon the ``pandas`` library to feature the ``DataFrame`` +and ``Series`` objects in the case data component of its ``DataSet`` object. +Additionally, each ``DataSet`` offers a metadata component to describe the +data columns and provide additional information on the characteristics of the +underlying structure. The metadata document is implemented as a nested ``dict`` +and provides the following ``keys`` on its first level: + +============== ============================================================== +element contains +============== ============================================================== +``'type'`` case data type +``'info'`` info on the source data +``'lib'`` shared use references +``'columns'`` info on ``DataFrame`` columns (Quantipy types, labels, etc.) +``'sets'`` ordered groups of variables pointing to other parts of the meta +``'masks'`` complex variable type definitions (arrays, dichotomous, etc.) +============== ============================================================== + +--------------------------------- +``columns`` and ``masks`` objects +--------------------------------- + +There are two variable collections inside a ``Quantipy`` metadata document: +``'columns'`` is storing the meta for each accompanying ``pandas.DataFrame`` +column object, while ``'masks'`` are building upon the regular ``'columns'`` +metadata but additionally employ special meta instructions to define +complex data types. An example is the the ``'array'`` type that (in MR speak) maps +multiple "question" variables to one "answer" object. + +"Simple"" data definitons that are supported by ``Quantipy`` can either be numeric +``'float'`` and ``'int'`` types, categorical ``'single'`` and ``'delimited set'`` +variables or of type ``'string'``, ``'date'`` and ``'time'``. + +--------------------------------------------- +Languages: ``text`` and ``text_key`` mappings +--------------------------------------------- +Throughout ``Quantipy`` metadata all label information, e.g. variable question +texts and category descriptions, are stored in ``text`` objects that are mapping +different language (or context) versions of a label to a specific ``text_key``. +That way the metadata can support multi-language and multi-purpose (for example +detailed/extensive vs. short question texts) label information in a digestable +format that is easy to query: + +>>> meta['columns']['q1']['text'] +{'de-DE': 'Das ist ein langes deutsches Label', + u'en-GB': u'What is your main fitness activity?', + 'x edits': {'de-DE': 'German build label', 'en-GB': 'English build label'}} + +Valid ``text_key`` settings are: + +============== ============================================================== +``text_key`` Language / context +============== ============================================================== +``'en-GB'`` English +``'de-DE'`` German +``'fr-FR'`` French +``'da-DK'`` Danish +``'sv-SV'`` Swedish +``'nb-NO'`` Norwegian +``'fi-FI'`` Finnish +``'x edits'`` Build label edit for x-axis +``'y edits'`` Build label edit for y-axis +============== ============================================================== + +----------------------------- +Categorical ``values`` object +----------------------------- +``single`` and ``delimited set`` variables restrict the possible case data +entries to a list of ``values`` that consist of numeric answer codes and their +``text`` labels, defining distinct categories: + +>>> meta['columns']['q1']['values'] +[{'value': 1, + 'text': {'en-GB': 'Dog'} + }, + {'value': 2, + 'text': {'en-GB': 'Cat'} + }, + {'value': 3, + 'text': {'en-GB': 'Bird'} + }, + {'value': -9, + 'text': {'en-GB': 'Not an animal'} + }] + +------------------ +The ``array`` type +------------------ +Turning to the ``masks`` collection of the metadata, ``array`` variables +group together a collection of variables that share a common response options +scheme, i.e. different statements (usually referencing a broader topic) that +are answered using the same scale. In the ``Quantipy`` metadata document, an +``array`` variable has a ``subtype`` that describes the type of the +constructing source variables listed in the ``items`` object. In contrast to simple variable types, any +categorical ``values`` metadata is stored inside the shared information collection +``lib``, for access from both the ``columns`` and ``masks`` representation of +``array`` elements: + +>>> meta['masks']['q5'] +{u'items': [{u'source': u'columns@q5_1', u'text': {u'en-GB': u'Surfing'}}, + {u'source': u'columns@q5_2', u'text': {u'en-GB': u'Snowboarding'}}, + {u'source': u'columns@q5_3', u'text': {u'en-GB': u'Kite boarding'}}, + {u'source': u'columns@q5_4', u'text': {u'en-GB': u'Parachuting'}}, + {u'source': u'columns@q5_5', u'text': {u'en-GB': u'Cave diving'}}, + {u'source': u'columns@q5_6', u'text': {u'en-GB': u'Windsurfing'}}], + u'name': u'q5', + u'subtype': u'single', + u'text': {u'en-GB': u'How likely are you to do each of the following in the next year?'}, + u'type': u'array', + u'values': 'lib@values@q5'} + +>>> meta['lib']['values']['q5'] +[{u'text': {u'en-GB': u'I would refuse if asked'}, u'value': 1}, + {u'text': {u'en-GB': u'Very unlikely'}, u'value': 2}, + {u'text': {u'en-GB': u"Probably wouldn't"}, u'value': 3}, + {u'text': {u'en-GB': u'Probably would if asked'}, u'value': 4}, + {u'text': {u'en-GB': u'Very likely'}, u'value': 5}, + {u'text': {u'en-GB': u"I'm already planning to"}, u'value': 97}, + {u'text': {u'en-GB': u"Don't know"}, u'value': 98}] + +Exploring the ``columns`` meta of an array item shows the same ``values`` reference pointer and informs about its ``parent`` meta structure, i.e. the +array's ``masks`` defintion: + +>>> meta['columns']['q5_1'] +{u'name': u'q5_1', + u'parent': {u'masks@q5': {u'type': u'array'}}, + u'text': {u'en-GB': u'How likely are you to do each of the following in the next year? - Surfing'}, + u'type': u'single', + u'values': u'lib@values@q5'} \ No newline at end of file diff --git a/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/02_io.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/02_io.rst.txt new file mode 100644 index 000000000..4a6205ea8 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/02_io.rst.txt @@ -0,0 +1,207 @@ +.. toctree:: + :maxdepth: 5 + :includehidden: + +=== +I/O +=== + +------------------------------- +Starting from native components +------------------------------- + +Using a standalone ``pd.DataFrame`` +----------------------------------- +``Quantipy`` can create a meta document from a inferring its variable types from +the ``dtypes`` of a ``pd.DataFrame``. In that process, ``ìnt``, ``float`` and +``string`` data types are created inside the meta component of the ``DataSet``. +In this basic form, ``text`` label information is missing. For a example, given +a ``pd.DataFrame`` as per: + +>>> casedata = [[1000, 10, 1.2, 'text1'], +... [1001, 4, 3.4, 'jjda'], +... [1002, 8, np.NaN, 'what?'], +... [1003, 8, 7.81, '---' ], +... [1004, 5, 3.0, 'hello world!']] +>>> df = pd.DataFrame(casedata, columns=['identity', 'q1', 'q2', 'q3']) +>>> df + identity q1 q2 q3 +0 1000 10 1.20 text1 +1 1001 4 3.40 jjda +2 1002 8 NaN what? +3 1003 8 7.81 --- +4 1004 5 3.00 hello world! + +... the conversion is adding matching metadata to the ``DataSet`` instance: + +>>> dataset = qp.DataSet(name='example', dimensions_comp=False) +>>> dataset.from_components(df) +Inferring meta data from pd.DataFrame.columns (4)... +identity: dtype: int64 - converted: int +q1: dtype: int64 - converted: int +q2: dtype: float64 - converted: float +q3: dtype: object - converted: string + +>>> dataset.meta()['columns']['q2'] +{'text': {'en-GB': ''}, 'type': 'float', 'name': 'q2', 'parent': {}, 'properties': {'created': True}} + +``.csv`` / ``.json`` pairs +-------------------------- +We can easily read in ``Quantipy`` native data with the ``read_quantipy()`` +method and providing the paths to both the ``.csv`` and ``.json`` file (file +extensions are handled automatically), e.g.: + +>>> folder = './Data/' +>>> file_name = 'Example Data (A)' +>>> path_csv = path_json = folder + file_name + +>>> dataset = qp.DataSet(name='example', dimensions_comp=False) +>>> dataset.read_quantipy(path_json, path_csv) +DataSet: ./Data/example +rows: 8255 - columns: 76 +Dimensions compatibility mode: False + +We can that access the case and metadata components: + +>>> dataset.data()['q4'].head() +0 1 +1 2 +2 2 +3 1 +4 1 +Name: q4, dtype: int64 + +>>> meta = dataset.meta()['columns']['q4'] +>>> json.dumps(meta) +{ + "values": [ + { + "text": { + "en-GB": "Yes" + }, + "value": 1 + }, + { + "text": { + "en-GB": "No" + }, + "value": 2 + } + ], + "text": { + "en-GB": "Do you ever participate in sports activities with people in your household?" + }, + "type": "single", + "name": "q4", + "parent": {} +} + +----------------------- +Third party conversions +----------------------- + +Supported conversions +--------------------- + +In adddition to providing plain ``.csv``/``.json`` data (pairs), source files +can be read into Quantipy using a number of I/O functions to deal with +standard file formats encountered in the market research industry: + ++-------------+-------------+-------------+-------------+ +| Software | Format | Read | Write | ++=============+=============+=============+=============+ +| SPSS | .sav | Yes | Yes | +| Statistics | | | | ++-------------+-------------+-------------+-------------+ +| SPSS | .dff/.mdd | Yes | Yes | +| Dimensions | | | | ++-------------+-------------+-------------+-------------+ +| Decipher |tab-delimited| Yes | No | +| |.json/ .txt | | | ++-------------+-------------+-------------+-------------+ +| Ascribe |tab-delimited| Yes | No | +| |.xml/ .txt | | | ++-------------+-------------+-------------+-------------+ + +The following functions are designed to convert the different file formats' +structures into inputs understood by Quantipy. + +SPSS Statistics +--------------- + +**Reading:** + +>>> from quantipy.core.tools.dp.io import read_spss +>>> meta, data = read_spss(path_sav) + +.. note:: + On a Windows machine you MUST use ``ioLocale=None`` when reading + from SPSS. This means if you are using a Windows machine your base + example for reading from SPSS is + ``meta, data = read_spss(path_sav, ioLocale=None)``. + +When reading from SPSS you have the opportunity to specify a custom +dichotomous values map, that will be used to convert all dichotomous +sets into Quantipy delimited sets, using the ``dichot`` argument. + +The entire read operation will use the same map on all dichotomous +sets so they must be applied uniformly throughout the SAV file. The +default map that will be used if none is provided will be +``{'yes': 1, 'no': 0}``. + +>>> meta, data = read_spss(path_sav, dichot={'yes': 1, 'no': 2}) + +SPSS dates will be converted to pandas dates by default but +if this results in conversion issues or failures you can read +the dates in as Quantipy strings to deal with them later, using the +``dates_as_strings`` argument. + +>>> meta, data = read_spss(path_sav, dates_as_strings=True) + +**Writing:** + +>>> from quantipy.core.tools.dp.io import write_spss +>>> write_spss(path_sav, meta, data) + +By default SPSS files will be generated from the ``'data file'`` +set found in ``meta['sets']``, but a custom set can be named instead +using the ``from_set`` argument. + +>>> write_spss(path_sav_analysis, meta, data, from_set='sav-export') + +The custom set must be well-formed: + +>>> "sets" : { +... "sav-export": { +... "items": [ +... "columns@Q1", +... "columns@Q2", +... "columns@Q3", +... ... +... ] +... } +... } + +Dimensions +---------- + +**Reading:** + +>>> from quantipy.core.tools.dp.io import read_dimensions +>>> meta, data = read_dimensions(path_mdd, path_ddf) + +Decipher +-------- + +**Reading:** + +>>> from quantipy.core.tools.dp.io import read_decipher +>>> meta, data = read_decipher(path_json, path_txt) + +Ascribe +------- + +**Reading:** + +>>> from quantipy.core.tools.dp.io import read_ascribe +>>> meta, data = read_ascribe(path_xml, path_txt) diff --git a/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/02a_management.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/02a_management.rst.txt new file mode 100644 index 000000000..de7824b4e --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/02a_management.rst.txt @@ -0,0 +1,122 @@ +.. toctree:: + :maxdepth: 5 + :includehidden: + +================== +DataSet management +================== + +-------------------------- +Setting the variable order +-------------------------- +The global variable order of a ``DataSet`` is dictated by the content of the +``meta['sets']['data file']['items']`` list and reflected in the structure of +the case data component's ``pd.DataFrame.columns``. There are two ways to set +a new order using the ``order(new_order=None, reposition=None)`` method: + +**Define a full order** + +Using this apporach requires that all ``DataSet`` variable names are passed +via the ``new_order`` parameter. Providing only a subset of the variables will +raise a ``ValueError``: + +>>> dataset.order(['q1', 'q8']) +ValueError: 'new_order' must contain all DataSet variables. + +Text... + +**Change positions relatively** + +Often only a few changes to the natural order of the ``DataSet`` are necessary, +e.g. derived variables should be moved alongside their originating ones or specific +sets of variables (demographics, etc.) should be grouped together. We can achieve +this using the ``reposition`` parameter as follows: + +Text... + +--------------------------------- +Cloning, filtering and subsetting +--------------------------------- + +Sometimes you want to cut the data into sections defined by either case/respondent conditions (e.g. a survey wave) or a collection of variables (e.g. +a specific part of the questionnaire). To not permanently change an existing +``DataSet`` by accident, draw a copy of it first: + +>>> copy_ds = dataset.clone() + +Then you can use ``filter()`` to restrict cases (rows) or ``subset()`` to keep +only a selected range of variables (columns). Both methods can be used inplace +but will return a new object by default. + +>>> keep = {'Wave': [1]} +>>> copy_ds.filter(alias='first wave', condition=keep, inplace=True) +>>> copy_ds._data.shape +(1621, 76) + +After the filter has been applied, the ``DataSet`` is only showing cases that contain the value 1 in the ``'Wave'`` variable. The filter alias (a short name +to describe the arbitrarily complex filter ``condition``) is attached to the +instance: + +>>> copy_ds.filtered +only first wave + +We are now further reducing the ``DataSet`` by dropping all variables except the three ``array`` variables ``'q5'``, ``'q6'``, and ``'q7'`` using ``subset()``. + +>>> reduced_ds = copy_ds.subset(variables=['q5', 'q6', 'q7']) + +We can see that only the requested variables (``masks`` defintitions and the +constructing ``array`` items) remain in ``reduced_ds``: + +>>> reduced_ds.by_type() +size: 1621 single delimited set array int float string date time N/A +0 q5_1 q5 +1 q5_2 q7 +2 q5_3 q6 +3 q5_4 +4 q5_5 +5 q5_6 +6 q6_1 +7 q6_2 +8 q6_3 +9 q7_1 +10 q7_2 +11 q7_3 +12 q7_4 +13 q7_5 +14 q7_6 + +------- +Merging +------- + +Intro text... As opposed to reducing an existing file... + +Vertical (cases/rows) merging +----------------------------- + +Text + +Horizontal (variables/columns) merging +-------------------------------------- + +Text + +----------------------------- +Savepoints and state rollback +----------------------------- + +When working with big ``DataSet``\s and needing to perform a lot of data +preparation (deriving large amounts of new variables, lots of meta editing, +complex cleaning, ...) it can be beneficial to quickly store a snapshot of a +clean and consistent state of the ``DataSet``. This is most useful when working +in interactive sessions like **IPython** or **Jupyter notebooks** and might +prevent you from reloading files from disk or waiting for previous processes +to finish. + +Savepoints are stored via ``save()`` and can be restored via ``revert()``. + +.. note:: + Savepoints only exists in memory and are not written to disk. Only one + savepoint can exist, so repeated ``save()`` calls will overwrite any previous + versions of the ``DataSet``. To permanently save your data, please use one + of the ``write`` methods, e.g. ``write_quantipy()``. diff --git a/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/03_inspection.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/03_inspection.rst.txt new file mode 100644 index 000000000..5301da6fe --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/03_inspection.rst.txt @@ -0,0 +1,355 @@ +.. toctree:: + :maxdepth: 5 + :includehidden: + +==================== +Inspecting variables +==================== + +------------------------------ +Querying and slicing case data +------------------------------ +A ``qp.DataSet`` is mimicking ``pandas``-like item access, i.e. passing a variable +name into the ``[]``-accessor will return a ``pandas.DataFrame`` view of the +case data component. That means that we can chain any ``pandas.DataFrame`` method to +the query: + +>>> ds['q9'].head() + q9 +0 99; +1 1;4; +2 98; +3 1;4; +4 99; + +There is the same support for selecting multiple variables at once: + +>>> ds[['q9', 'gender']].head() + q9 gender +0 99; 1 +1 1;4; 2 +2 98; 1 +3 1;4; 1 +4 99; 1 + +To integrate ``array`` (``masks``) variables into this behaviour, passing an +``array`` name will automatically call its item list: + +>>> ds['q6'].head() + q6_1 q6_2 q6_3 +0 1 1 1 +1 1 NaN 1 +2 1 NaN 2 +3 2 NaN 2 +4 2 10 10 + +This can be combined with the ``list``-based selection as well: + +>>> ds[['q6', 'q9', 'gender']].head() + q6_1 q6_2 q6_3 q9 gender +0 1 1 1 99; 1 +1 1 NaN 1 1;4; 2 +2 1 NaN 2 98; 1 +3 2 NaN 2 1;4; 1 +4 2 10 10 99; 1 + + +``DataSet`` case data supports row-slicing based on complex logical conditions +to inspect subsets of the data. We can use the ``take()`` with a ``Quantipy`` +logic operation naturally for this: + +>>> condition = intersection( +... [{'gender': [1]}, +... {'religion': [3]}, +... {'q9': [1, 4]}]) +>>> take = ds.take(condition) + +>>> ds[take, ['gender', 'religion', 'q9']].head() + gender religion q9 +52 1 3 1;2;4; +357 1 3 1;3;4; +671 1 3 1;3;4; +783 1 3 2;3;4; +802 1 3 4; + +.. seealso:: + Please find an overview of ``Quantipy`` logical operators and data slicing + and masking in the :doc:`docs about complex logical conditions <06_logics>`! + +---------------------------- +Variable and value existence +---------------------------- + +any, all, code_count, is_nan, var_exists, codes_in_data, is_like_numeric +variables + +______________________________________________________________________________ + +We can use ``variables()`` and ``var_exists()`` to generally test the membership +of variables inside ``DataSet``. The former is showing the list of all variables +registered inside the ``'data file'`` ``set``, the latter is checking if a variable's +``name`` is found in either the ``'columns'`` or ``'masks'`` collection. For +our example data, the variables are: + +>>> dataset.variables() + +So a test for the ``array`` ``'q5'`` should be positive: + +>>> dataset.var_exists('q5') +True + +In addition to ``Quantipy``\'s complex logic operators, the ``DataSet`` class +offers some quick case data operations for code existence tests. To return a +``pandas.Series`` of all empty rows inside a variable use ``is_nan()`` as per: + +>>> dataset.is_nan('q8').head() +0 True +1 True +2 True +3 True +4 True +Name: q8, dtype: bool + +Which we can also use to quickly check the number of missing cases... + +>>> dataset.is_nan('q8').value_counts() +True 5888 +False 2367 +Name: q8, dtype: int64 + +... as well as use the result as slicer for the ``DataSet`` case data component, +e.g. to show the non-empty rows: + +>>> slicer = dataset.is_nan('q8') +>>> dataset[~slicer, 'q8'].head() +Name: q8, dtype: int64 +7 5; +11 5; +13 1;4; +14 4;5; +23 1;4; +Name: q8, dtype: object + +Especially useful for ``delimited set`` and ``array`` data, the ``code_count()`` +method is creating the ``pandas.Series`` of response values found. If applied on +an ``array``, the result is expressed across all source item variables: + +>>> dataset.code_count('q6').value_counts() +3 5100 +2 3155 +dtype: int64 + +... which means that not all cases contain answers in all three of the array's items. + +With some basic ``pandas`` we can double-check this result: + +>>> pd.concat([dataset['q6'], dataset.code_count('q6')], axis=1).head() + q6_1 q6_2 q6_3 0 +0 1 1.0 1 3 +1 1 NaN 1 2 +2 1 NaN 2 2 +3 2 NaN 2 2 +4 2 10.0 10 3 + +``code_count()`` can optionally ignore certain codes via the ``count_only`` and +``count_not`` parameters: + +>>> q2_count = dataset.code_count('q2', count_only=[1, 2, 3]) +>>> pd.concat([dataset['q2'], q2_count], axis=1).head() + q2 0 +0 1;2;3;5; 3 +1 3;6; 1 +2 NaN 0 +3 NaN 0 +4 NaN 0 + + +Similarly, the ``any()`` and ``all()`` methods yield slicers for cases obeying +the condition that at least one / all of the provided codes are found in the +response. Again, for ``array`` variables the conditions are extended across all +the items: + +>>> dataset[dataset.all('q6', 5), 'q6'] + q6_1 q6_2 q6_3 +374 5 5.0 5 +2363 5 5.0 5 +2377 5 5.0 5 +4217 5 5.0 5 +5530 5 5.0 5 +5779 5 5.0 5 +5804 5 5.0 5 +6328 5 5.0 5 +6774 5 5.0 5 +7269 5 5.0 5 +8148 5 5.0 5 + +>>> dataset[dataset.all('q8', [1, 2, 3, 4, 96]), 'q8'] +845 1;2;3;4;5;96; +6242 1;2;3;4;96; +7321 1;2;3;4;96; +Name: q8, dtype: object + + +>>> dataset[dataset.any('q8', [1, 2, 3, 4, 96]), 'q8'].head() +13 1;4; +14 4;5; +23 1;4; +24 1;3;4; +25 1;4; +Name: q8, dtype: object + +-------------- +Variable types +-------------- + +To get a summary of the all variables grouped by type, call ``by_type()`` on +the ``DataSet``: + +>>> ds.by_type() +size: 8255 single delimited set array int float string date time N/A +0 gender q2 q5 record_number weight q8a start_time duration +1 locality q3 q7 unique_id weight_a q9a end_time +2 ethnicity q8 q6 age weight_b +3 religion q9 birth_day +4 q1 birth_month +5 q2b birth_year +6 q4 +7 q5_1 +8 q5_2 +9 q5_3 +10 q5_4 +11 q5_5 +12 q5_6 +13 q6_1 +14 q6_2 +15 q6_3 +16 q7_1 +17 q7_2 +18 q7_3 +19 q7_4 +20 q7_5 +21 q7_6 + +We can restrict the output to certain types by providing the desired ones in +the ``types`` parameter: + +>>> ds.by_type(types='delimited set') +size: 8255 delimited set +0 q2 +1 q3 +2 q8 +3 q9 + +>>> ds.by_type(types=['delimited set', 'float']) +size: 8255 delimited set float +0 q2 weight +1 q3 weight_a +2 q8 weight_b +3 q9 NaN + +In addition to that, ``DataSet`` implements the following methods +that return the corresponding variables as a ``list`` for easy iteration:: + + DataSet.singles + .delimied_sets() + .ints() + .floats() + .dates() + .strings() + .masks() + .columns() + .sets() + +>>> ds.delimited_sets() +[u'q3', u'q2', u'q9', u'q8'] + +>>> for delimited_set in ds.delimited_sets(): +... print delimited_set +q3 +q2 +q9 +q8 + +---------------------------------- +Slicing & dicing metadata objects +---------------------------------- + +Although it is possible to access a ``DataSet`` meta component via its ``_meta`` +attribute directly, the prefered way to inspect and interact with with the metadata +is to use ``DataSet`` methods. For instance, the easiest way to view the most +important meta on a variable is to use the ``meta()`` method: + +>>> ds.meta('q8') +delimited set codes texts missing +q8: Which of the following do you regularly skip? +1 1 Breakfast None +2 2 Mid-morning snacking None +3 3 Lunch None +4 4 Mid-afternoon snacking None +5 5 Dinner None +6 96 None of them None +7 98 Don't know (it varies a lot) None + +This output is extended with the ``item`` metadata if an ``array`` is passed: + +>>> ds.meta('q6') +single items item texts codes texts missing +q6: How often do you take part in any of the fo... +1 q6_1 Exercise alone 1 Once a day or more often None +2 q6_2 Join an exercise class 2 Every few days None +3 q6_3 Play any kind of team sport 3 Once a week None +4 4 Once a fortnight None +5 5 Once a month None +6 6 Once every few months None +7 7 Once every six months None +8 8 Once a year None +9 9 Less often than once a year None +10 10 Never None + +If the variable is not categorical, ``meta()`` returns simply: + +>>> ds.meta('weight_a') + float +weight_a: Weight (variant A) N/A + +``DataSet`` also provides a lot of methods to access and return the several +meta objects of a variable to make various data processing tasks easier: + +**Variable labels**: :meth:`quantipy.core.dataset.DataSet.text` + +>>> ds.text('q8', text_key=None) +Which of the following do you regularly skip? + +``values`` **object**: :meth:`quantipy.core.dataset.DataSet.values` + +>>> ds.values('gender', text_key=None) +[(1, u'Male'), (2, u'Female')] + +**Category codes**: :meth:`quantipy.core.dataset.DataSet.codes` + +>>> ds.codes('gender') +[1, 2] + +**Category labels**: :meth:`quantipy.core.dataset.DataSet.value_texts` + +>>> ds.value_texts('gender', text_key=None) +[u'Male', u'Female'] + +``items`` **object**: :meth:`quantipy.core.dataset.DataSet.items` + +>>> ds.items('q6', text_key=None) +[(u'q6_1', u'How often do you exercise alone?'), + (u'q6_2', u'How often do you take part in an exercise class?'), + (u'q6_3', u'How often do you play any kind of team sport?')] + +**Item** ``'columns'`` **sources**: :meth:`quantipy.core.dataset.DataSet.sources` + +>>> ds.sources('q6') +[u'q6_1', u'q6_2', u'q6_3'] + +**Item labels**: :meth:`quantipy.core.dataset.DataSet.item_texts` + +>>> ds.item_texts('q6', text_key=None) +[u'How often do you exercise alone?', + u'How often do you take part in an exercise class?', + u'How often do you play any kind of team sport?'] \ No newline at end of file diff --git a/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/04_editing.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/04_editing.rst.txt new file mode 100644 index 000000000..978a1cc95 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/04_editing.rst.txt @@ -0,0 +1,211 @@ +.. toctree:: + :maxdepth: 5 + :includehidden: + +================ +Editing metadata +================ + +-------------------------- +Creating meta from scratch +-------------------------- +It is very easy to add new variable metadata to a ``DataSet`` via ``add_meta()`` +which let's you create all supported variable types. Each new variable needs at +least a ``name``, ``qtype`` and ``label``. With this information a ``string``, +``int``, ``float`` or ``date`` variable can be defined, e.g.: + +>>> ds.add_meta(name='new_int', qtype='int', label='My new int variable') +>>> ds.meta('new_int') + int +new_int: My new int variable N/A + +Using the ``categories`` parameter we can create categorical variables of type +``single`` or ``delimited set``. We can provide the ``categories`` in two +different ways: + +>>> name, qtype, label = 'new_single', 'single', 'My new single variable' + +**Providing a list of category labels** (codes will be enumerated starting +from ``1``): + +>>> cats = ['Category A', 'Category B', 'Category C'] + +>>> ds.add_meta(name, qtype, label, categories=cats) +>>> ds.meta('new_single') +single codes texts missing +new_single: My new single variable +1 1 Category A None +2 2 Category B None +3 3 Category C None + +**Providing a list of tuples pairing codes and labels**: + +>>> cats = [(1, 'Category A'), (2, 'Category B'), (99, 'Category C')] + +>>> ds.add_meta(name, qtype, label, categories=cats) +>>> ds.meta('new_single') +single codes texts missing +new_single: My new single variable +1 1 Category A None +2 2 Category B None +3 99 Category C None + +.. note:: + ``add_meta()`` is preventing you from adding ill-formed or + inconsistent variable information, e.g. it is not possible to add ``categories`` + to an ``int``... + + >>> ds.add_meta('new_int', 'int', 'My new int variable', cats) + ValueError: Numerical data of type int does not accept 'categories'. + + ...and you must provide ``categories`` when trying to add categorical data: + + >>> ds.add_meta(name, 'single', label, categories=None) + ValueError: Must provide 'categories' when requesting data of type single. + +Similiar to the usage of the ``categories`` argument, ``items`` is controlling +the creation of an ``array``, i.e. specifying ``items`` is automatically +preparing the ``'masks'`` and ``'columns'`` metadata. The ``qtype`` argument +in this case always refers to the type of the corresponding ``'columns'``. + +>>> name, qtype, label = 'new_array', 'single', 'My new array variable' +>>> cats = ['Category A', 'Category B', 'Category C'] + +Again, there are two alternatives to construct the ``items`` object: + +**Providing a list of item labels** (item identifiers will be enumerated +starting from ``1``): + +>>> items = ['Item A', 'Item B', 'Item C', 'Item D'] + + +>>> ds.add_meta(name, qtype, label, cats, items=items) +>>> ds.meta('new_array') +single items item texts codes texts missing +new_array: My new array variable +1 new_array_1 Item A 1 Category A None +2 new_array_2 Item B 2 Category B None +3 new_array_3 Item C 3 Category C None +4 new_array_4 Item D + +**Providing a list of tuples pairing item identifiers and labels**: + +>>> items = [(1, 'Item A'), (2, 'Item B'), (97, 'Item C'), (98, 'Item D')] + +>>> ds.add_meta(name, qtype, label, cats, items) +>>> ds.meta('new_array') +single items item texts codes texts missing +new_array: My new array variable +1 new_array_1 Item A 1 Category A None +2 new_array_2 Item B 2 Category B None +3 new_array_97 Item C 3 Category C None +4 new_array_98 Item D + +.. note:: + For every created variable, ``add_meta()`` is also adding the relevant ``columns`` + into the ``pd.DataFrame`` case data component of the ``DataSet`` to keep + it consistent: + + >>> ds['new_array'].head() + new_array_1 new_array_2 new_array_97 new_array_98 + 0 NaN NaN NaN NaN + 1 NaN NaN NaN NaN + 2 NaN NaN NaN NaN + 3 NaN NaN NaN NaN + 4 NaN NaN NaN NaN + +-------- +Renaming +-------- +It is possible to attach new names to ``DataSet`` variables. Using the ``rename()`` +method will replace all former variable ``keys`` and other mentions inside the +metadata document and exchange the ``DataFrame`` column names. For ``array`` +variables only the ``'masks'`` name reference is updated by default -- to rename +the corresponding ``items`` a dict mapping item position number to new name can +be provided. + +>>> ds.rename(name='q8', new_name='q8_with_a_new_name') + +As mentioned, renaming a ``'masks'`` variable will leave the items untouched: + +>>> + +But we can simply provide their new names as per: + +>>> + +>>> + + +------------------------------- +Changing & adding ``text`` info +------------------------------- +All ``text``-related ``DataSet`` methods expose the ``text_key`` argument to +control to which language or context a label is added. For instance we can add +a German variable label to ``'q8'`` with ``set_variable_text()``: + +>>> ds.set_variable_text(name='q8', new_text='Das ist ein deutsches Label', text_key='de-DE') + +>>> ds.text('q8', 'en-GB') +Which of the following do you regularly skip? + +>>> ds.text('q8', 'de-DE') +Das ist ein deutsches Label + +To change the ``text`` inside the ``values`` or ``items`` metadata, we can +similarly use ``set_value_text`` and ``set_item_text()``: + +>>> + +When working with multiple language versions of the metadata, it might be required +to copy one language's ``text`` meta to another one's, for instance if there are +no fitting translations or the correct translation is missing. In such cases you +can use ``force_texts()`` to copy the meta of a source ``text_key`` (specified +in the ```copy_from`` parameter) to a target ``text_key`` (indicated via ``copy_to``). + +>>> + +>>> + +With ``clean_texts()`` you also have the option to replace specific characters, +terms or formatting tags (i.e. ``html``) from all ``text`` metadata of the +``DataSet``: + +>>> + +------------------------------- +Extending the ``values`` object +------------------------------- +We can add new category defintitons to existing ``values`` meta with the +``extend_values()`` method. As when adding full metadata for categorical +variables, new ``values`` can be generated by either providing only labels or +tuples of codes and labels. + +>>> + +While the method will never allow adding duplicated numeric values for the +categories, setting ``safe`` to ``False`` will enable you to add duplicated ``text`` +meta, i.e. ``values`` could contain both +``{'text': {'en-GB': 'No answer'}, 'value': 98}`` and +``{'text': {'en-GB': 'No answer'}, 'value': 99}``. By default, however, +the method will strictly prohibit any duplicates in the resulting ``values``. + +>>> + +-------------------------------- +Reordering the ``values`` object +-------------------------------- + + +---------------------------- +Removing ``DataSet`` objects +---------------------------- + + + + + + + + + diff --git a/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/05_transforming.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/05_transforming.rst.txt new file mode 100644 index 000000000..cd44e78e1 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/05_transforming.rst.txt @@ -0,0 +1,373 @@ +====================== +Transforming variables +====================== + +.. toctree:: + :maxdepth: 5 + :includehidden: + +------- +Copying +------- + +It's often recommended to draw a clean copy of a variable before starting to +editing its meta or case data. With ``copy()`` you can add a copy to the +``DataSet`` that is identical to the original in all respects but its name. By +default, the copy's name will be suffixed with ``'_rec'``, but you can apply a +custom suffix by providing it via the ``suffix`` argument (leaving out the +``'_'`` which is added automatically): + +>>> ds.copy('q3') +>>> ds.copy('q3', suffix='version2') + +>>> ds.delimited_sets +[u'q3', u'q2', u'q9', u'q8', u'q3_rec', u'q3_version2'] + +Querying the ``DataSet``, we can see that all three version are looking identical: + +>>> ds[['q3', 'q3_rec', 'q3_version2']].head() + q3 q3_rec q3_version2 +0 1;2;3; 1;2;3; 1;2;3; +1 1;2;3; 1;2;3; 1;2;3; +2 1;2;3; 1;2;3; 1;2;3; +3 1;3; 1;3; 1;3; +4 2; 2; 2; + +We can, however, prevent copying the case data and simply add an "empty" copy +of the variable by passing ``copy_data=False``: + +>>> ds.copy('q3', suffix='no_data', copy_data=False) + +>>> ds[['q3', 'q3_rec', 'q3_version2', 'q3_no_data']].head() + q3 q3_rec q3_version2 q3_no_data +0 1;2;3; 1;2;3; 1;2;3; NaN +1 1;2;3; 1;2;3; 1;2;3; NaN +2 1;2;3; 1;2;3; 1;2;3; NaN +3 1;3; 1;3; 1;3; NaN +4 2; 2; 2; NaN + +If we wanted to only copy a subset of the case data, we could also use a +:doc:`logical slicer <06_logics>` and supply it in the ``copy()`` operation's +``slicer`` parameter: + +>>> slicer = {'gender': [1]} +>>> ds.copy('q3', suffix='only_men', copy_data=True, slicer=slicer) + +>>> ds[['q3', 'gender', 'q3_only_men']].head() + q3 gender q3_only_men +0 1;2;3; 1 1;2;3; +1 1;2;3; 2 NaN +2 1;2;3; 1 1;2;3; +3 1;3; 1 1;3; +4 2; 1 2; + +----------------------- +Inplace type conversion +----------------------- + +You can change the characteristics of existing ``DataSet`` variables by +converting from one ``type`` to another. Conversions happen ``inplace``, i.e. +no copy of the variable is taken prior to the operation. Therefore, you might +want to take a ``DataSet.copy()`` before using the ``convert(name, to)`` +method. + +Conversions need to modify both the ``meta`` and ``data`` component of the +``DataSet`` and are limited to transformations that keep the original and new +state of a variable consistent. The following conversions are currently +supported: + ++--------------------------+-----------------+------------------------+--------------+----------------+-----------------+ +| ``name`` (from-``type``) | ``to='single'`` | ``to='delimited set'`` | ``to='int'`` | ``to='float'`` | ``to='string'`` | ++--------------------------+-----------------+------------------------+--------------+----------------+-----------------+ +| ``'single'`` | [X] | X | X | X | X | ++--------------------------+-----------------+------------------------+--------------+----------------+-----------------+ +| ``'delimited set'`` | | [X] | | | | ++--------------------------+-----------------+------------------------+--------------+----------------+-----------------+ +| ``'int'`` | X | | [X] | X | X | ++--------------------------+-----------------+------------------------+--------------+----------------+-----------------+ +| ``'float'`` | | | | [X] | X | ++--------------------------+-----------------+------------------------+--------------+----------------+-----------------+ +| ``'string'`` | X | | X* | X* | [X] | ++--------------------------+-----------------+------------------------+--------------+----------------+-----------------+ +| ``'date'`` | X | | | | X | ++--------------------------+-----------------+------------------------+--------------+----------------+-----------------+ + +\* *If all values of the variable are numerical, i.e.* ``DataSet.is_like_numeric()`` *returns* ``True``. + +Each of these conversions will rebuild the variable meta data to match the ``to`` +type. This means, that for instance a variable that is ``single`` will lose +its ``values`` object when transforming to ``int``, while the reverse operation +will create a ``values`` object that categorizes the unqiue numeric codes found in the +case data with their ``str`` representation as ``text`` meta. Consider the +variables ``q1`` (``single``) and ``age`` (``int``): + +**From type** ``single`` **to** ``int``: + +>>> ds.meta('q1') +single codes texts missing +q1: What is your main fitness activity? +1 1 Swimming None +2 2 Running/jogging None +3 3 Lifting weights None +4 4 Aerobics None +5 5 Yoga None +6 6 Pilates None +7 7 Football (soccer) None +8 8 Basketball None +9 9 Hockey None +10 96 Other None +11 98 I regularly change my fitness activity None +12 99 Not applicable - I don't exercise None + +>>> ds.convert('q1', to='int') +>>> ds.meta('q1') + int +q1: What is your main fitness activity? N/A + + +**From type** ``int`` **to** ``single``: + +>>> ds.meta('age') + int +age: Age N/A + +>>> ds.convert('age', to='single') +>>> ds.meta('age') +single codes texts missing +age: Age +1 19 19 None +2 20 20 None +3 21 21 None +4 22 22 None +5 23 23 None +6 24 24 None +7 25 25 None +8 26 26 None +9 27 27 None +10 28 28 None +11 29 29 None +12 30 30 None +13 31 31 None +14 32 32 None +15 33 33 None +16 34 34 None +17 35 35 None +18 36 36 None +19 37 37 None +20 38 38 None +21 39 39 None +22 40 40 None +23 41 41 None +24 42 42 None +25 43 43 None +26 44 44 None +27 45 45 None +28 46 46 None +29 47 47 None +30 48 48 None +31 49 49 None + + +-------------------------- +Banding and categorization +-------------------------- +In contrast to ``convert()``, the ``categorize()`` method creates a new +variable of type ``single``, acting as a short-hand for creating a renamed copy +and then type-transforming it. Therefore, it lets you quickly categorize +the unique values of a ``text``, ``int`` or ``date`` variable, storing +``values`` meta in the form of ``{'text': {'en-GB': str(1)}, 'value': 1}``. + +>>> + +Flexible banding of numeric data is provided thorugh ``DataSet.band()``: If a +variable is banded, it will standardly be added to the ``DataSet`` via the +original's name suffixed with ``'banded'``, e.g. ``'age_banded'``, keeping +the originating variables ``text`` label. The ``new_name`` and ``label`` +parameters can be used to create custom variable names and labels. The banding +of the incoming data is controlled with the ``bands`` argument that expects a +list containing ``int``, ``tuples`` or ``dict``, where each type is used for a +different kind of group definition. + +**Banding with** ``int`` **and** ``tuple``: + +- Use an ``int`` to make a band of only one value +- Use a ``tuple`` to indicate (inclusive) group limits +- ``values`` ``text`` meta is infered +- Example: ``[0, (1, 10), (11, 14), 15, (16, 25)]`` + +**Banding with** ``dict``: + +- The dict ``key`` will dicate the group's ``text`` label meta +- The dict ``value`` can pick up an ``int`` / ``tuple`` (see above) +- Example: ``[{'A': 0}, {'B': (1, 10)}, {'C': (11, 14)}, {'D': 15}, {'E': (16, 25)}]`` +- Mixing allowed: ``[0, {'A': (1, 10)}, (11, 14), 15, {'B': (16, 25)}]`` + +For instance, we could band ``'age'`` into a new variable called ``'grouped_age'`` +with ``bands`` being: + +>>> bands = [{'Younger than 35': (19, 34)}, +... (35, 39), +... {'Exactly 40': 40}, +... 41, +... (42, 60)] + +>>> ds.band(name='age', bands=bands, new_name='grouped_age', label=None) + +>>> ds.meta('grouped_age') +single codes texts missing +grouped_age: Age +1 1 Younger than 35 None +2 2 35-39 None +3 3 Exactly 40 None +4 4 41 None +5 5 42-60 None + +>>> ds.crosstab('age', 'grouped_age') +Question grouped_age. Age +Values All Younger than 35 35-39 Exactly 40 41 42-60 +Question Values +age. Age All 8255 4308 1295 281 261 2110 + 19 245 245 0 0 0 0 + 20 277 277 0 0 0 0 + 21 270 270 0 0 0 0 + 22 323 323 0 0 0 0 + 23 272 272 0 0 0 0 + 24 263 263 0 0 0 0 + 25 246 246 0 0 0 0 + 26 252 252 0 0 0 0 + 27 260 260 0 0 0 0 + 28 287 287 0 0 0 0 + 29 270 270 0 0 0 0 + 30 271 271 0 0 0 0 + 31 264 264 0 0 0 0 + 32 287 287 0 0 0 0 + 33 246 246 0 0 0 0 + 34 275 275 0 0 0 0 + 35 258 0 258 0 0 0 + 36 236 0 236 0 0 0 + 37 252 0 252 0 0 0 + 38 291 0 291 0 0 0 + 39 258 0 258 0 0 0 + 40 281 0 0 281 0 0 + 41 261 0 0 0 261 0 + 42 290 0 0 0 0 290 + 43 267 0 0 0 0 267 + 44 261 0 0 0 0 261 + 45 257 0 0 0 0 257 + 46 259 0 0 0 0 259 + 47 243 0 0 0 0 243 + 48 271 0 0 0 0 271 + 49 262 0 0 0 0 262 + +--------------------- +Array transformations +--------------------- + +**Transposing arrays** + +``DataSet`` offers tools to simplify common ``array`` variable operations. +You can switch the structure of ``items`` vs. ``values`` by producing the one +from the other using ``transpose()``. The transposition of an array will always +result in ``items`` that have the ``delimited set`` type in the corresponding +``'columns'`` metadata. That is because the transposed array is collecting +what former items have been assignd per former value: + +>>> ds.transpose('q5') + +*Original* + +>>> ds['q5'].head() + q5_1 q5_2 q5_3 q5_4 q5_5 q5_6 +0 2 2 2 2 1 2 +1 5 5 3 3 3 5 +2 5 98 5 5 1 5 +3 5 5 1 5 3 5 +4 98 98 98 98 98 98 + + +>>> ds.meta('q5') +single items item texts codes texts missing +q5: How likely are you to do each of the follow... +1 q5_1 Surfing 1 I would refuse if asked None +2 q5_2 Snowboarding 2 Very unlikely None +3 q5_3 Kite boarding 3 Probably wouldn't None +4 q5_4 Parachuting 4 Probably would if asked None +5 q5_5 Cave diving 5 Very likely None +6 q5_6 Windsurfing 97 I'm already planning to None +7 98 Don't know None + +*Transposition* + +>>> ds['q5_trans'].head() + q5_trans_1 q5_trans_2 q5_trans_3 q5_trans_4 q5_trans_5 q5_trans_97 q5_trans_98 +0 5; 1;2;3;4;6; NaN NaN NaN NaN NaN +1 NaN NaN 3;4;5; NaN 1;2;6; NaN NaN +2 5; NaN NaN NaN 1;3;4;6; NaN 2; +3 3; NaN 5; NaN 1;2;4;6; NaN NaN +4 NaN NaN NaN NaN NaN NaN 1;2;3;4;5;6; + +>>> ds.meta('q5_trans') +delimited set items item texts codes texts missing +q5_trans: How likely are you to do each of the ... +1 q5_trans_1 I would refuse if asked 1 Surfing None +2 q5_trans_2 Very unlikely 2 Snowboarding None +3 q5_trans_3 Probably wouldn't 3 Kite boarding None +4 q5_trans_4 Probably would if asked 4 Parachuting None +5 q5_trans_5 Very likely 5 Cave diving None +6 q5_trans_97 I'm already planning to 6 Windsurfing None +7 q5_trans_98 Don't know + +The method's ``ignore_items`` and ``ignore_values`` arguments can pick up +``items`` (indicated by their order number) and ``values`` to leave aside +during the transposition. + +*Ignoring items* + +The new ``values`` meta's numerical codes will always be enumerated from 1 to +the number of valid items for the transposition, so ignoring items 2, 3 and 4 +will lead to: + +>>> ds.transpose('q5', ignore_items=[2, 3, 4]) + +>>> ds['q5_trans'].head(1) + q5_trans_1 q5_trans_2 q5_trans_3 q5_trans_4 q5_trans_5 q5_trans_97 q5_trans_98 +0 2; 1;3; NaN NaN NaN NaN NaN + +>>> ds.values('q5_trans') +[(1, 'Surfing'), (2, 'Cave diving'), (3, 'Windsurfing')] + +*Ignoring values* + +>>> ds.transpose('q5', ignore_values=[1, 97]) + +>>> ds['q5_trans'].head(1) + q5_trans_2 q5_trans_3 q5_trans_4 q5_trans_5 q5_trans_98 +0 1;2;3;4;6; NaN NaN NaN NaN + +>>> ds.items('q5_trans') +[('q5_trans_2', u'Very unlikely'), + ('q5_trans_3', u"Probably wouldn't"), + ('q5_trans_4', u'Probably would if asked'), + ('q5_trans_5', u'Very likely'), + ('q5_trans_98', u"Don't know")] + +*Ignoring both items and values* + +>>> ds.transpose('q5', ignore_items=[2, 3, 4], ignore_values=[1, 97]) + +>>> ds['q5_trans'].head(1) + q5_trans_2 q5_trans_3 q5_trans_4 q5_trans_5 q5_trans_98 +0 1;3; NaN NaN NaN NaN + +>>> ds.meta('q5_trans') +delimited set items item texts codes texts missing +q5_trans: How likely are you to do each of the ... +1 q5_trans_2 Very unlikely 1 Surfing None +2 q5_trans_3 Probably wouldn't 2 Cave diving None +3 q5_trans_4 Probably would if asked 3 Windsurfing None +4 q5_trans_5 Very likely +5 q5_trans_98 Don't know + +**Flatten item answers** + +- ``flatten()`` \ No newline at end of file diff --git a/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/06_logics.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/06_logics.rst.txt new file mode 100644 index 000000000..45f601c45 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/06_logics.rst.txt @@ -0,0 +1,165 @@ +.. toctree:: + :maxdepth: 5 + :includehidden: + +======================= +Logic and set operaters +======================= + +------ +Ranges +------ +The ``frange()`` function takes a string of abbreviated ranges, possibly delimited +by a comma (or some other character) and extrapolates its full, +unabbreviated list of ints. + +>>> from quantipy.core.tools.dp.prep import frange + +**Basic range**: + +>>> frange('1-5') +[1, 2, 3, 4, 5] + +**Range in reverse**: + +>>> frange('15-11') +[15, 14, 13, 12, 11] + +**Combination**: + +>>> frange('1-5,7,9,15-11') +[1, 2, 3, 4, 5, 7, 9, 15, 14, 13, 12, 11] + +**May include spaces for clarity**: + +>>> frange('1-5, 7, 9, 15-11') +[1, 2, 3, 4, 5, 7, 9, 15, 14, 13, 12, 11] + +------------- +Complex logic +------------- +Multiple conditions can be combined using ``union`` or ``intersection`` set +statements. Logical mappers can be arbitrarily nested as long as they are +well-formed. + +``union`` +--------- +``union`` takes a list of logical conditions that will be treated with +**or** logic. + +Where **any** of logic_A, logic_B **or** logic_C are ``True``: + +>>> union([logic_A, logic_B, logic_C]) + +``intersection`` +---------------- +``intersection`` takes a list of conditions that will be +treated with **and** logic. + +Where **all** of logic_A, logic_B **and** logic_C are ``True``: + +>>> intersection([logic_A, logic_B, logic_C]) + +"List" logic +------------ +Instead of using the verbose ``has_any`` operator, we can express simple, non-nested +*or* logics simply as a list of codes. For example ``{"q1_1": [1, 2]}`` is an +example of list-logic, where ``[1, 2]`` will be interpreted as ``has_any([1, 2])``, +meaning if **q1_1** has any of the values **1** or **2**. + +``q1_1`` has any of the responses 1, 2 or 3: + +>>> l = {"q1_1": [1, 2, 3]} + + +``has_any`` +----------- +``q1_1`` has any of the responses 1, 2 or 3: + +>>> l = {"q1_1": has_any([1, 2, 3])} + +``q1_1`` has any of the responses 1, 2 or 3 and no others: + +>>> l = {"q1_1": has_any([1, 2, 3], exclusive=True)} + + +``not_any`` +----------- +``q1_1`` doesn't have any of the responses 1, 2 or 3: + +>>> l = {"q1_1": not_any([1, 2, 3])} + +``q1_1`` doesn't have any of the responses 1, 2 or 3 but has some others: + +>>> l = {"q1_1": not_any([1, 2, 3], exclusive=True)} + +``has_all`` +----------- +``q1_1`` has all of the responses 1, 2 and 3: + +>>> l = {"q1_1": has_all([1, 2, 3])} + +``q1_1`` has all of the responses 1, 2 and 3 and no others: + +>>> l = {"q1_1": has_all([1, 2, 3], exclusive=True)} + +``not_all`` +----------- +``q1_1`` doesn't have all of the responses 1, 2 and 3: + +>>> l = {"q1_1": not_all([1, 2, 3])} + +``q1_1`` doesn't have all of the responses 1, 2 and 3 but has some others: + +>>> l = {"q1_1": not_all([1, 2, 3], exclusive=True)} + +``has_count`` +------------- + +``q1_1`` has exactly 2 responses: + +>>> l = {"q1_1": has_count(2)} + +``q1_1`` has 1, 2 or 3 responses: + +>>> l = {"q1_1": has_count([1, 3])} + +``q1_1`` has 1 or more responses: + +>>> l = {"q1_1": has_count([is_ge(1)])} + +``q1_1`` has 1, 2 or 3 responses from the response group 5, 6, 7, 8 or 9: + +>>> l = {"q1_1": has_count([1, 3, [5, 6, 7, 8, 9]])} + +``q1_1`` has 1 or more responses from the response group 5, 6, 7, 8 or 9: + +>>> l = {"q1_1": has_count([is_ge(1), [5, 6, 7, 8, 9]])} + +``not_count`` +------------- +``q1_1`` doesn't have exactly 2 responses: + +>>> l = {"q1_1": not_count(2)} + +``q1_1`` doesn't have 1, 2 or 3 responses: + +>>> l = {"q1_1": not_count([1, 3])} + +``q1_1`` doesn't have 1 or more responses: + +>>> l = {"q1_1": not_count([is_ge(1)])} + +``q1_1`` doesn't have 1, 2 or 3 responses from the response group 5, 6, 7, 8 or 9: + +>>> l = {"q1_1": not_count([1, 3, [5, 6, 7, 8, 9]])} + +``q1_1`` doesn't have 1 or more responses from the response group 5, 6, 7, 8 or 9: + +>>> l = {"q1_1": not_count([is_ge(1), [5, 6, 7, 8, 9]])} + +---------------------------------- +Boolean slicers and code existence +---------------------------------- +``any()``, ``all()`` +``code_count()``, ``is_nan()`` diff --git a/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/07_custom_recoding.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/07_custom_recoding.rst.txt new file mode 100644 index 000000000..71f666d18 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/07_custom_recoding.rst.txt @@ -0,0 +1,632 @@ +.. toctree:: + :maxdepth: 5 + :includehidden: + +==================== +Custom data recoding +==================== + +--------------------------------- +The ``recode()`` method in detail +--------------------------------- +This function takes a mapper of ``{key: logic}`` entries and injects the +key into the target column where its paired logic is True. The logic +may be arbitrarily complex and may refer to any other variable or +variables in data. Where a pre-existing column has been used to +start the recode, the injected values can replace or be appended to +any data found there to begin with. Note that this function does +not edit the target column, it returns a recoded copy of the target +column. The recoded data will always comply with the column type +indicated for the target column according to the meta. + + +:method: ``recode(target, mapper, default=None, append=False, + intersect=None, initialize=None, fillna=None, inplace=True)`` + + +``target`` +---------- + +``target`` controls which column meta should be used to control the +result of the recode operation. This is important because you cannot +recode multiple responses into a 'single'-typed column. + +The ``target`` column **must** already exist in meta. + +The ``recode`` function is effectively a request to return a copy of +the ``target`` column, recoded as instructed. ``recode`` does not +edit the ``target`` column in place, it returns a recoded copy of it. + +If the ``target`` column does not already exist in ``data`` then a new +series, named accordingly and initialized with ``np.NaN``, will begin +the recode. + +Return a recoded version of the column ``radio_stations_xb`` edited +based on the given mapper: + +>>> recoded = recode( +... meta, data, +... target='radio_stations_xb', +... mapper=mapper +... ) + +By default, recoded data resulting from the the mapper will replace any +data already sitting in the target column (on a cell-by-cell basis). + +``mapper`` +---------- + +A mapper is a dict of ``{value: logic}`` entries where value represents +the data that will be injected for cases where the logic is True. + +Here's a simplified example of what a mapper looks like: + +>>> mapper = { +... 1: logic_A, +... 2: logic_B, +... 3: logic_C, +... } + +1 will be generated where ``logic_A`` is ``True``, 2 where ``logic_B`` is +``True`` and 3 where ``logic_C`` is ``True``. + +The recode function, by referencing the type indicated by the meta, +will manage the complications involved in single vs delimited set +data. + +>>> mapper = { +... 901: {'radio_stations': frange('1-13')}, +... 902: {'radio_stations': frange('14-20')}, +... 903: {'radio_stations': frange('21-25')} +... } + +This means: inject 901 if the column ``radio_stations`` has any of the +values 1-13, 902 where ``radio_stations`` has any of the values 14-20 +and 903 where ``radio_stations`` has any of the values 21-25. + +``default`` +----------- + +If you had lots of values to generate from the same reference column +(say most/all of them were based on ``radio_stations``) then we can +omit the wildcard logic format and use recode's default parameter. + +>>> recoded = recode( +... meta, data, +... target='radio_stations_xb', +... mapper={ +... 901: frange('1-13'), +... 902: frange('14-20'), +... 903: frange('21-25') +... }, +... default='radio_stations' +... ) + +This means, all unkeyed logic will default to be keyed to +``radio_stations``. In this case the three codes 901, 902 and 903 will +be generated based on the data found in ``radio_stations``. + +You can combine this with reference to other columns, but you can only +provide one default column. + +>>> recoded = recode( +... meta, data, +... target='radio_stations_xb', +... mapper={ +... 901: frange('1-13'), +... 902: frange('14-20'), +... 903: frange('21-25'), +... 904: {'age': frange('18-34')} +... }, +... default='radio_stations' +... ) + +Given that logic can be arbitrarily complicated, mappers can be as +well. You'll see an example of a mapper that recodes a segmentation +in **Example 4**, below. + +``append`` +---------- + +If you want the recoded data to be appended to whatever may +already be in the target column (this is only applicable for 'delimited +set'-typed columns), then you should use the append parameter. + +>>> recoded = recode( +... meta, data, +... target='radio_stations_xb', +... mapper=mapper, +... append=True +... ) + +The precise behaviour of the append parameter can be seen in the +following examples. + +Given the following data: + +>>> df['radio_stations_xb'] +1 6;7;9;13; +2 97; +3 97; +4 13;16;18; +5 2;6; +Name: radio_stations_xb, dtype: object + +We generate a recoded value of 901 if any of the values 1-13 are +found. With the default ``append=False`` behaviour we will return the +following: + +>>> target = 'radio_stations_xb' +>>> recode(meta, data, target, mapper) +1 901; +2 97; +3 97; +4 901; +5 901; +Name: radio_stations_xb, dtype: object + +However, if we instead use ``append=True``, we will return the following: + +>>> target = 'radio_stations_xb' +>>> recode(meta, data, target, mapper, append=True) +1 6;7;9;13;901; +2 97; +3 97; +4 13;16;18;901; +5 2;6;901; +Name: radio_stations_xb, dtype: object + +``intersect`` +------------- + +One way to help simplify complex logical conditions, especially when +they are in some way repetitive, is to use ``intersect``, which +accepts any logical statement and forces every condition in the mapper +to become the intersection of both it and the intersect condition. + +For example, we could limit our recode to males by giving a logical +condition to that effect to ``intersect``: + +>>> recoded = recode( +... meta, data, +... target='radio_stations_xb', +... mapper={ +... 901: frange('1-13'), +... 902: frange('14-20'), +... 903: frange('21-25'), +... 904: {'age': frange('18-34')} +... }, +... default='radio_stations', +... intersect={'gender': [1]} +... ) + +``initialize`` +-------------- + +You may also ``initialize`` your copy of the target column as part of your +recode operation. You can ``initalize`` with either np.NaN (to overwrite +anything that may already be there when your recode begins) or by naming +another column. When you name another column a copy of the data from that +column is used to initialize your recode. + +Initialization occurs **before** your recode. + +>>> recoded = recode( +... meta, data, +... target='radio_stations_xb', +... mapper={ +... 901: frange('1-13'), +... 902: frange('14-20'), +... 903: frange('21-25'), +... 904: {'age': frange('18-34')} +... }, +... default='radio_stations', +... initialize=np.NaN +... ) + +>>> recoded = recode( +... meta, data, +... target='radio_stations_xb', +... mapper={ +... 901: frange('1-13'), +... 902: frange('14-20'), +... 903: frange('21-25'), +... 904: {'age': frange('18-34')} +... }, +... default='radio_stations', +... initialize='radio_stations' +... ) + +``fillna`` +---------- + +You may also provide a ``fillna`` value that will be used as per +``pd.Series.fillna()`` **after** the recode has been performed. + +>>> recoded = recode( +... meta, data, +... target='radio_stations_xb', +... mapper={ +... 901: frange('1-13'), +... 902: frange('14-20'), +... 903: frange('21-25'), +... 904: {'age': frange('18-34')} +... }, +... default='radio_stations', +... initialize=np.NaN, +... fillna=99 +... ) + +---------------------- +Custom recode examples +---------------------- + +Building a net code +------------------- +Here's an example of copying an existing question and recoding onto it a +net code. + +Create the new metadata: + +>>> meta['columns']['radio_stations_xb'] = copy.copy( +... meta['columns']['radio_stations'] +... ) +>>> meta['columns']['radio_stations_xb']['values'].append( +... { +... "value": 901, +... "text": {"en-GB": "NET: Listened to radio in past 30 days"} +... } +... ) + +Initialize the new column. In this case we're starting with a copy of +the ``radio_stations`` column: + +>>> data['radio_stations_xb'] = data['radio_stations'].copy() + +Recode the new column by appending the code 901 to it as indicated +by the mapper: + +>>> data['radio_stations_xb'] = recode( +... meta, data, +... target='radio_stations_xb', +... mapper={ +... 901: {'radio_stations': frange('1-23, 92, 94, 141')} +... }, +... append=True +... ) + +Check the result: + +>>> data[['radio_stations', 'radio_stations_xb']].head(20) + radio_stations radio_stations_cb +0 5; 5;901; +1 97; 97; +2 97; 97; +3 97; 97; +4 97; 97; +5 4; 4;901; +6 11; 11;901; +7 4; 4;901; +8 97; 97; +9 97; 97; +10 97; 97; +11 92; 92;901; +12 97; 97; +13 1;13;17; 1;13;17;901; +14 6; 6;901; +15 1;5;6;10; 1;5;6;10;901; +16 6; 6;901; +17 2;4;16; 2;4;16;901; +18 6;10; 6;10;901; +19 6; 6;901; + +Create-and-fill +--------------- + +Here's an example where the value 1 is generated based on some logic +and then all remaining cases are given the value 2 using the +pandas.Series.fillna() method. + +Create the new metadata + +>>> meta['columns']['age_xb'] = { +... 'type': 'single', +... 'text': {'en-GB': 'Age'}, +... 'values': [ +... {'value': 1, 'text': {'en-GB': '16-25'}}, +... {'value': 2, 'text': {'en-GB': 'Others'}} +... ] +... } + +Initialize the new column: + +>>> data['age_xb'] = np.NaN + +Recode the new column: + +>>> data['age_xb'] = recode( +... meta, data, +... target='age_xb', +... mapper={ +... 1: {'age': frange('16-40')} +... } +... ) + +Fill all cases that are still empty with the value 2: + +>>> data['age_xb'].fillna(2, inplace=True) + +Check the result: + +>>> data[['age', 'age_xb']].head(20) + age age_grp_rc +0 22 1 +1 68 2 +2 32 1 +3 44 2 +4 33 1 +5 52 2 +6 54 2 +7 44 2 +8 62 2 +9 49 2 +10 64 2 +11 73 2 +12 43 2 +13 28 1 +14 66 2 +15 39 1 +16 51 2 +17 50 2 +18 77 2 +19 42 2 + +Numerical banding +----------------- + +Here's a typical example of recoding age into custom bands. + +In this case we're using list comprehension to generate the first ten +values objects and then concatenate that with a final '65+' value object +which doesn't folow the same label format. + +Create the new metadata: + +>>> meta['columns']['age_xb_1'] = { +... 'type': 'single', +... 'text': {'en-GB': 'Age'}, +... 'values': [ +... { +... 'value': i, +... 'text': {'en-GB': '{}-{}'.format(r[0], r[1])} +... } +... for i, r in enumerate( +... [ +... [18, 20], +... [21, 25], [26, 30], +... [31, 35], [36, 40], +... [41, 45], [46, 50], +... [51, 55], [56, 60], +... [61, 65] +... ], +... start=1 +... ) +... ] + [ +... { +... 'value': 11, +... 'text': {'en-GB': '65+'} +... } +... ] +... } + +Initialize the new column: + +>>> data['age_xb_1'] = np.NaN + +Recode the new column: + +>>> data['age_xb_1'] = recode( +... meta, data, +... target='age_xb_1', +... mapper={ +... 1: frange('18-20'), +... 2: frange('21-25'), +... 3: frange('26-30'), +... 4: frange('31-35'), +... 5: frange('36-40'), +... 6: frange('41-45'), +... 7: frange('46-50'), +... 8: frange('51-55'), +... 9: frange('56-60'), +... 10: frange('61-65'), +... 11: frange('66-99') +... }, +... default='age' +... ) + +Check the result: + +>>> data[['age', 'age_xb_1']].head(20) + age age_cb +0 22 2 +1 68 11 +2 32 4 +3 44 6 +4 33 4 +5 52 8 +6 54 8 +7 44 6 +8 62 10 +9 49 7 +10 64 10 +11 73 11 +12 43 6 +13 28 3 +14 66 11 +15 39 5 +16 51 8 +17 50 7 +18 77 11 +19 42 6 + +Complicated segmentation +------------------------ + +Here's an example of using a complicated, nested series of logic +statements to recode an obscure segmentation. + +The segemenation was given with the following definition: + +**1 - Self-directed:** + +- If q1_1 in [1,2] and q1_2 in [1,2] and q1_3 in [3,4,5] + +**2 - Validators:** + +- If q1_1 in [1,2] and q1_2 in [1,2] and q1_3 in [1,2] + +**3 - Delegators:** + +- If (q1_1 in [3,4,5] and q1_2 in [3,4,5] and q1_3 in [1,2]) +- Or (q1_1 in [3,4,5] and q1_2 in [1,2] and q1_3 in [1,2]) +- Or (q1_1 in [1,2] and q1_2 in [3,4,5] and q1_3 in [1,2]) + +**4 - Avoiders:** + +- If (q1_1 in [3,4,5] and q1_2 in [3,4,5] and q1_3 in [3,4,5]) +- Or (q1_1 in [3,4,5] and q1_2 in [1,2] and q1_3 in [3,4,5]) +- Or (q1_1 in [1,2] and q1_2 in [3,4,5] and q1_3 in [3,4,5]) + +**5 - Others:** + +- Everyone else. + +Create the new metadata: + +>>> meta['columns']['segments'] = { +... 'type': 'single', +... 'text': {'en-GB': 'Segments'}, +... 'values': [ +... {'value': 1, 'text': {'en-GB': 'Self-directed'}}, +... {'value': 2, 'text': {'en-GB': 'Validators'}}, +... {'value': 3, 'text': {'en-GB': 'Delegators'}}, +... {'value': 4, 'text': {'en-GB': 'Avoiders'}}, +... {'value': 5, 'text': {'en-GB': 'Other'}}, +... ] +... } + +Initialize the new column? + +>>> data['segments'] = np.NaN + +Create the mapper separately, since it's pretty massive! + +See the **Complex logic** section for more information and examples +related to the use of ``union`` and ``intersection``. + +>>> mapper = { +... 1: intersection([ +... {"q1_1": [1, 2]}, +... {"q1_2": [1, 2]}, +... {"q1_3": [3, 4, 5]} +... ]), +... 2: intersection([ +... {"q1_1": [1, 2]}, +... {"q1_2": [1, 2]}, +... {"q1_3": [1, 2]} +... ]), +... 3: union([ +... intersection([ +... {"q1_1": [3, 4, 5]}, +... {"q1_2": [3, 4, 5]}, +... {"q1_3": [1, 2]} +... ]), +... intersection([ +... {"q1_1": [3, 4, 5]}, +... {"q1_2": [1, 2]}, +... {"q1_3": [1, 2]} +... ]), +... intersection([ +... {"q1_1": [1, 2]}, +... {"q1_2": [3, 4, 5]}, +... {"q1_3": [1, 2]} +... ]), +... ]), +... 4: union([ +... intersection([ +... {"q1_1": [3, 4, 5]}, +... {"q1_2": [3, 4, 5]}, +... {"q1_3": [3, 4, 5]} +... ]), +... intersection([ +... {"q1_1": [3, 4, 5]}, +... {"q1_2": [1, 2]}, +... {"q1_3": [3, 4, 5]} +... ]), +... intersection([ +... {"q1_1": [1, 2]}, +... {"q1_2": [3, 4, 5]}, +... {"q1_3": [3, 4, 5]} +... ]) +... ]) +... } + +Recode the new column: + +>>> data['segments'] = recode( +... meta, data, +... target='segments', +... mapper=mapper +... ) + +.. note:: + Anything not at the top level of the mapper will not benefit from using + the ``default`` parameter of the recode function. In this case, for example, + saying ``default='q1_1'`` would not have helped. Everything in a nested level + of the mapper, including anything in a ``union`` or ``intersection`` list, + must use the explicit dict form ``{"q1_1": [1, 2]}``. + +Fill all cases that are still empty with the value 5: + +>>> data['segments'].fillna(5, inplace=True) + +Check the result: + +>>> data[['q1_1', 'q1_2', 'q1_3', 'segments']].head(20) + q1_1 q1_2 q1_3 segments +0 3 3 3 4 +1 3 3 3 4 +2 1 1 3 1 +3 1 1 2 2 +4 2 2 2 2 +5 1 1 5 1 +6 2 3 2 3 +7 2 2 3 1 +8 1 1 4 1 +9 3 3 3 4 +10 3 3 4 4 +11 2 2 4 1 +12 1 1 5 1 +13 2 2 4 1 +14 1 1 1 2 +15 2 2 4 1 +16 2 2 3 1 +17 1 1 5 1 +18 5 5 1 3 +19 1 1 4 1 + + +Variable creation +----------------- + +Adding derived variables +------------------------ + +Interlocking variables +---------------------- + +Condition-based code removal +---------------------------- + + + diff --git a/docs/API/_build/html/_sources/sites/lib_doc/engine/00_overview.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/engine/00_overview.rst.txt new file mode 100644 index 000000000..ba0714fd0 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/engine/00_overview.rst.txt @@ -0,0 +1,12 @@ +---------------------- +Analysis & aggregation +---------------------- + +.. toctree:: + :maxdepth: 5 + :includehidden: + + 01_links_stacks + 02_quantity + 03_test + 04_agg_methods diff --git a/docs/API/_build/html/_sources/sites/lib_doc/engine/01_links_stacks.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/engine/01_links_stacks.rst.txt new file mode 100644 index 000000000..b29290cb6 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/engine/01_links_stacks.rst.txt @@ -0,0 +1,131 @@ +.. toctree:: + :maxdepth: 5 + :includehidden: + +======================= +Collecting aggregations +======================= + +All computational results are collected in a so-called ``qp.Stack`` object which +acts as a container for large amount of aggregations in form of ``qp.Link``\s. + +---------------------- +What is a ``qp.Link?`` +---------------------- + +A ``qp.Link`` is defined by four attributes that make it unique and set how it is +stored in a ``qp.Stack``. These four attributes are ``data_key``, ``filter``, +``x`` (downbreak) and ``y`` (crossbreak), which are positioned in a ``qp.Stack`` +similar to a tree diagram: + + * Each ``Stack`` can have various ``data_key``\s. + * Each ``data_key`` can have various ``filter``\s. + * Each ``filter`` can have various ``x``\s. + * Each ``x`` can have various ``y``\s. + +Consequently ``qp.Stack[dk][filter][x][y]`` is one ``qp.Link`` that can be added +using ``add_link(self, data_keys=None, filters=['no_filter'], x=None, y=None, ...)`` + +``qp.Link``\s are are storing different ``qp.View``\s (frequencies, statistics, +etc. - all kinds of computations) that are applied on the same four data attributes. + +------------------------- +Populating a ``qp.Stack`` +------------------------- + +A ``qp.Stack`` is able to cope with a large amount of aggregations, so it is +impractical to add ``Link``\s one by one with repeated ``Stack.add_link()`` calls. +It is much easier to create a "construction plan" using a ``qp.Batch`` and +apply the settings saved in ``DataSet._meta['sets']['batches']`` to populate a +``qp.Stack`` instance. In the following, let's assume ``dataset`` is containing +the definitions of two ``qp.Batch``\es, a ``qp.Stack`` can be created running:: + + stack = dataset.populate(batches='all') + +For the ``Batch`` definitions from :doc:`here <../batch/00_overview>`, you +will get the following *construction plans*: + +>>> batch1 = dataset.get_batch('batch1') +>>> batch1.add_y_on_y('y_keys') + +>>> print batch1.x_y_map +OrderedDict([('q1', ['@', 'gender', 'q1', 'locality', 'ethnicity']), + ('q2', ['locality', 'ethnicity']), + ('q6', ['@']), + ('@', ['q6']), + (u'q6_1', ['@', 'gender', 'q1']), + (u'q6_2', ['@', 'gender', 'q1']), + (u'q6_3', ['@', 'gender', 'q1'])]) + +>>> print batch1.x_filter_map +OrderedDict([('q1', {'(men only)+(q1)': (<function _intersection at 0x0000000019AE06D8>, [{'gender': 1}, {'age': [20, 21, 22, 23, 24, 25]}])}), + ('q2', {'men only': {'gender': 1}}), + ('q6', {'men only': {'gender': 1}}), + ('q6_1', {'men only': {'gender': 1}}), + ('q6_2', {'men only': {'gender': 1}}), + ('q6_3', {'men only': {'gender': 1}})]) + +>>> batch2 = dataset.get_batch('batch2') + +>>> print batch2.x_y_map +OrderedDict([('q2b', ['@', 'gender'])]) + +>>> print batch2.x_filter_map +OrderedDict([('q2b', 'no_filter')]) + +As both ``Batch``\es refer to the same data file, the same ``data_key`` (in this +case the name of ``dataset``) is defining all ``Links``. + +After populating the ``Stack`` content can be viewed using ``.describe()``: + +>>> stack.describe() + data filter x y view # +0 Example Data (A) men only q1 q1 NaN 1 +1 Example Data (A) men only q1 @ NaN 1 +2 Example Data (A) men only q1 gender NaN 1 +3 Example Data (A) men only @ q6 NaN 1 +4 Example Data (A) men only q2 ethnicity NaN 1 +5 Example Data (A) men only q2 locality NaN 1 +6 Example Data (A) men only q6_1 q1 NaN 1 +7 Example Data (A) men only q6_1 @ NaN 1 +8 Example Data (A) men only q6_1 gender NaN 1 +9 Example Data (A) men only q6_2 q1 NaN 1 +10 Example Data (A) men only q6_2 @ NaN 1 +11 Example Data (A) men only q6_2 gender NaN 1 +12 Example Data (A) men only q6_3 q1 NaN 1 +13 Example Data (A) men only q6_3 @ NaN 1 +14 Example Data (A) men only q6_3 gender NaN 1 +15 Example Data (A) men only gender q1 NaN 1 +16 Example Data (A) men only gender @ NaN 1 +17 Example Data (A) men only gender gender NaN 1 +18 Example Data (A) men only q6 @ NaN 1 +19 Example Data (A) (men only)+(q1) q1 q1 NaN 1 +20 Example Data (A) (men only)+(q1) q1 @ NaN 1 +21 Example Data (A) (men only)+(q1) q1 locality NaN 1 +22 Example Data (A) (men only)+(q1) q1 ethnicity NaN 1 +23 Example Data (A) (men only)+(q1) q1 gender NaN 1 +24 Example Data (A) no_filter q2b @ NaN 1 +25 Example Data (A) no_filter q2b gender NaN 1 + +You can find all combinations defined in the ``x_y_map`` in the +``Stack`` structure, but also ``Link``\s like ``Stack['Example Data (A)']['men only']['gender']['gender']`` +are included. These special cases arising from the ``y_on_y`` setting. Sometimes +it is helpful to group a ``describe``-dataframe and create a cross-tabulation +of the four ``Link`` attributes to get a better overview, e.g. to see how many +``Links`` are included for each x-filter combination. +: + +>>> stack.describe('x', 'filter') +filter (men only)+(q1) men only no_filter +x +@ NaN 1.0 NaN +gender NaN 3.0 NaN +q1 5.0 3.0 NaN +q2 NaN 2.0 NaN +q2b NaN NaN 2.0 +q6 NaN 1.0 NaN +q6_1 NaN 3.0 NaN +q6_2 NaN 3.0 NaN +q6_3 NaN 3.0 NaN + + diff --git a/docs/API/_build/html/_sources/sites/lib_doc/engine/02_quantity.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/engine/02_quantity.rst.txt new file mode 100644 index 000000000..4f351499d --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/engine/02_quantity.rst.txt @@ -0,0 +1,8 @@ +.. toctree:: + :maxdepth: 5 + :includehidden: + +======================== +The computational engine +======================== + diff --git a/docs/API/_build/html/_sources/sites/lib_doc/engine/03_test.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/engine/03_test.rst.txt new file mode 100644 index 000000000..83341abff --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/engine/03_test.rst.txt @@ -0,0 +1,7 @@ +.. toctree:: + :maxdepth: 5 + :includehidden: + +==================== +Significance testing +==================== diff --git a/docs/API/_build/html/_sources/sites/lib_doc/engine/04_agg_methods.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/engine/04_agg_methods.rst.txt new file mode 100644 index 000000000..4dd5529b8 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/engine/04_agg_methods.rst.txt @@ -0,0 +1,465 @@ +.. toctree:: + :maxdepth: 5 + :includehidden: + +================ +View aggregation +================ + +All following examples are working with a ``qp.Stack`` that was populated +from a ``qp.DataSet`` including the following ``qp.Batch`` definitions: + +>>> batch1 = dataset.get_batch('batch1') +>>> batch1.add_y_on_y('y_keys') + +>>> print batch1.x_y_map +OrderedDict([('q1', ['@', 'gender', 'q1', 'locality', 'ethnicity']), + ('q2', ['locality', 'ethnicity']), + ('q6', ['@']), + ('@', ['q6']), + (u'q6_1', ['@', 'gender', 'q1']), + (u'q6_2', ['@', 'gender', 'q1']), + (u'q6_3', ['@', 'gender', 'q1'])]) + +>>> print batch1.x_filter_map +OrderedDict([('q1', {'(men only)+(q1)': (<function _intersection at 0x0000000019AE06D8>, [{'gender': 1}, {'age': [20, 21, 22, 23, 24, 25]}])}), + ('q2', {'men only': {'gender': 1}}), + ('q6', {'men only': {'gender': 1}}), + ('q6_1', {'men only': {'gender': 1}}), + ('q6_2', {'men only': {'gender': 1}}), + ('q6_3', {'men only': {'gender': 1}})]) + +>>> print batch1.weights +['weight_a'] + +>>> batch2 = dataset.get_batch('batch2') + +>>> print batch2.x_y_map +OrderedDict([('q2b', ['@', 'gender'])]) + +>>> print batch2.x_filter_map +OrderedDict([('q2b', 'no_filter')]) + +>>> print batch2.weights +['weight'] + +----------- +Basic views +----------- + +It is possible to add various ``qp.View``\s to a ``Link``. This can be performed +by running ``Stack.add_link()`` providing ``View`` objects via the ``view`` parameter. +Alternatively, the ``qp.Batch`` definitions that are stored in the meta data +help to add basic ``View``\s (counts, percentages, bases and sums). By simply +running ``Stack.aggregate()`` we can easily add a large amount of aggregations +in one step. + +.. note:: + ``Stack.aggregate()`` can only be used with pre-populated ``Stack``\s! + (see :doc:`DataSet.populate() <01_links_stacks>`). + +For instance, we can add column percentages and (unweighted and weighted) base sizes +to all ``Link``\s of ``batch2`` like this: + +>>> stack.aggregate(views=['c%', 'cbase'], unweighted_base=True, batches='batch2', verbose=False) +>>> stack.describe() + data filter x y view # +0 Example Data (A) men only q1 q1 NaN 1 +1 Example Data (A) men only q1 @ NaN 1 +2 Example Data (A) men only q1 gender NaN 1 +3 Example Data (A) men only @ q6 NaN 1 +4 Example Data (A) men only q2 ethnicity NaN 1 +5 Example Data (A) men only q2 locality NaN 1 +6 Example Data (A) men only q6_1 q1 NaN 1 +7 Example Data (A) men only q6_1 @ NaN 1 +8 Example Data (A) men only q6_1 gender NaN 1 +9 Example Data (A) men only q6_2 q1 NaN 1 +10 Example Data (A) men only q6_2 @ NaN 1 +11 Example Data (A) men only q6_2 gender NaN 1 +12 Example Data (A) men only q6_3 q1 NaN 1 +13 Example Data (A) men only q6_3 @ NaN 1 +14 Example Data (A) men only q6_3 gender NaN 1 +15 Example Data (A) men only gender q1 NaN 1 +16 Example Data (A) men only gender @ NaN 1 +17 Example Data (A) men only gender gender NaN 1 +18 Example Data (A) men only q6 @ NaN 1 +19 Example Data (A) (men only)+(q1) q1 q1 NaN 1 +20 Example Data (A) (men only)+(q1) q1 @ NaN 1 +21 Example Data (A) (men only)+(q1) q1 locality NaN 1 +22 Example Data (A) (men only)+(q1) q1 ethnicity NaN 1 +23 Example Data (A) (men only)+(q1) q1 gender NaN 1 +24 Example Data (A) no_filter q2b @ x|f|:|y|weight|c% 1 +25 Example Data (A) no_filter q2b @ x|f|x:||weight|cbase 1 +26 Example Data (A) no_filter q2b @ x|f|x:|||cbase 1 +27 Example Data (A) no_filter q2b gender x|f|:|y|weight|c% 1 +28 Example Data (A) no_filter q2b gender x|f|x:||weight|cbase 1 +29 Example Data (A) no_filter q2b gender x|f|x:|||cbase 1 + +Obviously ``View``\s are only added to ``Link``\s defined by ``batch2`` and +automatically weighted according to the weight definition of ``batch2``, +which is evident from the view keys (``x|f|:|y|weight|c%``). Combining the information +of the four ``Link`` attributes with a view key, leads to a ``pd.DataFrame`` +and its belonging meta information: + +>>> link = stack['Example Data (A)']['no_filter']['q2b']['gender'] +>>> view_key = 'x|f|:|y|weight|c%' + +>>> link[view_key] +Question q2b +Values @ +Question Values +q2b 1 11.992144 + 2 80.802580 + 3 7.205276 + +>>> link[view_key].meta() +{ + "agg": { + "weights": "weight", + "name": "c%", + "grp_text_map": null, + "text": "", + "fullname": "x|f|:|y|weight|c%", + "is_weighted": true, + "method": "frequency", + "is_block": false + }, + "x": { + "is_array": false, + "name": "q2b", + "is_multi": false, + "is_nested": false + }, + "shape": [ + 3, + 1 + ], + "y": { + "is_array": false, + "name": "@", + "is_multi": false, + "is_nested": false + } +} + +Now we are adding ``View``\s to all ``batch1``-defined ``Link``\s as well: + +>>> stack.aggregate(views=['c%', 'counts', 'cbase'], unweighted_base=True, batches='batch1', verbose=False) +>>> stack.describe(['x', 'view'], 'y').loc[['@', 'q6'], ['@', 'q6']] +y @ q6 +x view +@ x|f|:|y|weight_a|c% NaN 1.0 + x|f|:||weight_a|counts NaN 1.0 +q6 x|f|:|y|weight_a|c% 1.0 NaN + x|f|:||weight_a|counts 1.0 NaN + +Even if unweighted bases are requested, they get skipped for array summaries +and transposed arrays. + +Since ``y_on_y`` is requested, for a variable used as cross- and downbreak, with an extended filter (in this +example ``q1``), two ``Link``\s with ``View``\s are created: + +>>> stack.describe(['y', 'filter', 'view'], 'x').loc['q1', 'q1'] +filter view +(men only)+(q1) x|f|:|y|weight_a|c% 1.0 + x|f|:||weight_a|counts 1.0 + x|f|x:||weight_a|cbase 1.0 + x|f|x:|||cbase 1.0 +men only x|f|:|y|weight_a|c% 1.0 + x|f|:||weight_a|counts 1.0 + x|f|x:||weight_a|cbase 1.0 + x|f|x:|||cbase 1.0 + +The first one is the aggregation defined by the ``Batch`` construction plan, +the second one shows the ``y_on_y`` aggregation using only the main +``Batch.filter``. + +------------------------- +Non-categorical variables +------------------------- + +>>> batch3 = dataset.add_batch('batch3') +>>> batch3.add_x('age') +>>> stack = dataset.populate('batch3') +>>> stack.describe() + data filter x y view # +0 Example Data (A) no_filter age @ NaN 1 + +Non-categorical variables (``ìnt`` or ``float``) are handled in a special way. +There are two options: + + * Treat them like categorical variables: + Append them to the parameter ``categorize``, then counts, percentage + and sum aggregations can be added alongside the ``cbase`` ``View``. + + >>> stack.aggregate(views=['c%', 'counts', 'cbase', 'counts_sum', 'c%_sum'], + unweighted_base=True, + categorize=['age'], + batches='batch3', + verbose=False) + + >>> stack.describe() + data filter x y view # + 0 Example Data (A) no_filter age @ x|f|:|||counts 1 + 1 Example Data (A) no_filter age @ x|f.c:f|x:|y||c%_sum 1 + 2 Example Data (A) no_filter age @ x|f|:|y||c% 1 + 3 Example Data (A) no_filter age @ x|f|x:|||cbase 1 + 4 Example Data (A) no_filter age @ x|f.c:f|x:|||counts_sum 1 + + * Do not categorize the variable: + Only ``cbase`` is created and additional descriptive statistics + ``View``\s must be added. The method will raise a warning: + + >>> stack.aggregate(views=['c%', 'counts', 'cbase', 'counts_sum', 'c%_sum'], + unweighted_base=True, + batches='batch3', + verbose=True) + Warning: Found 1 non-categorized numeric variable(s): ['age']. + Descriptive statistics must be added! + + >>> stack.describe() + data filter x y view # + 0 Example Data (A) no_filter age @ x|f|x:|||cbase 1 + +---------------------- +Descriptive statistics +---------------------- + +>>> b_name = 'batch4' +>>> batch4 = dataset.add_batch(b_name) +>>> batch4.add_x(['q2b', 'q6', 'age']) +>>> stack = dataset.populate(b_name) +>>> stack.aggregate(views=['counts', 'cbase'], batches=b_name, verbose=False) + +>>> stack.describe() + data filter x y view # +0 Example Data (A) no_filter q2b @ x|f|:|||counts 1 +1 Example Data (A) no_filter q2b @ x|f|x:|||cbase 1 +2 Example Data (A) no_filter q6_1 @ x|f|:|||counts 1 +3 Example Data (A) no_filter q6_1 @ x|f|x:|||cbase 1 +4 Example Data (A) no_filter q6_2 @ x|f|:|||counts 1 +5 Example Data (A) no_filter q6_2 @ x|f|x:|||cbase 1 +6 Example Data (A) no_filter q6_3 @ x|f|:|||counts 1 +7 Example Data (A) no_filter q6_3 @ x|f|x:|||cbase 1 +8 Example Data (A) no_filter age @ x|f|x:|||cbase 1 +9 Example Data (A) no_filter q6 @ x|f|:|||counts 1 +10 Example Data (A) no_filter q6 @ x|f|x:|||cbase 1 + +Adding descriptive statistics ``View``\s like mean, stddev, min, max, median, etc. +can be added with the method ``stack.add_stats()``. With the parameters +``other_source``, ``rescale`` and ``exclude`` you can specify the calculation. +Again each combination of the parameters refers to a unique view key. Note that +in ``on_vars`` included arrays get unrolled, that means also all belonging +array items get equipped with the added ``View``: + +>>> stack.add_stats(on_vars=['q2b', 'age'], stats='mean', _batches=b_name, verbose=False) +>>> stack.add_stats(on_vars=['q6'], stats='stddev', _batches=b_name, verbose=False) +>>> stack.add_stats(on_vars=['q2b'], stats='mean', rescale={1:100, 2:50, 3:0}, +... custom_text='rescale mean', _batches=b_name, verbose=False) + +>>> stack.describe('view', 'x') +x age q2b q6 q6_1 q6_2 q6_3 +view +x|d.mean|x:|||stat 1.0 1.0 NaN NaN NaN NaN +x|d.mean|x[{100,50,0}]:|||stat NaN 1.0 NaN NaN NaN NaN +x|d.stddev|x:|||stat NaN NaN 1.0 1.0 1.0 1.0 +x|f|:|||counts NaN 1.0 1.0 1.0 1.0 1.0 +x|f|x:|||cbase 1.0 1.0 1.0 1.0 1.0 1.0 + +---- +Nets +---- + +>>> b_name = 'batch5' +>>> batch5 = dataset.add_batch(b_name) +>>> batch5.add_x(['q2b', 'q6']) +>>> stack = dataset.populate(b_name) +>>> stack.aggregate(views=['counts', 'c%', 'cbase'], batches=b_name, verbose=False) + +>>> stack.describe('view', 'x') +x q2b q6 q6_1 q6_2 q6_3 +view +x|f|:|y||c% 1 1 1 1 1 +x|f|:|||counts 1 1 1 1 1 +x|f|x:|||cbase 1 1 1 1 1 + +Net-like ``View``\s can be added with the method ``Stack.add_nets()`` by defining +``net_map``\s for selected variables. There is a distinction between two different +types of net ``View``\s: + + * Expanded nets: + The existing counts or percentage ``View``\s are replaced with the new + net ``View``\s, which will the net-defining codes after or before the + computed net groups (i.e. "overcode" nets). + + >>> stack.add_nets('q2b', [{'Top2': [1, 2]}], expand='after', _batches=b_name, verbose=False) + + >>> stack.describe('view', 'x') + x q2b q6 q6_1 q6_2 q6_3 + view + x|f|:|y||c% NaN 1.0 1.0 1.0 1.0 + x|f|:|||counts NaN 1.0 1.0 1.0 1.0 + x|f|x:|||cbase 1.0 1.0 1.0 1.0 1.0 + x|f|x[{1,2}+]*:|y||net 1.0 NaN NaN NaN NaN + x|f|x[{1,2}+]*:|||net 1.0 NaN NaN NaN NaN + + * Not expanded nets: + The new net ``View``\s are added to the stack, which contain only the + computed net groups. + + >>> stack.add_nets('q2b', [{'Top2': [1, 2]}], _batches=b_name, verbose=False) + + >>> stack.describe('view', 'x') + x q2b q6 q6_1 q6_2 q6_3 + view + x|f|:|y||c% NaN 1.0 1.0 1.0 1.0 + x|f|:|||counts NaN 1.0 1.0 1.0 1.0 + x|f|x:|||cbase 1.0 1.0 1.0 1.0 1.0 + x|f|x[{1,2}+]*:|y||net 1.0 NaN NaN NaN NaN + x|f|x[{1,2}+]*:|||net 1.0 NaN NaN NaN NaN + x|f|x[{1,2}]:|y||net 1.0 NaN NaN NaN NaN + x|f|x[{1,2}]:|||net 1.0 NaN NaN NaN NaN + +The difference between the two net types are also visible in the view keys: +``x|f|x[{1,2}+]*:|||net`` versus ``x|f|x[{1,2}]:|||net``. + +~~~~~~~~~~~~~~~ +Net definitions +~~~~~~~~~~~~~~~ + +To create more complex net definitions the method ``quantipy.net()`` can be used, +which generates a well-formatted instruction dict and appends it to the ``net_map``. +It's a helper especially concerning including various texts with different +valid ``text_keys``. The next example shows how to prepare a net for 'q6' +(promoters, detractors): + +>>> q6_net = qp.net([], [1, 2, 3, 4, 5, 6], 'Promotors', ['en-GB', 'sv-SE']) +>>> q6_net = qp.net(q6_net, [9, 10], {'en-GB': 'Detractors', +... 'sv_SE': 'Detractors', +... 'de-DE': 'Kritiker'}) +>>> qp.net(q6_net[0], text='Promoter', text_key='de-DE') + +>>> print q6_net +[ + { + "1": [1, 2, 3, 4, 5, 6], + "text": { + "en-GB": "Promotors", + "sv-SE": "Promotors", + "de-DE": "Promoter" + } + }, + { + "2": [9, 10], + "text": { + "en-GB": "Detractors", + "sv_SE": "Detractors", + "de-DE": "Kritiker" + } + } +] + +~~~~~~~~~~~~ +Calculations +~~~~~~~~~~~~ + +``Stack.add_nets()`` has the parameter ``calc``, which allows adding ``View``\s +that are calculated out of the defined nets. The method ``qp.calc()`` is a +helper to create a well-formatted instruction dict for the calculation. +For instance, to calculate the NPS (*promoters* - *detractors*) for ``'q6'``, see the example +above and create the following calculation: + +>>> q6_calc = qp.calc((1, '-', 2), 'NPS', ['en-GB', 'sv-SE', 'de-DE']) + +>>> print q6_calc +OrderedDict([('calc', ('net_1', <built-in function sub>, 'net_2')), + ('calc_only', False), + ('text', {'en-GB': 'NPS', + 'sv-SE': 'NPS', + 'de-DE': 'NPS'})]) + +>>> stack.add_nets('q6', q6_net, calc=q6_calc, _batches=b_name, verbose=False) + +>>> stack.describe('view', 'x') +x q2b q6 q6_1 q6_2 q6_3 +view +x|f.c:f|x[{1,2,3,4,5,6}],x[{9,10}],x[{1,2,3,4,5... NaN 1.0 1.0 1.0 1.0 +x|f.c:f|x[{1,2,3,4,5,6}],x[{9,10}],x[{1,2,3,4,5... NaN 1.0 1.0 1.0 1.0 +x|f|:|y||c% NaN 1.0 1.0 1.0 1.0 +x|f|:|||counts NaN 1.0 1.0 1.0 1.0 +x|f|x:|||cbase 1.0 1.0 1.0 1.0 1.0 +x|f|x[{1,2}+]*:|y||net 1.0 NaN NaN NaN NaN +x|f|x[{1,2}+]*:|||net 1.0 NaN NaN NaN NaN +x|f|x[{1,2}]:|y||net 1.0 NaN NaN NaN NaN +x|f|x[{1,2}]:|||net 1.0 NaN NaN NaN NaN + +You can see that nets that are added on arrays are also applied for all array items. + +--------------- +Cumulative sums +--------------- + +Cumulative sum ``View``\s can be added to a specified collection of xks of the +``Stack`` using ``stack.cumulative_sum()``. These ``View``\s will always +replace the regular counts and percentage ``View``\s: + +>>> b_name = 'batch6' +>>> batch6 = dataset.add_batch(b_name) +>>> batch6.add_x(['q2b', 'q6']) +>>> stack = dataset.populate(b_name) +>>> stack.aggregate(views=['counts', 'c%', 'cbase'], batches=b_name, verbose=False) + +>>> stack.cumulative_sum('q6', verbose=False) + +>>> stack.describe('view', 'x') +x q2b q6 q6_1 q6_2 q6_3 +view +x|f.c:f|x++:|y||c%_cumsum NaN 1.0 1.0 1.0 1.0 +x|f.c:f|x++:|||counts_cumsum NaN 1.0 1.0 1.0 1.0 +x|f|:|y||c% 1.0 NaN NaN NaN NaN +x|f|:|||counts 1.0 NaN NaN NaN NaN +x|f|x:|||cbase 1.0 1.0 1.0 1.0 1.0 + +------------------ +Significance tests +------------------ + +>>> batch2 = dataset.get_batch('batch2') +>>> batch2.set_sigtests([0.05]) +>>> batch5 = dataset.get_batch('batch5') +>>> batch5.set_sigtests([0.01, 0.05]) +>>> stack = dataset.populate(['batch2', 'batch5']) + +>>> stack.aggregate(['counts', 'cbase'], batches=['batch2', 'batch5'], verbose=False) + +>>> stack.describe(['view', 'y'], 'x') +x q2b q6 q6_1 q6_2 q6_3 +view y +x|f|:||weight|counts @ 1.0 NaN NaN NaN NaN + gender 1.0 NaN NaN NaN NaN +x|f|:|||counts @ 1.0 1.0 1.0 1.0 1.0 +x|f|x:||weight|cbase @ 1.0 NaN NaN NaN NaN + gender 1.0 NaN NaN NaN NaN +x|f|x:|||cbase @ 1.0 1.0 1.0 1.0 1.0 + gender 1.0 NaN NaN NaN NaN + +Significance tests can only be added ``Batch``-wise, which also means that +significance levels must be defined for each ``Batch`` before running +``stack.add_tests()``. + +>>> stack.add_tests(['batch2', 'batch5'], verbose=False) + +>>> stack.describe(['view', 'y'], 'x') +x q2b q6 q6_1 q6_2 q6_3 +view y +x|f|:||weight|counts @ 1.0 NaN NaN NaN NaN + gender 1.0 NaN NaN NaN NaN +x|f|:|||counts @ 1.0 1.0 1.0 1.0 1.0 +x|f|x:||weight|cbase @ 1.0 NaN NaN NaN NaN + gender 1.0 NaN NaN NaN NaN +x|f|x:|||cbase @ 1.0 1.0 1.0 1.0 1.0 + gender 1.0 NaN NaN NaN NaN +x|t.props.Dim.01|:|||significance @ 1.0 NaN 1.0 1.0 1.0 +x|t.props.Dim.05|:||weight|significance @ 1.0 NaN NaN NaN NaN + gender 1.0 NaN NaN NaN NaN +x|t.props.Dim.05|:|||significance @ 1.0 NaN 1.0 1.0 1.0 diff --git a/docs/API/_build/html/_sources/sites/lib_doc/overview.rst.txt b/docs/API/_build/html/_sources/sites/lib_doc/overview.rst.txt new file mode 100644 index 000000000..eb91da666 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/lib_doc/overview.rst.txt @@ -0,0 +1,14 @@ +============= +Documentation +============= + +.. toctree:: + :maxdepth: 5 + :hidden: + + dataprocessing/00_overview + batch/00_overview + engine/00_overview + builds/00_overview + + diff --git a/docs/API/_build/html/_sources/sites/release_notes/00_overview.rst.txt b/docs/API/_build/html/_sources/sites/release_notes/00_overview.rst.txt new file mode 100644 index 000000000..984dc1c01 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/release_notes/00_overview.rst.txt @@ -0,0 +1,17 @@ +------------- +Release notes +------------- + +.. toctree:: + :maxdepth: 5 + :includehidden: + + 01_latest + 02_archive + + +.. toctree:: + :maxdepth: 5 + :hidden: + + 03_how_to_snippets \ No newline at end of file diff --git a/docs/API/_build/html/_sources/sites/release_notes/01_latest.rst.txt b/docs/API/_build/html/_sources/sites/release_notes/01_latest.rst.txt new file mode 100644 index 000000000..4eb81c383 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/release_notes/01_latest.rst.txt @@ -0,0 +1,134 @@ +.. toctree:: + :maxdepth: 5 + :includehidden: + +=================== +Latest (01/10/2018) +=================== + +**New**: "rewrite" of Rules module (affecting sorting): + +**sorting "normal" columns**: + +* ``sort_on`` always '@' +* ``fix`` any categories +* ``sort_by_weight`` default is unweighted (None), but each weight (included +in data) can be used + +If sort_by_weight and the view-weight differ, a warning is shown. + +**sorting "expanded net" columns**: + +* ``sort_on`` always '@' +* ``fix`` any categories +* sorting ``within`` or ``between`` net groups is available +* ``sort_by_weight``: as default the weight of the first found +expanded-net-view is taken. Only weights of aggregated net-views are possible + +**sorting "array summaries"**: + +* ``sort_on`` can be any desc ('median', 'stddev', 'sem', 'max', 'min', +'mean', 'upper_q', 'lower_q') or nets ('net_1', 'net_2', .... enumerated +by the net_def) +* ``sort_by_weight``: as default the weight of the first found desc/net-view +is taken. Only weights of aggregated desc/net-views are possible +* ``sort_on`` can also be any category, here each weight can be used to sort_on + +"""" + +**New**: ``DataSet.min_value_count()`` + +A new wrapper for ``DataSet.hiding()`` is included. All values are hidden, +that have less counts than the included number ``min``. +The used data can be weighted or filtered using the parameters ``weight`` and +``condition``. + +Usage as Batch method: +``Batch.min_value_count()`` without the parameters ``weight`` and +``condition`` automatically grabs ``Batch.weights[0]`` and ``Batch.filter`` +to calculate low value counts. + +"""" + +**New**: Prevent weak duplicated in data + +As Python is case sensitive it is possible to have two or more variables with +the same name, but in lower- and uppercases. Most other software do not support +that, so a warning is shown if a weak dupe is created. Additionally +``Dataset.write_dimensions()`` performs auto-renaming is weak dupes are detected. + +"""" + +**New**: Prevent single-cat delimited sets + +``DataSet.add_meta(..., qtype='delimited set', categories=[...], ...)`` +automatically switches ``qtype`` to single if only one category is defined. +``DataSet.convert(name, 'single')`` allows conversion from ``delimited set`` to +``single`` if the variable has only one category. +``DataSet.repair()`` and ``DataSt.remove_values()`` convert delimited sets +automatically to singles if only one category is included. + +"""" + +**Update**: merge warnings + merging delimites sets + +Warnings in ``hmerge()`` and ``vmerge()`` are updated. If a column exists in +the left and the right dataset, the type is compared. Some type inconsistencies +are allowed, but return a warning, while others end up in a raise. + +delimited sets in ``vmerge()``: + +If a column is a delimited set in the left dataset, but a single, int or float +in the right dataset, the data of the right column is converted into a delimited +set. + +delimited sets in ``hmerge(...merge_existing=None)``: + +For the hmerge a new parameter ``merge_existing`` is included, which can be +``None``, a list of variable-names or ``'all'``. + +If delimited sets are included in left and right dataset: + +* ``merge_existing=None``: Only meta is adjusted. Data is untouched (left data +is taken). +* ``merge_existing='all'``: Meta and data are merged for all delimited sets, +that are included in both datasets. +* ``merge_existing=[variable-names]``: Meta and data are merged for all +delimited sets, that are listed and included in both datasets. + +"""" + +**Update**: encoding in ``DataSet.get_batch(name)`` + +The method is not that encoding sensitive anymore. It returns the depending +``Batch``, no matter if ``'...'``, ``u'...'`` or ``'...'.decode('utf8')`` is +included as name. + +"""" + +**Update**: warning in weight engine + +Missing codes in the sample are only alerted, if the belonging target is not 0. + +"""" + +**Update**: ``DataSet.to_array(..., variables, ...)`` + +Duplicated vars in ``variables`` are not allowed anymore, these were causing +problems in the ChainManager class. + +"""" + +**Update**: ``Batch.add_open_ends()`` + +Method raises an error if no vars are included in ``oe`` and ``break_by``. The +empty dataframe was causing issues in the ChainManager class. + +"""" + +**Update**: ``Batch.extend_x()`` + +The method automatically checks if the included variables are arrays and adds +them to ``Batch.summaries`` if they are included yet. + +"""" diff --git a/docs/API/_build/html/_sources/sites/release_notes/02_archive.rst.txt b/docs/API/_build/html/_sources/sites/release_notes/02_archive.rst.txt new file mode 100644 index 000000000..d2099d199 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/release_notes/02_archive.rst.txt @@ -0,0 +1,1642 @@ + + +.. toctree:: + :maxdepth: 5 + :hidden: + +====================== +Archived release notes +====================== + +--------------- +sd (04/06/2018) +--------------- + + + +**New**: Additional variable (names) "getter"-like and resolver methods + +* ``DataSet.created()`` +* ``DataSet.find(str_tags=None, suffixed=False)`` +* ``DataSet.names()`` +* ``DataSet.resolve_name()`` + +A bunch of new methods enhancing the options of finding and testing for variable +names have been added. ``created()`` will list all variables that have been added +to a dataset using core functions, i.e. ``add_meta()`` and ``derive()``, resp. +all helper methods that use them internally (as ``band()`` or ``categorize()`` do +for instance). + +The ``find()`` method is returning all variable names that contain any of the +provided substrings in ``str_tags``. To only consider names that end with these +strings, set ``suffixed=True``. If no ``str_tags`` are passed, the method will +use a default list of tags including ``['_rc', '_net', ' (categories', ' (NET', '_rec']``. + +Sometimes a dataset might contain "semi-duplicated" names, variables that differ +in respect to case sensitivity but have otherwise identical names. Calling +``names()`` will report such cases in a ``pd.DataFrame`` that lists all name +variants under the respective ``str.lower()`` version. If no semi-duplicates +are found, ``names()`` will simply return ``DataSet.variables()``. + +Lastly, ``resolve_name()`` can be used to return the "proper", existing representation(s) of a given variable name's spelling. + +"""" + +**New**: ``Batch.remove()`` + +Not needed batches can be removed from ``meta``, so they are not aggregated +anymore. + +"""" + +**New**: ``Batch.rename(new_name)`` + +Sometimes standard batches have long/ complex names. They can now be changed +into a custom name. Please take into account, that for most hubs the name of +omnibus batches should look like 'client ~ topic'. + +"""" + +**Update**: Handling verbatims in ``qp.Batch`` + +Instead of holding the well prepared open-end dataframe in ``batch.verbatims``, +the attribute is now filled by ``batch.add_open_ends()`` with instructions to +create the open-end dataframe. It is easier to to modify/ overwrite existing +verbatims. Therefore also a new parameter is included ``overwrite=True``. + +"""" + +**Update**: ``Batch.copy(..., b_filter=None, as_addition=False)`` + +It is now possible to define an additional filter for a copied batch and also +to set it as addition to the master batch. + +"""" + +**Update**: Regrouping the variable list using ``DataSet.order(..., regroup=True)`` + +A new parameter called ``regroup`` will instruct reordering all newly created +variables into their logical position of the dataset's main variable order, i.e. +attempting to place *derived* variables after the *originating* ones. + +"""" + +**Bugfix**: ``add_meta()`` and duplicated categorical ``values`` codes + +Providing duplicated numerical codes while attempting to create new metadata +using ``add_meta()`` will now correctly raise a ``ValueError`` to prevent +corrupting the ``DataSet``. + +>>> cats = [(1, 'A'), (2, 'B'), (3, 'C'), (3, 'D'), (2, 'AA')] +>>> dataset.add_meta('test_var', 'single', 'test label', cats) +ValueError: Cannot resolve category definition due to code duplicates: [2, 3] + + + +--------------- +sd (04/04/2018) +--------------- + + +**New**: Emptiness handlers in ``DataSet`` and ``Batch`` classes + +* ``DataSet.empty(name, condition=None)`` +* ``DataSet.empty_items(name, condition=None, by_name=True)`` +* ``DataSet.hide_empty_items(condition=None, arrays=None)`` +* ``Batch.hide_empty(xks=True, summaries=True)`` + +``empty()`` is used to test if regular variables are completely empty, +``empty_items()`` checks the same for the items of an array mask definition. +Both can be run on lists of variables. If a single variable is tested, the former +returns simply boolean, the latter will list all empty items. If lists are checked, +``empty()`` returns the sublist of empty variables, ``empty_items()`` is mapping +the list of empty items per array name. The ``condition`` parameter of these +methods takes a ``Quantipy logic`` expression to restrict the test to a subset +of the data, i.e. to check if variables will be empty if the dataset is filtered +a certain way. A very simple example: + +>>> dataset.add_meta('test_var', 'int', 'Variable is empty') +>>> dataset.empty('test_var') +True + +>>> dataset[dataset.take({'gender': 1}), 'test_var'] = 1 +>>> dataset.empty('test_var') +False + +>>> dataset.empty('test_var', {'gender': 2}) +True + + +The ``DataSet`` method ``hide_empty_items()`` uses the emptiness tests to +automatically apply a **hiding rule** on all empty items found in the dataset. +To restrict this to specific arrays only, their names can be provided via the +``arrays`` argument. ``Batch.hide_empty()`` takes into account the current +``Batch.filter`` setup and by drops/hides *all* relevant empty variables from the +``xks`` list and summary aggregations by default. Summaries that would end up without valid +items because of this are automatically removed from the ``summaries`` collection +and the user is warned. + +"""" + +**New**: ``qp.set_option('fast_stack_filters', True)`` + +A new option to enable a more efficient test for already existing filters +inside the ``qp.Stack`` object has been added. Set the ``'fast_stack_filters'`` +option to ``True`` to use it, the default is ``False`` to ensure compatibility +in different versions of production DP template workspaces. + +"""" + +**Update**: ``Stack.add_stats(..., factor_labels=True, ...)`` + +The parameter ``factor_labels`` is now also able to take the string ``'()'``, +then factors are written in the normal brackets next to the label (instead +of ``[]``). + +In the new version factor_labels are also just added if there are none included +before, except new scales are used. + +"""" + +**Bugfix**: ``DataSet`` ``np.NaN`` insertion to ``delimited_set`` variables + +``np.NaN`` was incorrectly transformed when inserted into ``delimited_set`` +before, leading to either ``numpy`` type conflicts or type casting exceptions. +This is now fixed. + + + +--------------- +sd (27/02/2018) +--------------- + +**New**: ``DataSet._dimensions_suffix`` + +``DataSet`` has a new attribute ``_dimensions_suffix``, which is used as mask +suffix while running ``DataSet.dimensionize()``. The default is ``_grid`` and +it can be modified with ``DataSet.set_dim_suffix()``. + +"""" + +**Update**: ``Stack._get_chain()`` (old chain) + +The method is speeded-up. If a filter is already included in the Stack, it is +not calculated from scratch anymore. Additionally the method has a new parameter +``described``, which takes a describing dataframe of the Stack, so it no longer +needs to be calculated in each loop. + +"""" +**Update**: ``Stack.add_nets()`` (recoded ``Views``) + +Nets that are applied on array variables will now also create a new recoded +array that reflects the net definitions if ``recoded`` is used. The +method has been creating only the item versions before. + +"""" + +**Update**: ``Stack.add_stats()`` + +The method will now create a new metadata property called ``'factor'`` for each +variable it is applied on. You can only have one factor assigned to one +categorical value, so for multiple statistic definitions (exclusions, etc.) +it will get overwritten. + +"""" + +**Update**: ``DataSet.from_batch()`` (``additions`` parameter) + +The ``additions`` parameter has been updated to also be able to create recoded +variables from existing "additional" Batches that are attached to a parent one. +Filter variables will get the new meta ``'properties'`` tag ``'recoded_filter'`` +and only have one category (``1``, ``'active'``). They are named simply +``'filter_1'``, ``'filter_2'`` and so on. The new possible values of the +parameters are now: + + * ``None``: ``as_addition()``-Batches are not considered. + * ``'variables'``: Only cross- and downbreak variables are considered. + * ``'filters'``: Only filters are recoded. + * ``'full'``: ``'variables'`` + ``'filters'`` + +"""" + +**Bugfix**: ``ViewManager._request_views()`` + +Cumulative sums are only requested if they are included in the belonging +``Stack``. Additionally the correct related sig-tests are now taken for +cumulative sums. + +--------------- +sd (12/01/2018) +--------------- + +**New**: ``Audit`` + +``Audit`` is a new class which takes ``DataSet`` instances, compares and aligns +them. + +The class compares/ reports/ aligns the following aspects: + + * datasets are valid (``DataSet.validate()``) + * mismatches (variables are not included in all datasets) + * different types (variables are in more than one dataset, but have different types) + * labels (variables are in more than one dataset, but have different labels for the same text_key) + * value codes (variables are in more than one dataset, but have different value codes) + * value texts (variables are in more than one dataset, but have different value texts) + * array items (arrays are in more than one dataset, but have different items) + * item labels (arrays are in more than one dataset, but their items have different labels) + +This is the first draft of the class, so it will need some testing and probably +adjustments. + +"""" + +**New**: ``DataSet.reorder_items(name, new_order)`` + +The new method reorders the items of the included array. The ints in the +``new_order`` list match up to the number of the items +(``DataSet.item_no('item_name')``), not to the position. + +"""" + +**New**: ``DataSet.valid_tks``, Arabic + +Arabic (``ar-AR``) is included as default valid text-key. + +"""" + +**New**: ``DataSet.extend_items(name, ext_items, text_key=None)`` + +The new method extends the items of an existing array. + +"""" + +**Update**: ``DataSet.set_missings()`` + +The method is now limited to ``DataSet``, ``Batch`` does not inherit it. + +"""" + +**Update**: ``DataSet`` + +The whole class is reordered and cleaned up. Some new deprecation warnings +will appear. + +"""" + +**Update**: ``DataSet.add_meta()`` / ``DataSet.derive()`` + +Both methods will now raise a ``ValueError: Duplicated codes provided. Value codes must be unique!`` +if categorical ``values`` definitions try to apply duplicated codes. + +"""" + +--------------- +sd (18/12/2017) +--------------- + + +**New**: ``Batch.remove_filter()`` + +Removes all defined (global + extended) filters from a Batch instance. + +"""" + +**Update**: ``Batch.add_filter()`` + +It's now possible to extend the global filter of a Batch instance. These options +are possible. + +Add first filter:: + + >>> batch.filter, batch.filter_names + 'no_filter', ['no_filter'] + >>> batch.add_filter('filter1', logic1) + >>> batch.filter, batch.filter_names + {'filter1': logic1}, ['filter1'] + +Extend filter:: + + >>> batch.filter, batch.filter_names + {'filter1': logic}, ['filter1'] + >>> batch.add_filter('filter2', logic2) + >>> batch.filter, batch.filter_names + {'filter1' + 'filter2': intersection([logic1, logic2])}, ['filter1' + 'filter2'] + +Replace filter:: + + >>> batch.filter, batch.filter_names + {'filter1': logic}, ['filter1'] + >>> batch.add_filter('filter1', logic2) + >>> batch.filter, batch.filter_names + {'filter1': logic2}, ['filter1'] + +"""" + +**Update**: ``Stack.add_stats(..., recode)`` + +The new parameter ``recode`` defines if a new numerical variable is created which +satisfies the stat definitions. + +"""" + +**Update**: ``DataSet.populate()`` + +A progress tracker is added to this method. + +"""" + +**Bugfix**: ``Batch.add_open_ends()`` + +``=`` is removed from all responsess in the included variables, as it causes +errors in the Excel-Painter. + +"""" + +**Bugfix**: ``Batch.extend_x()`` and ``Batch.extend_y()`` + +Check if included variables exist and unroll included masks. + +"""" + +**Bugfix**: ``Stack.add_nets(..., calc)`` + +If the operator in calc is ``div``/ ``/``, the calculation is now performed +correctly. + +"""" + +--------------- +sd (28/11/2017) +--------------- + +**New** ``DataSet.from_batch()`` + +Creates a new ``DataSet`` instance out of ``Batch`` definitions (xks, yks, +filter, weight, language, additions, edits). + +"""" + +**New**: ``Batch.add_total()`` + +Defines if total column ``@`` should be included in the downbreaks (yks). + +"""" + +**New**: ``Batch.set_unwgt_counts()`` + +If cellitems are ``cp`` and a weight is provided, it is possible to request +unweighted count views (percentages are still weighted). + +"""" + +**Update**: ``Batch.add_y_on_y(name, y_filter=None, main_filter='extend')`` + +Multiple ``y_on_y`` aggregations can now be added to a ``Batch`` instance +and each can have an own filter. The y_on_y-filter can ``extend`` or ``replace`` +the main_filter of the ``Batch``. + +"""" + +**Update**: ``Stack.add_nets(..., recode)`` + +The new parameter ``recode`` defines if a new variable is created which +satisfies the net definitions. Different options for ``recode`` are: + + * ``'extend_codes'``: The new variable contains all codes of the original + variable and all nets as new categories. + * ``'drop_codes'``: The new variable contains only all nets as new categories. + * ``'collect_codes'`` or ``'collect_codes@cat_name'``: The new variable contains + all nets as new categories and another new category which sums all cases that + are not in any net. The new category text can be defined by adding ``@cat_name`` + to ``collect_codes``. If none is provided ``Other`` is used as default. + +"""" + +**Update**: ``Stack.add_nets()`` + +If a variable in the ``Stack`` already has a net_view, it gets overwritten +if a new net is added. + +"""" + +**Update**: ``DataSet.set_missings(..., missing_map)`` + +The parameter ``missing_map`` can also handle lists now. All included +codes are be flagged as ``'exclude'``. + +"""" + +**Update**: ``request_views(..., sums='mid')`` (``ViewManager``/``query.py``) + +Allow different positions for sums in the view-order. They can be placed in +the middle (``'mid'``) between the basics/ nets and the stats or at the +``'bottom'`` after the stats. + +"""" + +**Update/ New**: ``write_dimensions()`` + +Converting qp data to mdd and ddf files by using ``write_dimensions()`` is +updated now. A bug regarding encoding texts is fixed and additionally all +included ``text_keys`` in the meta are transferred into the mdd. Therefore +two new classes are included: ``DimLabels`` and ``DimLabel``. + +--------------- +sd (13/11/2017) +--------------- + +**New** ``DataSet.to_delimited_set(name, label, variables, + from_dichotomous=True, codes_from_name=True)`` + +Creates a new delimited set variable out of other variables. If the input- +variables are dichotomous (``from_dichotomous``), the new value-codes can be +taken from the variable-names or from the order of the variables +(``codes_from_name``). + +"""" + +**Update** ``Stack.aggregate(..., bases={})`` + +A dictionary in form of:: + + bases = { + 'cbase': { + 'wgt': True, + 'unwgt': False}, + 'cbase_gross': { + 'wgt': True, + 'unwgt': True}, + 'ebase': { + 'wgt': False, + 'unwgt': False} + } + +defines what kind of bases will be aggregated. If ``bases`` is provided the +old parameter ``unweighted_base`` and any bases in the parameter ``views`` +will be ignored. If bases is not provided and any base is included in ``views``, +a dictionary is automatically created out of ``views`` and ``unweighted_base``. + +--------------- +sd (17/10/2017) +--------------- + + +**New**: ``del DataSet['var_name']`` and ``'var_name' in DataSet`` syntax support + +It is now possible to test membership of a variable name simply using the ``in`` +operator instead of ``DataSet.var_exists('var_name')`` and delete a variable definition +from ``DataSet`` using the ``del`` keyword inplace of the ``drop('var_name')`` +method. + +"""" + +**New**: ``DataSet.is_single(name)``, ``.is_delimited_set(name)``, ``.is_int(name)``, ``.is_float(name)``, ``.is_string(name)``, ``.is_date(name)``, ``.is_array(name)`` + +These new methods make testing a variable's type easy. + +"""" + +**Update**: ``DataSet.singles(array_items=True)`` and all other non-``array`` type iterators + +It is now possible to exclude ``array`` items from ``singles()``, ``delimited_sets()``, +``ints()`` and ``floats()`` variable lists by setting the new ``array_items`` +parameter to ``False``. + +"""" + +**Update**: ``Batch.set_sigtests(..., flags=None, test_total=None)``, ``Batch.sigproperties`` + +The significancetest-settings for flagging and testing against total, can now +be modified by the two parameters ``flags`` and ``test_total``. The ``Batch`` +attribute ``siglevels`` is removed, instead all sig-settings are stored +in ``Batch.sigproperties``. + +"""" + +**Update**: ``Batch.make_summaries(..., exclusive=False)``, ``Batch.skip_items`` + +The new parameter ``exclusive`` can take a list of arrays or a boolean. If a list +is included, these arrays are added to ``Batch.skip_items``, if it is True all +variables from ``Batch.summaries`` are added to ``Batch.skip_items`` + +"""" + +**Update**: ``quantipy.sandbox.sandbox.Chain.paint(..., totalize=True)`` + +If ``totalize`` is ``True``, ``@``-Total columns of a (x-oriented) ``Chain.dataframe`` +will be painted as ``'Total'`` instead of showing the corresponsing ``x``-variables +question text. + +"""" + +**Update**: ``quantipy.core.weights.Rim.Rake`` + +The weighting algorithm's ``generate_report()`` method can be caught up in a +``MemoryError`` for complex weight schemes run on very large sample sizes. This +is now prevented to ensure the weight factors are computed with priority and +the algorithm is able to terminate correctly. A warning is raised:: + + UserWarning: OOM: Could not finish writing report... + +"""" + +**Update**: ``Batch.replace_y()`` + +Conditional replacements of y-variables of a ``Batch`` will now always also +automatically add the ``@``-Total indicator if not provided. + +"""" + +**Bugfix**: ``DataSet.force_texts(..., overwrite=True)`` + +Forced overwriting of existing ``text_key`` meta data was failing for ``array`` +``mask`` objects. This is now solved. + +"""" + +--------------- +sd (15/09/2017) +--------------- + +**New**: ``DataSet.meta_to_json(key=None, collection=None)`` + +The new method allows saving parts of the metadata as a json file. The parameters +``key`` and ``collection`` define the metaobject which will be saved. + +"""" + +**New**: ``DataSet.save()`` and ``DataSet.revert()`` + +These two new methods are useful in interactive sessions like **Ipython** or +**Jupyter** notebooks. ``save()`` will make a temporary (only im memory, not +written to disk) copy of the ``DataSet`` and store its current state. You can +then use ``revert()`` to rollback to that snapshot of the data at a later +stage (e.g. a complex recode operation went wrong, reloading from the physical files takes +too long...). + +"""" + +**New**: ``DataSet.by_type(types=None)`` + +The ``by_type()`` method is replacing the soon to be deprecated implementation +of ``variables()`` (see below). It provides the same functionality +(``pd.DataFrame`` summary of variable types) as the latter. + +"""" + +**Update**: ``DataSet.variables()`` absorbs ``list_variables()`` and ``variables_from_set()`` + +In conjunction with the addition of ``by_type()``, ``variables()`` is +replacing the related ``list_variables()`` and ``variables_from_set()`` methods in order to offer a unified solution for querying the ``DataSet``\'s (main) variable collection. + +"""" + +**Update**: ``Batch.as_addition()`` + +The possibility to add multiple cell item iterations of one ``Batch`` definition +via that method has been reintroduced (it was working by accident in previous +versions with subtle side effects and then removed). Have fun! + +"""" + +**Update**: ``Batch.add_open_ends()`` + +The method will now raise an ``Exception`` if called on a ``Batch`` that has +been added to a parent one via ``as_addition()`` to warn the user and prevent +errors at the build stage:: + + NotImplementedError: Cannot add open end DataFrames to as_addition()-Batches! + +--------------- +sd (31/08/2017) +--------------- + +**New**: ``DataSet.code_from_label(..., exact=True)`` + +The new parameter ``exact`` is implemented. If ``exact=True`` codes are returned +whose belonging label is equal the included ``text_label``. Otherwise the +method checks if the labels contain the included ``text_label``. + +"""" + +**New**: ``DataSet.order(new_order=None, reposition=None)`` + +This new method can be used to change the global order of the ``DataSet`` +variables. You can either pass a complete ``new_order`` list of variable names to +set the order or provide a list of dictionaries to move (multiple) variables +before a reference variable name. The order is reflected in the case data +``pd.DataFrame.columns`` order and the meta ``'data file'`` ``set`` object's items. + +"""" + +**New**: ``DataSet.dichotomize(name, value_texts=None, keep_variable_text=True, ignore=None, replace=False, text_key=None)`` + +Use this to convert a ``'delimited set'`` variable into a set of binary coded +``'single'`` variables. Variables will have the values 1/0 and by default use +``'Yes'`` / ``'No'`` as the corresponding labels. Use the ``value_texts`` +parameter to apply custom labels. + +"""" + +**New**: ``Batch.extend_x(ext_xks)`` + +The new method enables an easy extension of ``Batch.xks``. In ``ext_xks`` +included ``str`` are added at the end of ``Batch.xks``. Values of included +``dict``\s are positioned in front of the related key. + +"""" + +**Update**: ``Batch.extend_y(ext_yks, ...)`` + +The parameter ``ext_yks`` now also takes ``dict``\s, which define the position +of the additional ``yks``. + +"""" + +**Update**: ``Batch.add_open_ends(..., replacements)`` + +The new parameter ``replacements`` is implemented. The method loops over the +whole pd.DataFrame and replaces all keys of the included ``dict`` +with the belonging value. + +"""" + +**Update**: ``Stack.add_stats(..., other_source)`` + +Statistic views can now be added to delimited sets if ``other_source`` is used. +In this case ``other_source`` must be a single or numerical variable. + +"""" + +**Update**: ``DataSet.validate(..., spss_limits=False)`` + +The new parameter ``spss_limits`` is implemented. If ``spss_limits=True``, the +validate output dataframe is extended by 3 columns which show if the SPSS label +limitations are satisfied. + +"""" + +**Bugfix**: ``DataSet.convert()`` + +A bug that prevented conversions from ``single`` to numeric types has been fixed. + +"""" + +**Bugfix**: ``DataSet.add_meta()`` + +A bug that prevented the creation of numerical arrays outside of ``to.array()`` +has been fixed. It is now possible to create ``array`` metadata without providing +category references. + +"""" + +**Bugfix**: ``Stack.add_stats()`` + +Checking the statistic views is skipped now if no single typed variables are +included even if a checking cluster is provided. + +"""" + +**Bugfix**: ``Batch.copy()`` + +Instead of using a deepcopy of the ``Batch`` instance, a new instance is created +and filled with the attributes of the initial one. Then the copied instance can +be used as additional ``Batch``. + +"""" + +**Bugfix**: ``qp.core.builds.powerpoint`` + +Access to bar-chart series and colour-filling is now working for +different Powerpoint versions. Also a bug is fixed which came up in +``PowerPointpainter()`` for variables which have fixed categories and whose +values are located in ``lib``. + +--------------- +sd (24/07/2017) +--------------- + +**New**: ``qp.set_option()`` + +It is now possible to set library-wide settings registered in ``qp.OPTIONS`` +by providing the setting's name (key) and the desired value. Currently supported +are:: + + OPTIONS = { + 'new_rules': False, + 'new_chains': False, + 'short_item_texts': False + } + +So for example, to work with the currently refactored ``Chain`` interim class +we can use ``qp.set_options('new_chains', True)``. + +"""" + +**New**: ``qp.Batch()`` + +This is a new object aimed at defining and structuring aggregation and build +setups. Please see an :doc:`extensive overview here <../lib_doc/batch/00_overview>`. + +"""" + +**New**: ``Stack.aggregate()`` / ``add_nets()`` / ``add_stats()`` / ``add_tests()`` / ... + +Connected to the new ``Batch`` class, some new ``Stack`` methods to ease up +view creation have been added. You can :doc:`find the docs here <../lib_doc/engine/00_overview>`. + +"""" + +**New**: ``DataSet.populate()`` + +Use this to create a ``qp.Stack`` from ``Batch`` definitions. This connects the +``Batch`` and ``Stack`` objects; check out the :doc:`Batch <../lib_doc/batch/00_overview>` +and :doc:`Analysis & aggregation <../lib_doc/engine/00_overview>` docs. + +"""" + +**New**: ``DataSet.write_dimensions(path_mdd=None, path_ddf=None, text_key=None, mdm_lang='ENG', run=True, clean_up=True)`` + +It is now possible to directly convert a ``DataSet`` into a Dimensions .ddf/.mdd +file pair (given SPSS Data Collection Base Professional is installed on your +machine). By default, files will be saved to the same location in that the +``DataSet`` resides and keep its ``text_key``. + +"""" + +**New**: ``DataSet.repair()`` + +This new method can be used to try to fix common ``DataSet`` metadata problems +stemming from outdated versions, incorrect manual editing of the meta dictionary +or other inconsistencies. The method is checking and repairing following issues: + + * ``'name'`` is present for all variable metadata + * ``'source'`` and ``'subtype'`` references for array variables + * correct ``'lib'``-based ``'values'`` object for array variables + * ``text key``-dependent ``'x edits'`` / ``'y edits'`` meta data + * ``['data file']['items']`` set entries exist in ``'columns'`` / ``'masks'`` + +"""" + +**New**: ``DataSet.subset(variables=None, from_set=None, inplace=False)`` + +As a counterpart to ``filter()``, ``subset()`` can be used to create a new +``DataSet`` that contains only a selection of variables. The new variables +collection can be provided either as a list of names or by naming an already +existing set containing the desired variables. + +"""" + +**New**: ``DataSet.variables_from_set(setname)`` + +Get the list of variables belonging to the passed set indicated by +``setname``. + +"""" + +**New**: ``DataSet.is_like_numeric(name)`` + +A new method to test if all of a ``string`` variable's values can be converted +to a numerical (``int`` / ``float``) type. Returns a boolean ``True`` / ``False``. + +"""" + +**Update**: ``DataSet.convert()`` + +It is now possible to convert inplace from ``string`` to ``int`` / ``float`` if +the respective internal ``is_like_numeric()`` check identifies numeric-like values. + +"""" + +**Update**: ``DataSet.from_components(..., reset=True)``, ``DataSet.read_quantipy(..., reset=True)`` + +Loaded ``.json`` metadata dictionaries will get cleaned now by default from any +user-defined, non-native objects inside the ``'lib'`` and ``'sets'`` +collections. Set ``reset=False`` to keep any extra entires (restoring the old +behaviour). + +"""" + +**Update**: ``DataSet.from_components(data_df, meta_dict=None, ...)`` + +It is now possible to create a ``DataSet`` instance by providing a ``pd.DataFrame`` +alone, without any accompanying meta data. While reading in the case data, the meta +component will be created by inferring the proper ``Quantipy`` variable types +from the ``pandas`` ``dtype`` information. + +"""" + +**Update**: ``Quantity.swap(var, ..., update_axis_def=True)`` + +It is now possible to ``swap()`` the ``'x'`` variable of an array based ``Quantity``, +as long as the length oh the constructing ``'items'`` collection is identical. +In addition, the new parameter ``update_axis_def`` is now by default enforcing +an update of the axis defintions (``pd.DataFrame`` column names, etc) while +previously the method was keeping the original index and column names. The old +behaviour can be restored by setting the parameter to ``False``. + +*Array example*: + +>>> link = stack[name_data]['no_filter']['q5']['@'] +>>> q = qp.Quantity(link) +>>> q.summarize() +Array q5 +Questions q5_1 q5_2 q5_3 q5_4 q5_5 q5_6 +Question Values +q5 All 8255.000000 8255.000000 8255.000000 8255.000000 8255.000000 8255.000000 + mean 26.410297 22.260569 25.181466 39.842883 24.399758 28.972017 + stddev 40.415559 38.060583 40.018463 46.012205 40.537497 41.903322 + min 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 + 25% 3.000000 3.000000 3.000000 3.000000 1.000000 3.000000 + median 5.000000 3.000000 3.000000 5.000000 3.000000 5.000000 + 75% 5.000000 5.000000 5.000000 98.000000 5.000000 97.000000 + max 98.000000 98.000000 98.000000 98.000000 98.000000 98.000000 + +*Updated axis definiton*: + +>>> q.swap('q7', update_axis_def=True) +>>> q.summarize() +Array q7 +Questions q7_1 q7_2 q7_3 q7_4 q7_5 q7_6 +Question Values +q7 All 1195.000000 1413.000000 3378.000000 35.000000 43.000000 36.000000 + mean 5.782427 5.423213 5.795145 4.228571 4.558140 5.333333 + stddev 2.277894 2.157226 2.366247 2.073442 2.322789 2.552310 + min 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 + 25% 4.000000 4.000000 4.000000 3.000000 3.000000 3.000000 + median 6.000000 6.000000 6.000000 4.000000 4.000000 6.000000 + 75% 8.000000 7.000000 8.000000 6.000000 6.000000 7.750000 + max 9.000000 9.000000 9.000000 8.000000 9.000000 9.000000 + +*Original axis definiton*: + +>>> q = qp.Quantity(link) +>>> q.swap('q7', update_axis_def=False) +>>> q.summarize() +Array q5 +Questions q5_1 q5_2 q5_3 q5_4 q5_5 q5_6 +Question Values +q5 All 1195.000000 1413.000000 3378.000000 35.000000 43.000000 36.000000 + mean 5.782427 5.423213 5.795145 4.228571 4.558140 5.333333 + stddev 2.277894 2.157226 2.366247 2.073442 2.322789 2.552310 + min 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 + 25% 4.000000 4.000000 4.000000 3.000000 3.000000 3.000000 + median 6.000000 6.000000 6.000000 4.000000 4.000000 6.000000 + 75% 8.000000 7.000000 8.000000 6.000000 6.000000 7.750000 + max 9.000000 9.000000 9.000000 8.000000 9.000000 9.000000 + + +"""" + +**Update**: ``DataSet.merge_texts()`` + +The method will now always overwrite existing ``text_key`` meta, which makes it +possible to merge ``text``\s from meta of the same ``text_key`` as the master +``DataSet``. + +"""" + +**Bugfix**: ``DataSet.band()`` + +``band(new_name=None)``\'s automatic name generation was incorrectly creating +new variables with the name ``None_banded``. This is now fixed. + +"""" + +**Bugfix**: ``DataSet.copy()`` + +The method will now check if the name of the copy already exists in the +``DataSet`` and drop the referenced variable if found to prevent +inconsistencies. Additionally, it is not longer possible to copy isolated +``array`` items: + +>>> dataset.copy('q5_1') +NotImplementedError: Cannot make isolated copy of array item 'q5_1'. Please copy array variable 'q5' instead! + +--------------- +sd (08/06/2017) +--------------- + + + +**New**: ``DataSet.extend_valid_tks()``, ``DataSet.valid_tks`` + +``DataSet`` has a new attribute ``valid_tks`` that contains a list of all valid +textkeys. All methods that take a textkey as parameter are checked against that +list. + +If a datafile contains a special/ unusual textkey (for example ``'id-ID'`` or +``'zh-TW'``), the list can be extended with ``DataSet.extend_valid_tks()``. +This extension can also be used to create a textkey for special conditions, +for example to create texts only for powerpoint outputs:: + + >>> dataset.extend_valid_tks('pptx') + >>> dataset.force_texts('pptx', 'en-GB') + >>> dataset.set_variable_text('gender','Gender label for pptx', text_key='pptx') + +"""" + +**New**: Equal error messages + +All methods that use the parameters ``name``/``var``, ``text_key`` or +``axis_edit``/ ``axis`` now have a decorator that checks the provided values. +The following shows a few examples for the new error messages: + +``name`` & ``var``:: + + 'name' argument for meta() must be in ['columns', 'masks']. + q1 is not in ['columns', 'masks']. + +``text_key``:: + + 'en-gb' is not a valid text_key! Supported are: ['en-GB', 'da-DK', 'fi-FI', 'nb-NO', 'sv-SE', 'de-DE'] + +``axis_edit`` & ``axis``:: + + 'xs' is not a valid axis! Supported are: ['x', 'y'] + +"""" + +**New**: ``DataSet.repair_text_edits(text_key)`` + +This new method can be used in trackers, that were drawn up in an older ``Quantipy`` +version. Text objects can be repaired if are not well prepared, for example if +it looks like this:: + + {'en-GB': 'some English text', + 'sv_SE': 'some Swedish text', + 'x edits': 'new text'} + +``DataSet.repair_text_edits()`` loops over all text objects in the dataset and +matches the ``x edits`` and ``y edits`` texts to all included textkeys:: + + >>> dataset.repair_text_edits(['en-GB', 'sv-SE']) + {'en-GB': 'some English text', + 'sv_SE': 'some Swedish text', + 'x edits': {'en-GB': new text', 'sv-SE': 'new text'}} + +"""" + +**Update**: ``DataSet.meta()``/ ``.text()``/ ``.values()``/ ``.value_texts()``/ ``.items()``/ ``.item_texts()`` + +All these methods now can take the parameters ``text_key`` and ``axis_edit``. +The related text is taken from the meta information and shown in the output. +If a text key or axis edit is not included the text is returned as None. + +"""" + +**Update**: ``DataSet.compare(dataset, variables=None, strict=False, text_key=None)`` + +The method is totally updated, works more precise and contains a few new +features. Generally variables included in ``dataset`` are compared with +eponymous variables in the main ``DataSet`` instance. You can specify witch +``variables`` should be compared, if question/ value texts should be compared +``strict`` or not and for which ``text_key``. + +"""" + +**Update**: ``DataSet.validate(verbose=True)`` + +A few new features are tested now and the output has changed. Set ``verbose=True`` +to see the definitions of the different error columns:: + + name: column/mask name and meta[collection][var]['name'] are not identical + + q_label: text object is badly formated or has empty text mapping + + values: categorical var does not contain values, value text is badly + formated or has empty text mapping + + textkeys: dataset.text_key is not included or existing tks are not + consistent (also for parents) + + source: parents or items do not exist + + codes: codes in .data are not included in .meta + +"""" + +**Update**: ``DataSet.sorting()`` / ``.slicing()`` / ``.hiding()`` + +These methods will now also work on lists of variable names. + +"""" + +**Update**: ``DataSet.set_variable_text()``, ``Dataset.set_item_texts()`` + +If these methods are applied to an array item, the new variable text is also +included in the meta information of the parent array. The same works also the +other way around, if an array text is set, then the array item texts are modified. + +"""" + +**Update**: ``DataSet.__init__(self, name, dimensions_comp=True)`` + +A few new features are included to handle data coming from Crunch. While +initializing a new ``DataSet`` instance dimensions compatibility can be set to +False. In the custom template use ``t.get_qp_dataset(name, dim_comp=False)`` +in the load cells. + +"""" + +**Bugfix**: ``DataSet.hmerge()`` + +If ``right_on`` and ``left_on`` are used and ``right_on`` is also included in +the main file, it is not overwritten any more. + +--------------- +sd (17/05/2017) +--------------- + +**Update**: ``DataSet.set_variable_text(..., axis_edit=None)``, ``DataSet.set_value_texts(..., axis_edit=False)`` + +The new ``axis_edit`` argument can be used with one of ``'x'``, ``'y'`` or ``['x', 'y']`` to instruct a text metadata change that will only be visible in build exports. + +.. warning:: + In a future version ``set_col_text_edit()`` and ``set_val_text_text()`` will + be removed! The identical functionality is provided via this ``axis_edit`` parameter. + +"""" + +**Update**: ``DataSet.replace_texts(..., text_key=None)`` + +The method loops over all meta text objects and replaces unwanted strings. +It is now possible to perform the replacement only for specified ``text_key``\s. +If ``text_key=None`` the method replaces the strings for all ``text_key``\s. + +"""" + +**Update**: ``DataSet.force_texts(copy_to=None, copy_from=None, update_existing=False)`` + +The method is now only able to force texts for all meta text objects (for +single variables use the methods ``set_variable_text()`` and +``set_value_texts()``). + +"""" + +**Bugfix**: ``DataSet.copy()`` + +Copied variables get the tag ``created`` and can be listed with +``t.list_variables(dataset, 'created')``. + +"""" + +**Bugfix**: ``DataSet.hmerge()``, ``DataSet.vmerge()`` + +Array meta information in merged datafiles is now updated correctly. + +--------------- +sd (04/05/2017) +--------------- + +**New**: ``DataSet.var_exists()`` + +Returns True if the input variable/ list of variables are included in the +``DataSet`` instance, otherwise False. + +"""" + +**New**: ``DataSet.remove_html()``, ``DataSet.replace_texts(replace)`` + +The ``DataSet`` method ``clean_texts()`` has been removed and split into two +methods to make usage more clear: ``remove_html()`` will strip all ``text`` +metadata objects from any html and formatting tags. ``replace_texts()`` will +use a ``dict`` mapping of old to new ``str`` terms to change the matching +``text`` throughout the ``DataSet`` metadata. + +"""" + +**New**: ``DataSet.item_no(name)`` + +This method will return the positional index number of an array item, e.g.: + +>>> dataset.item_no('Q4A[{q4a_1}].Q4A_grid') +1 + +"""" + +**New**: ``QuantipyViews``: ``counts_cumsum``, ``c%_cumsum`` + +These two new views contain frequencies with cumulative sums which are computed +over the x-axis. + +"""" + +**Update**: ``DataSet.text(name, shorten=True)`` + +The new parameter ``shorten`` is now controlling if the variable ``text`` metadata +of array masks will be reported in short format, i.e. without the corresponding +mask label text. This is now also the default behaviour. + +"""" + +**Update**: ``DataSet.to_array()`` + +Created mask meta information now also contains keys ``parent`` and ``subtype``. +Variable names are compatible with crunch and dimensions meta: + +Example in Dimensions modus: + +>>> dataset.to_array('Q11', ['Q1', 'Q2', 'Q3', 'Q4', 'Q5'], 'label') + +The new grid is named ``'Q11.Q11_grid'`` and the source/column variables are +``'Q11[{Q1}].-Q11_grid'`` - ``'Q11[{Q5}].-Q11_grid'``. + +"""" + +**Bugfix**: ``DataSet.derotate()`` + +Meta is now Crunch and Dimensions compatible. Also mask meta information are updated. + +--------------- +sd (24/04/2017) +--------------- + +**Update**: ``DataSet.hiding(..., hide_values=True)`` + +The new parameter ``hide_values`` is only necessary if the input variable is a +mask. If ``False``, mask items are hidden, if ``True`` mask values are hidden +for all mask items and for array summary sheets. + +"""" + +**Bugfix**: ``DataSet.set_col_text_edit(name)`` + +If the input variable is an array item, the new column text is also added to +``meta['mask'][name]['items]``. + + +"""" + +**Bugfix**: ``DataSet.drop(name, ignore_items=False)`` + +If a mask is dropped, but the items are kept, all items are handled now as +individual variables and their meta information is not stored in ``meta['lib']`` +anymore. + +--------------- +sd (06/04/2017) +--------------- + +Only small adjustments. + +--------------- +sd (29/03/2017) +--------------- + +**New**: ``DataSet.codes_in_data(name)`` + +This method returns a list of codes that exist in the data of a variable. This +information can be used for more complex recodes, for example copying a variable, +but keeping only all categories with more than 50 ratings, e.g.: + +>>> valid_code = dataset.codes_in_data('varname') +>>> keep_code = [x for x in valid_code if dataset['varname'].value_counts()[x] > 49] +>>> dataset.copy('varname', 'rc', copy_only=keep_code) + +"""" + +**Update**: ``DataSet.copy(..., copy_not=None)`` + +The new parameter ``copy_not`` takes a list of codes that should be ignored +for the copied version of the provided variable. The metadata of the copy will +be reduced as well. + +"""" + +**Update**: ``DataSet.code_count()`` + +This method is now alligned with ``any()`` and ``all()`` in that it can be used +on ``'array'`` variables as well. In such a case, the resulting ``pandas.Series`` +is reporting the number of answer codes found across all items per case data +row, i.e.: + +>>> code_count = dataset.code_count('Q4A.Q4A_grid', count_only=[3, 4]) +>>> check = pd.concat([dataset['Q4A.Q4A_grid'], code_count], axis=1) +>>> check.head(10) + Q4A[{q4a_1}].Q4A_grid Q4A[{q4a_2}].Q4A_grid Q4A[{q4a_3}].Q4A_grid 0 +0 3.0 3.0 NaN 2 +1 NaN NaN NaN 0 +2 3.0 3.0 4.0 3 +3 5.0 4.0 2.0 1 +4 4.0 4.0 4.0 3 +5 4.0 5.0 4.0 2 +6 3.0 3.0 3.0 3 +7 4.0 4.0 4.0 3 +8 6.0 6.0 6.0 0 +9 4.0 5.0 5.0 1 + +"""" + +--------------- +sd (20/03/2017) +--------------- + +**New**: ``qp.DataSet(dimensions_comp=True)`` + +The ``DataSet`` class can now be explicitly run in a Dimensions compatibility +mode to control the naming conventions of ``array`` variables ("grids"). This +is also the default behaviour for now. This comes with a few changes related to +meta creation and variable access using ``DataSet`` methods. Please see a brief +case study on this topic :doc:`here <how_to_snippets/dimensions_comp>`. + +"""" + +**New**: enriched ``items`` / ``masks`` meta data + +``masks`` will now also store the ``subtype`` (``single``, ``delimited set``, etc.) +while ``items`` elements will now contain a reference to the defining ``masks`` +entrie(s) in a new ``parent`` object. + +"""" + +**Update**: ``DataSet.weight(..., subset=None)`` + +Filters the dataset by giving a Quantipy complex logic expression and weights +only the remaining subset. + +"""" + +**Update**: Defining categorical ``values`` meta and ``array`` items + +Both ``values`` and ``items`` can now be created in three different ways when +working with the ``DataSet`` methods ``add_meta()``, ``extend_values()`` and +``derive()``: (1) Tuples that map element code to label, (2) only labels or (3) +only element codes. Please see quick guide on that :doc:`here <how_to_snippets/create_categorical_meta>` + +--------------- +sd (07/03/2017) +--------------- + +**Update**: ``DataSet.code_count(..., count_not=None)`` + +The new parameter ``count_not`` can be used to restrict the set of codes feeding +into the resulting ``pd.Series`` by exclusion (while ``count_only`` restricts +by inclusion). + +"""" + +**Update**: ``DataSet.copy(..., copy_only=None)`` + +The new parameter ``copy_only`` takes a list of codes that should be included +for the copied version of the provided variable, all others will be ignored +and the metadata of the copy will be reduced as well. + +"""" + +**Bugfix**: ``DataSet.band()`` + +There was a bug that was causing the method to crash for negative values. It is +now possible to create negative single value bands, while negative ranges +(lower and/or upper bound < 0) will raise a ``ValueError``. + +"""" + +--------------- +sd (24/02/2017) +--------------- + +* Some minor bugfixes and updates. Please use latest version. + +"""" + +--------------- +sd (16/02/2017) +--------------- + +**New:** ``DataSet.derotate(levels, mapper, other=None, unique_key='identity', dropna=True)`` + +Create a derotated ("levelled", responses-to-cases) ``DataSet`` instance by +defining level variables, looped variables and other (simple) variables that +should be added. + +View more information on the topic :doc:`here <how_to_snippets/derotate>`. + +"""" + +**New:** ``DataSet.to_array(name, variables, label)`` + +Combine ``column`` variables with identical ``values`` objects to an ``array`` +incl. all required ``meta['masks']`` information. + +"""" + +**Update:** ``DataSet.interlock(..., variables)`` + +It is now possible to add ``dict``\s to ``variables``. In these ``dict``\s a +``derive()``-like mapper can be included which will then create a temporary +variable for the interlocked result. Example: + +>>> variables = ['gender', +... {'agegrp': [(1, '18-34', {'age': frange('18-34')}), +... (2, '35-54', {'age': frange('35-54')}), +... (3, '55+', {'age': is_ge(55)})]}, +... 'region'] +>>> dataset.interlock('new_var', 'label', variables) + +"""" + +--------------- +sd (04/01/2017) +--------------- + +**New:** ``DataSet.flatten(name, codes, new_name=None, text_key=None)`` + +Creates a new ``delimited set`` variable that groups ``grid item`` answers to +categories. The ``items`` become ``values`` of the new variable. If an +``item`` contains one of the ``codes`` it will be counted towards the categorical +case data of the new variable. + +"""" + +**New:** ``DataSet.uncode(target, mapper, default=None, intersect=None, inplace=True)`` + +Remove codes from the ``target`` variable's data component if a logical +condition is satisfied. + +"""" + +**New:** ``DataSet.text(var, text_key=None)`` + +Returns the question text label (per ``text_key``) of a variable. + +"""" + +**New:** ``DataSet.unroll(varlist, keep=None, both=None)`` + +Replaces ``masks`` names inside ``varlist`` with their ``items``. Optionally, +individual ``masks`` can be excluded or kept inside the list. + +"""" + +**New:** ``DataSet.from_stack(stack, datakey=None)`` + +Create a ``quantipy.DataSet`` from the ``meta``, ``data``, ``data_key`` and +``filter`` definition of a ``quantipy.Stack`` instance. + +"""" + +--------------- +sd (8/12/2016) +--------------- + +**New:** + +``DataSet.from_excel(path_xlsx, merge=True, unique_key='identity')`` + +Returns a new ``DataSet`` instance with ``data`` from ``excel``. The ``meta`` +for all variables contains ``type='int'``. + +Example: ``new_ds = dataset.from_excel(path, True, 'identity')`` + +The function is able to modify ``dataset`` inplace by merging ``new_ds`` on +``identity``. + +"""" + +**Update:** + +``DataSet.copy(..., slicer=None)`` + +It is now possible to filter the data that statisfies the logical condition +provided in the ``slicer``. +Example: + +>>> dataset.copy('q1', 'rec', True, {'q1': not_any([99])}) + +"""" + +--------------- +sd (23/11/2016) +--------------- + +**Update:** + +``DataSet.rename(name, new_name=None, array_item=None)`` + +The function is able to rename ``columns``, ``masks`` or ``mask items``. +``maks items`` are changed by position. + +"""" + +**Update:** + +``DataSet.categorize(..., categorized_name=None)`` + +Provide a custom name string for ``categorized_name`` will change the default +name of the categorized variable from ``OLD_NAME#`` to the passed string. + + +"""" + +--------------- +sd (16/11/2016) +--------------- + +**New:** + +``DataSet.check_dupe(name='identity')`` + +Returns a list with duplicated values for the variable provided via ``name``. +Identifies for example duplicated identities. + +"""" + +**New:** + +``DataSet.start_meta(text_key=None)`` + +Creates an empty QP meta data document blueprint to add variable definitions to. + +"""" + +**Update:** + +.. code-block:: python + + DataSet.create_set(setname='new_set', based_on='data file', included=None, + ... excluded=None, strings='keep', arrays='both', replace=None, + ... overwrite=False) + +Add a new ``set`` to the ``meta['sets']`` object. Variables from an existing +``set`` (``based_on``) can be ``included`` to ``new_set`` or varibles can be +``excluded`` from ``based_on`` with customized lists of variables. +Control ``string`` variables and ``masks`` with the ``kwargs`` ``strings`` and +``arrays``. ``replace`` single variables in ``new_set`` with a ``dict`` . + +"""" + +**Update:** + +``DataSet.from_components(..., text_key=None)`` + +Will now accept a ``text_key`` in the method call. If querying a ``text_key`` +from the meta component fails, the method will no longer crash, but raise a +``warning`` and set the ``text_key`` to ``None``. + +"""" + +**Update:** + +.. line-block:: + + ``DataSet.as_float()`` + ``DataSet.as_int()`` + ``DataSet.as_single()`` + ``DataSet.as_delimited_set()`` + ``DataSet.as_string()`` + ``DataSet.band_numerical()`` + ``DataSet.derive_categorical()`` + ``DataSet.set_mask_text()`` + ``DataSet.set_column_text()`` + +These methods will now print a ``UserWarning`` to prepare for the soon to +come removal of them. + +"""" + +**Bugfix:** + +``DataSet.__setitem__()`` + +Trying to set ``np.NaN`` was failing the test against meta data for categorical +variables and was raising a ``ValueError`` then. This is fixed now. + +"""" + +--------------- +sd (11/11/2016) +--------------- + +**New:** + +.. line-block:: + + ``DataSet.columns`` + ``DataSet.masks`` + ``DataSet.sets`` + ``DataSet.singles`` + ``DataSet.delimited_sets`` + ``DataSet.ints`` + ``DataSet.floats`` + ``DataSet.dates`` + ``DataSet.strings`` + +New ``DataSet`` instance attributes to quickly return the list of ``columns``, +``masks`` and ``sets`` objects from the meta or query the variables by +``type``. Use this to check for variables, iteration, inspection, ect. + +"""" + +**New:** + +``DataSet.categorize(name)`` + +Create a categorized version of ``int/string/date`` variables. New variables +will be named as per ``OLD_NAME#`` + +"""" + +**New:** + +``DataSet.convert(name, to)`` + +Wraps the individual ``as_TYPE()`` conversion methods. ``to`` must be one of +``'int', 'float', 'string', 'single', 'delimited set'``. + +"""" + +**New:** + +``DataSet.as_string(name)`` + +Only for completeness: Use ``DataSet.convert(name, to='string')`` instead. + +Converts ``int/float/single/date`` typed variables into a ``string`` and +removes all categorical metadata. + +"""" + +**Update:** + +``DataSet.add_meta()`` + +Can now add ``date`` and ``text`` type meta data. + +"""" + +**Bugfix:** + +``DataSet.vmerge()`` + +If ``masks`` in the right ``dataset``, that also exist in the left ``dataset``, +have new ``items`` or ``values``, they are added to ``meta['masks']``, +``meta['lib']`` and ``meta['sets']``. + +"""" + +--------------- +sd (09/11/2016) +--------------- + +**New:** + +``DataSet.as_float(name)`` + +Converts ``int/single`` typed variables into a ``float`` and removes +all categorical metadata. + +"""" + +**New:** + +``DataSet.as_int(name)`` + +Converts ``single`` typed variables into a ``int`` and removes +all categorical metadata. + +"""" + +**New:** + +``DataSet.as_single(name)`` + +Converts ``int`` typed variables into a ``single`` and adds numeric values as +categorical metadata. + +"""" + +**New:** + +``DataSet.create_set(name, variables, blacklist=None)`` + +Adds a new ``set`` to ``meta['sets']`` object. Create easily ``sets`` from +other ``sets`` while using customised ``blacklist``. + +"""" + +**New:** + +``DataSet.drop(name, ignore_items=False)`` + +Removes all metadata and data referenced to the variable. When passing an +``array mask``, ``ignore_items`` can be ste to ``True`` to keep the ``item +columns`` incl. their metadata. + +"""" + +**New:** + +``DataSet.compare(dataset=None, variables=None)`` + +Compare the metadata definition between the current and another ``dataset``, +optionally restricting to a pair of variables. + +"""" + +**Update:** + +``DataSet.__setitem__()`` + +``[..]``-Indexer now checks scalars against categorical meta. + diff --git a/docs/API/_build/html/_sources/sites/release_notes/03_how_to_snippets.rst.txt b/docs/API/_build/html/_sources/sites/release_notes/03_how_to_snippets.rst.txt new file mode 100644 index 000000000..2b4fb423f --- /dev/null +++ b/docs/API/_build/html/_sources/sites/release_notes/03_how_to_snippets.rst.txt @@ -0,0 +1,12 @@ + + +=============== +How-to-snippets +=============== + +.. toctree:: + :maxdepth: 5 + + how_to_snippets/dimensions_comp + how_to_snippets/create_categorical_meta + how_to_snippets/derotate \ No newline at end of file diff --git a/docs/API/_build/html/_sources/sites/release_notes/how_to_snippets/create_categorical_meta.rst.txt b/docs/API/_build/html/_sources/sites/release_notes/how_to_snippets/create_categorical_meta.rst.txt new file mode 100644 index 000000000..857337f02 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/release_notes/how_to_snippets/create_categorical_meta.rst.txt @@ -0,0 +1,66 @@ +.. toctree:: + :maxdepth: 5 + :hidden: + +============================================= +Different ways of creating categorical values +============================================= + +The ``DataSet`` methods ``add_meta()``, ``extend_values()`` and ``derive()`` +offer three alternatives for specifying the categorical values of ``'single'`` +and ``'delimited set'`` typed variables. The approaches differ with respect to +how the mapping of numerical value codes to value text labels is handled. + +**(1) Providing a list of text labels** + +By providing the category labels only as a list of ``str``, ``DataSet`` +is going to create the numerical codes by simple enumeration: + +>>> name, qtype, label = 'test_var', 'single', 'The test variable label' + +>>> cats = ['test_cat_1', 'test_cat_2', 'test_cat_3'] +>>> dataset.add_meta(name, qtype, label, cats) + +>>> dataset.meta('test_var') +single codes texts missing +test_var: The test variable label +1 1 test_cat_1 None +2 2 test_cat_2 None +3 3 test_cat_3 None + +**(2) Providing a list of numerical codes** + +If only the desired numerical codes are provided, the label information for all +categories consequently will appear blank. In such a case the user will, however, +get reminded to add the ``'text'`` meta in a separate step: + +>>> cats = [1, 2, 98] +>>> dataset.add_meta(name, qtype, label, cats) +...\\quantipy\core\dataset.py:1287: UserWarning: 'text' label information missing, +only numerical codes created for the values object. Remember to add value 'text' metadata manually! + +>>> dataset.meta('test_var') +single codes texts missing +test_var: The test variable label +1 1 None +2 2 None +3 98 None + +**(3) Pairing numerical codes with text labels** + +To explicitly assign codes to corresponding labels, categories can also be +defined as a list of tuples of codes and labels: + +>>> cats = [(1, 'test_cat_1') (2, 'test_cat_2'), (98, 'Don\'t know')] +>>> dataset.add_meta(name, qtype, label, cats) + +>>> dataset.meta('test_var') +single codes texts missing +test_var: The test variable label +1 1 test_cat_1 None +2 2 test_cat_2 None +3 98 Don't know None + +.. note:: + All three approaches are also valid for defining the ``items`` object for + ``array``-typed ``masks``. \ No newline at end of file diff --git a/docs/API/_build/html/_sources/sites/release_notes/how_to_snippets/derotate.rst.txt b/docs/API/_build/html/_sources/sites/release_notes/how_to_snippets/derotate.rst.txt new file mode 100644 index 000000000..7e5abcc17 --- /dev/null +++ b/docs/API/_build/html/_sources/sites/release_notes/how_to_snippets/derotate.rst.txt @@ -0,0 +1,182 @@ +.. toctree:: + :maxdepth: 5 + :hidden: + +========== +Derotation +========== + +------------------ +What is derotation +------------------ + +Derotation of ``data`` is necessary if brands, products or something similar +(**levels**) are assessed and each respondent (case) rates a different +selection of that levels. So each **case** has several **responses**. +Derotation now means, that the ``data`` is switched from case-level to +responses-level. + +**Example**: ``q1_1/q1_2``: On a scale from 1 to 10, how much do you like the +following drinks? + +| 1: water +| 2: cola +| 3: lemonade +| 4: beer +| + +**``data``** + ++-------+---------+---------+------+------+--------+ +| id | drink_1 | drink_2 | q1_1 | q1_2 | gender | ++-------+---------+---------+------+------+--------+ +| case1 | 1 | 3 | 2 | 8 | 1 | ++-------+---------+---------+------+------+--------+ +| case2 | 1 | 4 | 9 | 5 | 2 | ++-------+---------+---------+------+------+--------+ +| case3 | 2 | 4 | 6 | 10 | 1 | ++-------+---------+---------+------+------+--------+ + +**derotated ``data``** + ++-------+-------+----------------+----+--------+ +| | drink | drink_levelled | q1 | gender | ++-------+-------+----------------+----+--------+ +| case1 | 1 | 1 | 2 | 1 | ++-------+-------+----------------+----+--------+ +| case1 | 2 | 3 | 8 | 1 | ++-------+-------+----------------+----+--------+ +| case2 | 1 | 1 | 9 | 2 | ++-------+-------+----------------+----+--------+ +| case2 | 2 | 4 | 5 | 2 | ++-------+-------+----------------+----+--------+ +| case3 | 1 | 2 | 6 | 1 | ++-------+-------+----------------+----+--------+ +| case3 | 2 | 4 | 10 | 1 | ++-------+-------+----------------+----+--------+ + +To identify which case rates which levels, some key-/level-variables are +included in the ``data``, in this example ``drink_1`` and ``drink_2``. +Variables (for example ``gender``) that are not included to this loop can also +be added. + +--------------------------------- +How to use ``DataSet.derotate()`` +--------------------------------- + +The ``DataSet`` method takes a few parameters: + +* ``levels``: ``dict`` of ``list`` + + Contains all key-/level-variables and the name for the new levelled variable. + All key-/level-variables must have the same ``value_map``. + + >>> levels = {'drink': ['drink_1', 'drink_2']} + + +| + +* ``mapper``: ``list`` of ``dicts`` of ``list`` + + Contains the looped questions and the new ``column`` name to which the + looped questions will be combinded. + + >>> mapper = [{'q1': ['q1_1', 'q1_2']}] + +| + +* ``other``: ``str`` or ``list`` of ``str`` + + Contains all variables that should be assumed to the derotated ``data``, but + which are not included in the loop. + + >>> other = 'gender' + +| + +* ``unique_key``: ``str`` + + Name of varibale that identifies cases in the initial ``data``. + + >>> unique_key = 'id' + +| + +* ``dropna``: ``bool``, default ``True`` + + If a case rates less then the possible counts of levels, these responses + will be droped. + +>>> ds = dataset.derotate(levels = {'drink': ['drink_1', 'drink_2']}, +... mapper = [{'q1': ['q1_1', 'q1_2']}], +... other = 'gender', +... unique_key = 'id', +... dropna = True) + +---------------------- +What about ``arrays``? +---------------------- + +It is possible that also ``arrays`` are looped. In this case a mapper can look +like this: + +>>> mapper = [{'q12_1': ['q12a[{q12a_1}].q12a_grid', 'q12b[{q12b_1}].q12b_grid', +... 'q12c[{q12c_1}].q12c_grid', 'q12d[{q12d_1}].q12d_grid']}, +... {'q12_2': ['q12a[{q12a_2}].q12a_grid', 'q12b[{q12b_2}].q12b_grid', +... 'q12c[{q12c_2}].q12c_grid', 'q12d[{q12d_2}].q12d_grid']}, +... {'q12_3': ['q12a[{q12a_3}].q12a_grid', 'q12b[{q12b_3}].q12b_grid', +... 'q12c[{q12c_3}].q12c_grid', 'q12d[{q12d_3}].q12d_grid']}, +... {'q12_4': ['q12a[{q12a_4}].q12a_grid', 'q12b[{q12b_4}].q12b_grid', +... 'q12c[{q12c_4}].q12c_grid', 'q12d[{q12d_4}].q12d_grid']}, +... {'q12_5': ['q12a[{q12a_5}].q12a_grid', 'q12b[{q12b_5}].q12b_grid', +... 'q12c[{q12c_5}].q12c_grid', 'q12d[{q12d_5}].q12d_grid']}, +... {'q12_6': ['q12a[{q12a_6}].q12a_grid', 'q12b[{q12b_6}].q12b_grid', +... 'q12c[{q12c_6}].q12c_grid', 'q12d[{q12d_6}].q12d_grid']}, +... {'q12_7': ['q12a[{q12a_7}].q12a_grid', 'q12b[{q12b_7}].q12b_grid', +... 'q12c[{q12c_7}].q12c_grid', 'q12d[{q12d_7}].q12d_grid']}, +... {'q12_8': ['q12a[{q12a_8}].q12a_grid', 'q12b[{q12b_8}].q12b_grid', +... 'q12c[{q12c_8}].q12c_grid', 'q12d[{q12d_8}].q12d_grid']}, +... {'q12_9': ['q12a[{q12a_9}].q12a_grid', 'q12b[{q12b_9}].q12b_grid', +... 'q12c[{q12c_9}].q12c_grid', 'q12d[{q12d_9}].q12d_grid']}, +... {'q12_10': ['q12a[{q12a_10}].q12a_grid', 'q12b[{q12b_10}].q12b_grid', +... 'q12c[{q12c_10}].q12c_grid', 'q12d[{q12d_10}].q12d_grid']}, +... {'q12_11': ['q12a[{q12a_11}].q12a_grid', 'q12b[{q12b_11}].q12b_grid', +... 'q12c[{q12c_11}].q12c_grid', 'q12d[{q12d_11}].q12d_grid']}, +... {'q12_12': ['q12a[{q12a_12}].q12a_grid', 'q12b[{q12b_12}].q12b_grid', +... 'q12c[{q12c_12}].q12c_grid', 'q12d[{q12d_12}].q12d_grid']}, +... {'q12_13': ['q12a[{q12a_13}].q12a_grid', 'q12b[{q12b_13}].q12b_grid', +... 'q12c[{q12c_13}].q12c_grid', 'q12d[{q12d_13}].q12d_grid']}]] + +Can be also writen like this: + +>>> for y in frange('1-13'): +... q_group = [] +... for x in ['a', 'b', 'c', 'd']: +... var = 'q12{}'.format(x) +... var_grid = var + '[{' + var + '_{}'.format(y) + '}].' + var + '_grid' +... q_group.append(var_grid) +... mapper.append({'q12_{}'.format(y): q_group}) + +So the derotated ``dataset`` will lose its ``meta`` information about the +``mask`` and only the ``columns`` ``q12_1`` to ``q12_13`` will be added. To +receive back the ``mask`` structure, use the method ``dataset.to_array()``: + +>>> variables = [{'q12_1': u'label 1'}, +... {'q12_2': u'label 2'}, +... {'q12_3': u'label 3'}, +... {'q12_4': u'label 4'}, +... {'q12_5': u'label 5'}, +... {'q12_6': u'label 6'}, +... {'q12_7': u'label 7'}, +... {'q12_8': u'label 8'}, +... {'q12_9': u'label 9'}, +... {'q12_10': u'label 10'}, +... {'q12_11': u'label 11'}, +... {'q12_12': u'label 12'}, +... {'q12_13': u'label 13'}] +>>> ds.to_array('qTP', variables, 'Var_name') + +``variables`` can also be a list of variable-names, then the ``mask-items`` +will be named by its belonging ``columns``. + +``arrays`` included in ``other`` will keep their ``meta`` structure. \ No newline at end of file diff --git a/docs/API/_build/html/_sources/sites/release_notes/how_to_snippets/dimensions_comp.rst.txt b/docs/API/_build/html/_sources/sites/release_notes/how_to_snippets/dimensions_comp.rst.txt new file mode 100644 index 000000000..889f9208b --- /dev/null +++ b/docs/API/_build/html/_sources/sites/release_notes/how_to_snippets/dimensions_comp.rst.txt @@ -0,0 +1,110 @@ +.. toctree:: + :maxdepth: 5 + :hidden: + +==================================== +``DataSet`` Dimensions compatibility +==================================== + +DTO-downloaded and Dimensions converted variable naming conventions are following +specific rules for ``array`` names and corresponding ``ìtems``. ``DataSet`` +offers a compatibility mode for Dimensions scenarios and handles the proper +renaming automatically. Here is what you should know... + +---------------------- +The compatibility mode +---------------------- + +A ``DataSet`` will (by default) support Dimensions-like ``array`` naming for its connected data files when constructed. An ``array`` ``masks`` meta defintition +of a variable called ``q5`` looking like this...:: + + {u'items': [{u'source': u'columns@q5_1', u'text': {u'en-GB': u'Surfing'}}, + {u'source': u'columns@q5_2', u'text': {u'en-GB': u'Snowboarding'}}, + {u'source': u'columns@q5_3', u'text': {u'en-GB': u'Kite boarding'}}, + {u'source': u'columns@q5_4', u'text': {u'en-GB': u'Parachuting'}}, + {u'source': u'columns@q5_5', u'text': {u'en-GB': u'Cave diving'}}, + {u'source': u'columns@q5_6', u'text': {u'en-GB': u'Windsurfing'}}], + u'subtype': u'single', + u'text': {u'en-GB': u'How likely are you to do each of the following in the next year?'}, + u'type': u'array', + u'values': u'lib@values@q5'} + +...will be converted into its "Dimensions equivalent" as per: + +>>> dataset = qp.DataSet(name_data, dimensions_comp=True) +>>> dataset.read_quantipy(path_data+name_data, path_data+name_data) +DataSet: ../Data/Quantipy/Example Data (A) +rows: 8255 - columns: 75 +Dimensions compatibilty mode: True + +>>> dataset.masks() +['q5.q5_grid', 'q6.q6_grid', 'q7.q7_grid'] + +>>> dataset._meta['masks']['q5.q5_grid'] +{u'items': [{u'source': 'columns@q5[{q5_1}].q5_grid', + u'text': {u'en-GB': u'Surfing'}}, + {u'source': 'columns@q5[{q5_2}].q5_grid', + u'text': {u'en-GB': u'Snowboarding'}}, + {u'source': 'columns@q5[{q5_3}].q5_grid', + u'text': {u'en-GB': u'Kite boarding'}}, + {u'source': 'columns@q5[{q5_4}].q5_grid', + u'text': {u'en-GB': u'Parachuting'}}, + {u'source': 'columns@q5[{q5_5}].q5_grid', + u'text': {u'en-GB': u'Cave diving'}}, + {u'source': 'columns@q5[{q5_6}].q5_grid', + u'text': {u'en-GB': u'Windsurfing'}}], + 'name': 'q5.q5_grid', + u'subtype': u'single', + u'text': {u'en-GB': u'How likely are you to do each of the following in the next year?'}, + u'type': u'array', + u'values': 'lib@values@q5.q5_grid'} + +------------------------------------- +Accessing and creating ``array`` data +------------------------------------- + +Since new names are converted automatically by ``DataSet`` methods, there is +no need to write down the full (DTO-like) Dimensions ``array`` name when adding +new metadata. However, querying variables is always requiring the proper name: + +>>> name, qtype, label = 'array_var', 'single', 'ARRAY LABEL' +>>> cats = ['A', 'B', 'C'] +>>> items = ['1', '2', '3'] +>>> dataset.add_meta(name, qtype, label, cats, items) + +>>> dataset.masks() +['q5.q5_grid', 'array_var.array_var_grid', 'q6.q6_grid', 'q7.q7_grid'] + +>>> dataset.meta('array_var.array_var_grid') +single items item texts codes texts missing +array_var.array_var_grid: ARRAY LABEL +1 array_var[{array_var_1}].array_var_grid 1 1 A None +2 array_var[{array_var_2}].array_var_grid 2 2 B None +3 array_var[{array_var_3}].array_var_grid 3 3 C None + +>>> dataset['array_var.array_var_grid'].head(5) + array_var[{array_var_1}].array_var_grid array_var[{array_var_2}].array_var_grid array_var[{array_var_3}].array_var_grid +0 NaN NaN NaN +1 NaN NaN NaN +2 NaN NaN NaN +3 NaN NaN NaN +4 NaN NaN NaN + +As can been seen above, both the ``masks`` name as well as the ``array`` item +elements are being properly converted to match DTO/Dimensions +conventions. + +When using ``rename()``, ``copy()`` or ``transpose()``, the same behaviour +applies: + +>>> dataset.rename('q6.q6_grid', 'q6new') +>>> dataset.masks() +['q5.q5_grid', 'array_var.array_var_grid', 'q6new.q6new_grid', 'q7.q7_grid'] + +>>> dataset.copy('q6new.q6new_grid', suffix='q6copy') +>>> dataset.masks() +['q5.q5_grid', 'q6new_q6copy.q6new_q6copy_grid', 'array_var.array_var_grid', 'q6new.q6new_grid', 'q7.q7_grid'] + +>>> dataset.transpose('q6new_q6copy.q6new_q6copy_grid') +>>> dataset.masks() +['q5.q5_grid', 'q6new_q6copy_trans.q6new_q6copy_trans_grid', 'q6new_q6copy.q6new_q6copy_grid', 'array_var.array_var_grid', 'q6new.q6new_grid', 'q7.q7_grid'] \ No newline at end of file diff --git a/docs/API/_build/html/_static/basic.css b/docs/API/_build/html/_static/basic.css index 7ed0e58ed..6df76b0a6 100644 --- a/docs/API/_build/html/_static/basic.css +++ b/docs/API/_build/html/_static/basic.css @@ -4,7 +4,7 @@ * * Sphinx stylesheet -- basic theme. * - * :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ @@ -398,6 +398,13 @@ table.field-list td, table.field-list th { margin: 0; } +.field-name { + -moz-hyphens: manual; + -ms-hyphens: manual; + -webkit-hyphens: manual; + hyphens: manual; +} + /* -- other body styles ----------------------------------------------------- */ ol.arabic { diff --git a/docs/API/_build/html/_static/doctools.js b/docs/API/_build/html/_static/doctools.js index 816349563..565497723 100644 --- a/docs/API/_build/html/_static/doctools.js +++ b/docs/API/_build/html/_static/doctools.js @@ -4,7 +4,7 @@ * * Sphinx JavaScript utilities for all documentation. * - * :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ diff --git a/docs/API/_build/html/_static/searchtools.js b/docs/API/_build/html/_static/searchtools.js index bbfb3ac14..c82157380 100644 --- a/docs/API/_build/html/_static/searchtools.js +++ b/docs/API/_build/html/_static/searchtools.js @@ -4,7 +4,7 @@ * * Sphinx JavaScript utilities for the full-text search. * - * :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ diff --git a/docs/API/_build/html/_static/underscore.js b/docs/API/_build/html/_static/underscore.js deleted file mode 100644 index 5b55f32be..000000000 --- a/docs/API/_build/html/_static/underscore.js +++ /dev/null @@ -1,31 +0,0 @@ -// Underscore.js 1.3.1 -// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. -// Underscore is freely distributable under the MIT license. -// Portions of Underscore are inspired or borrowed from Prototype, -// Oliver Steele's Functional, and John Resig's Micro-Templating. -// For all details and documentation: -// http://documentcloud.github.com/underscore -(function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source== -c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c, -h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else r._=b;b.VERSION="1.3.1";var j=b.each= -b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===n)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===n)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(x&&a.map===x)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a== -null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect= -function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e= -e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck= -function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&(e={value:a,computed:b})}); -return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){f==0?b[0]=a:(d=Math.floor(Math.random()*(f+1)),b[f]=b[d],b[d]=a)});return b};b.sortBy=function(a,c,d){return b.pluck(b.map(a,function(a,b,g){return{value:a,criteria:c.call(d,a,b,g)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a, -c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:a.toArray?a.toArray():b.isArray(a)?i.call(a):b.isArguments(a)?i.call(a):b.values(a)};b.size=function(a){return b.toArray(a).length};b.first=b.head=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest= -b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,e=[];b.reduce(d,function(d,g,h){if(0==h||(c===true?b.last(d)!=g:!b.include(d,g)))d[d.length]=g,e[e.length]=a[h];return d},[]); -return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c, -d){if(a==null)return-1;var e;if(d)return d=b.sortedIndex(a,c),a[d]===c?d:-1;if(p&&a.indexOf===p)return a.indexOf(c);for(d=0,e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(D&&a.lastIndexOf===D)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){arguments.length<=1&&(b=a||0,a=0);for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;)g[f++]=a,a+=d;return g}; -var F=function(){};b.bind=function(a,c){var d,e;if(a.bind===s&&s)return s.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));F.prototype=a.prototype;var b=new F,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a, -c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(a,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i=b.debounce(function(){h=g=false},c);return function(){d=this;e=arguments;var b;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);i()},c));g?h=true: -a.apply(d,e);i();g=true}};b.debounce=function(a,b){var d;return function(){var e=this,f=arguments;clearTimeout(d);d=setTimeout(function(){d=null;a.apply(e,f)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}}; -b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments, -1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)}; -b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"}; -b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.mixin=function(a){j(b.functions(a), -function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+ -u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]= -function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain= -true;return this};m.prototype.value=function(){return this._wrapped}}).call(this); diff --git a/docs/API/_build/html/_static/websupport.js b/docs/API/_build/html/_static/websupport.js index 98e7f40b6..53f6a4525 100644 --- a/docs/API/_build/html/_static/websupport.js +++ b/docs/API/_build/html/_static/websupport.js @@ -4,7 +4,7 @@ * * sphinx.websupport utilities for all documentation. * - * :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. + * :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS. * :license: BSD, see LICENSE for details. * */ diff --git a/docs/API/_build/html/genindex.html b/docs/API/_build/html/genindex.html index 9730954ce..4a59564b2 100644 --- a/docs/API/_build/html/genindex.html +++ b/docs/API/_build/html/genindex.html @@ -90,9 +90,18 @@ <h3>Quick search</h3> <ul> <li class="toctree-l1"><a class="reference internal" href="sites/release_notes/00_overview.html">Release notes</a><ul> -<li class="toctree-l2"><a class="reference internal" href="sites/release_notes/01_latest.html">Latest (15/09/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="sites/release_notes/01_latest.html">Latest (01/10/2018)</a></li> <li class="toctree-l2"><a class="reference internal" href="sites/release_notes/02_archive.html">Archived release notes</a><ul> -<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#latest-31-08-2017">Latest (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> @@ -193,7 +202,7 @@ <h3>Quick search</h3> <li class="toctree-l3"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> <li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> -<li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> <li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> @@ -290,6 +299,7 @@ <h3>Quick search</h3> <li class="toctree-l2"><a class="reference internal" href="sites/api_ref/quantify_engine.html">quantify.engine</a></li> <li class="toctree-l2"><a class="reference internal" href="sites/api_ref/QuantipyViews.html">QuantipyViews</a></li> <li class="toctree-l2"><a class="reference internal" href="sites/api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="sites/api_ref/Stack.html">Stack</a></li> <li class="toctree-l2"><a class="reference internal" href="sites/api_ref/View.html">View</a></li> <li class="toctree-l2"><a class="reference internal" href="sites/api_ref/ViewMapper.html">ViewMapper</a></li> </ul> @@ -352,6 +362,7 @@ <h1 id="index">Index</h1> | <a href="#L"><strong>L</strong></a> | <a href="#M"><strong>M</strong></a> | <a href="#N"><strong>N</strong></a> + | <a href="#O"><strong>O</strong></a> | <a href="#P"><strong>P</strong></a> | <a href="#Q"><strong>Q</strong></a> | <a href="#R"><strong>R</strong></a> @@ -367,11 +378,11 @@ <h2 id="A">A</h2> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="sites/api_ref/Cluster.html#quantipy.Cluster.add_chain">add_chain() (quantipy.Cluster method)</a> </li> - <li><a href="sites/api_ref/stack.html#quantipy.Stack.add_data">add_data() (quantipy.Stack method)</a> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.add_data">add_data() (quantipy.Stack method)</a> </li> <li><a href="sites/api_ref/Rim_scheme.html#quantipy.Rim.add_group">add_group() (quantipy.Rim method)</a> </li> - <li><a href="sites/api_ref/stack.html#quantipy.Stack.add_link">add_link() (quantipy.Stack method)</a> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.add_link">add_link() (quantipy.Stack method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.add_meta">add_meta() (quantipy.DataSet method)</a> </li> @@ -379,17 +390,19 @@ <h2 id="A">A</h2> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="sites/api_ref/stack.html#quantipy.Stack.add_nets">add_nets() (quantipy.Stack method)</a> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.add_nets">add_nets() (quantipy.Stack method)</a> </li> - <li><a href="sites/api_ref/stack.html#quantipy.Stack.add_stats">add_stats() (quantipy.Stack method)</a> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.add_stats">add_stats() (quantipy.Stack method)</a> </li> - <li><a href="sites/api_ref/stack.html#quantipy.Stack.add_tests">add_tests() (quantipy.Stack method)</a> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.add_tests">add_tests() (quantipy.Stack method)</a> </li> - <li><a href="sites/api_ref/stack.html#quantipy.Stack.aggregate">aggregate() (quantipy.Stack method)</a> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.aggregate">aggregate() (quantipy.Stack method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.all">all() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.any">any() (quantipy.DataSet method)</a> +</li> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.apply_meta_edits">apply_meta_edits() (quantipy.Stack method)</a> </li> </ul></td> </tr></table> @@ -402,6 +415,8 @@ <h2 id="B">B</h2> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="sites/api_ref/Cluster.html#quantipy.Cluster.bank_chains">bank_chains() (quantipy.Cluster method)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.by_type">by_type() (quantipy.DataSet method)</a> </li> </ul></td> </tr></table> @@ -414,6 +429,8 @@ <h2 id="C">C</h2> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.categorize">categorize() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/Chain.html#quantipy.Chain">Chain (class in quantipy)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.clear_factors">clear_factors() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.clone">clone() (quantipy.DataSet method)</a> </li> @@ -451,7 +468,7 @@ <h2 id="C">C</h2> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.crosstab">crosstab() (quantipy.DataSet method)</a> </li> - <li><a href="sites/api_ref/stack.html#quantipy.Stack.cumulative_sum">cumulative_sum() (quantipy.Stack method)</a> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.cumulative_sum">cumulative_sum() (quantipy.Stack method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.cut_item_texts">cut_item_texts() (quantipy.DataSet method)</a> </li> @@ -476,18 +493,22 @@ <h2 id="D">D</h2> <ul> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.describe">(quantipy.DataSet method)</a> </li> - <li><a href="sites/api_ref/stack.html#quantipy.Stack.describe">(quantipy.Stack method)</a> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.describe">(quantipy.Stack method)</a> </li> </ul></li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="sites/api_ref/QuantipyViews.html#quantipy.QuantipyViews.descriptives">descriptives() (quantipy.QuantipyViews method)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.dichotomize">dichotomize() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.dimensionize">dimensionize() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.dimensionizing_mapper">dimensionizing_mapper() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.drop">drop() (quantipy.DataSet method)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.drop_duplicates">drop_duplicates() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.duplicates">duplicates() (quantipy.DataSet method)</a> </li> @@ -497,10 +518,16 @@ <h2 id="D">D</h2> <h2 id="E">E</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="sites/api_ref/quantify_engine.html#quantipy.Quantity.exclude">exclude() (quantipy.Quantity method)</a> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.empty">empty() (quantipy.DataSet method)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.empty_items">empty_items() (quantipy.DataSet method)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="sites/api_ref/quantify_engine.html#quantipy.Quantity.exclude">exclude() (quantipy.Quantity method)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.extend_items">extend_items() (quantipy.DataSet method)</a> +</li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.extend_values">extend_values() (quantipy.DataSet method)</a> </li> </ul></td> @@ -509,6 +536,8 @@ <h2 id="E">E</h2> <h2 id="F">F</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.factors">factors() (quantipy.DataSet method)</a> +</li> <li><a href="sites/api_ref/Chain.html#Chain.filename">filename (Chain attribute)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.filter">filter() (quantipy.DataSet method)</a> @@ -517,23 +546,31 @@ <h2 id="F">F</h2> <li><a href="sites/api_ref/quantify_engine.html#quantipy.Quantity.filter">(quantipy.Quantity method)</a> </li> </ul></li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.find">find() (quantipy.DataSet method)</a> +</li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.find_duplicate_texts">find_duplicate_texts() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.flatten">flatten() (quantipy.DataSet method)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.force_texts">force_texts() (quantipy.DataSet method)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.force_texts">force_texts() (quantipy.DataSet method)</a> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.freeze_master_meta">freeze_master_meta() (quantipy.Stack method)</a> </li> <li><a href="sites/api_ref/QuantipyViews.html#quantipy.QuantipyViews.frequency">frequency() (quantipy.QuantipyViews method)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.from_batch">from_batch() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.from_components">from_components() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.from_excel">from_excel() (quantipy.DataSet method)</a> </li> - <li><a href="sites/api_ref/stack.html#quantipy.Stack.from_sav">from_sav() (quantipy.Stack static method)</a> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.from_sav">from_sav() (quantipy.Stack static method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.from_stack">from_stack() (quantipy.DataSet method)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.fully_hidden_arrays">fully_hidden_arrays() (quantipy.DataSet method)</a> </li> </ul></td> </tr></table> @@ -545,12 +582,14 @@ <h2 id="G">G</h2> </li> <li><a href="sites/api_ref/View.html#quantipy.View.get_edit_params">get_edit_params() (quantipy.View method)</a> </li> - <li><a href="sites/api_ref/quantify_engine.html#quantipy.Test.get_se">get_se() (quantipy.Test method)</a> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.get_property">get_property() (quantipy.DataSet method)</a> </li> - <li><a href="sites/api_ref/quantify_engine.html#quantipy.Test.get_sig">get_sig() (quantipy.Test method)</a> + <li><a href="sites/api_ref/quantify_engine.html#quantipy.Test.get_se">get_se() (quantipy.Test method)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="sites/api_ref/quantify_engine.html#quantipy.Test.get_sig">get_sig() (quantipy.Test method)</a> +</li> <li><a href="sites/api_ref/quantify_engine.html#quantipy.Test.get_statistic">get_statistic() (quantipy.Test method)</a> </li> <li><a href="sites/api_ref/View.html#quantipy.View.get_std_params">get_std_params() (quantipy.View method)</a> @@ -566,6 +605,8 @@ <h2 id="H">H</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> <li><a href="sites/api_ref/View.html#quantipy.View.has_other_source">has_other_source() (quantipy.View method)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.hide_empty_items">hide_empty_items() (quantipy.DataSet method)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> @@ -586,6 +627,8 @@ <h2 id="I">I</h2> <li><a href="sites/api_ref/View.html#quantipy.View.is_counts">is_counts() (quantipy.View method)</a> </li> <li><a href="sites/api_ref/View.html#quantipy.View.is_cumulative">is_cumulative() (quantipy.View method)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.is_like_numeric">is_like_numeric() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/View.html#quantipy.View.is_meanstest">is_meanstest() (quantipy.View method)</a> </li> @@ -620,8 +663,6 @@ <h2 id="L">L</h2> <li><a href="sites/api_ref/quantify_engine.html#quantipy.Quantity.limit">limit() (quantipy.Quantity method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.link">link() (quantipy.DataSet method)</a> -</li> - <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.list_variables">list_variables() (quantipy.DataSet method)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> @@ -630,7 +671,7 @@ <h2 id="L">L</h2> <ul> <li><a href="sites/api_ref/Cluster.html#quantipy.Cluster.load">(quantipy.Cluster static method)</a> </li> - <li><a href="sites/api_ref/stack.html#quantipy.Stack.load">(quantipy.Stack static method)</a> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.load">(quantipy.Stack static method)</a> </li> </ul></li> </ul></td> @@ -645,14 +686,18 @@ <h2 id="M">M</h2> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.merge_texts">merge_texts() (quantipy.DataSet method)</a> </li> - </ul></td> - <td style="width: 33%; vertical-align: top;"><ul> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.meta">meta() (quantipy.DataSet method)</a> <ul> <li><a href="sites/api_ref/View.html#quantipy.View.meta">(quantipy.View method)</a> </li> </ul></li> + </ul></td> + <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.meta_to_json">meta_to_json() (quantipy.DataSet method)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.min_value_count">min_value_count() (quantipy.DataSet method)</a> +</li> <li><a href="sites/api_ref/View.html#quantipy.View.missing">missing() (quantipy.View method)</a> </li> </ul></td> @@ -661,6 +706,8 @@ <h2 id="M">M</h2> <h2 id="N">N</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.names">names() (quantipy.DataSet method)</a> +</li> <li><a href="sites/api_ref/View.html#quantipy.View.nests">nests() (quantipy.View method)</a> </li> </ul></td> @@ -672,6 +719,14 @@ <h2 id="N">N</h2> </ul></td> </tr></table> +<h2 id="O">O</h2> +<table style="width: 100%" class="indextable genindextable"><tr> + <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.order">order() (quantipy.DataSet method)</a> +</li> + </ul></td> +</tr></table> + <h2 id="P">P</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> @@ -711,23 +766,27 @@ <h2 id="R">R</h2> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.recode">recode() (quantipy.DataSet method)</a> </li> - <li><a href="sites/api_ref/stack.html#quantipy.Stack.reduce">reduce() (quantipy.Stack method)</a> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.recode_from_net_def">recode_from_net_def() (quantipy.Stack static method)</a> +</li> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.reduce">reduce() (quantipy.Stack method)</a> </li> - <li><a href="sites/api_ref/stack.html#quantipy.Stack.refresh">refresh() (quantipy.Stack method)</a> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.refresh">refresh() (quantipy.Stack method)</a> </li> - <li><a href="sites/api_ref/stack.html#quantipy.Stack.remove_data">remove_data() (quantipy.Stack method)</a> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.remove_data">remove_data() (quantipy.Stack method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.remove_html">remove_html() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.remove_items">remove_items() (quantipy.DataSet method)</a> </li> - </ul></td> - <td style="width: 33%; vertical-align: top;"><ul> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.remove_values">remove_values() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.rename">rename() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.rename_from_mapper">rename_from_mapper() (quantipy.DataSet method)</a> +</li> + </ul></td> + <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.reorder_items">reorder_items() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.reorder_values">reorder_values() (quantipy.DataSet method)</a> </li> @@ -742,8 +801,18 @@ <h2 id="R">R</h2> <li><a href="sites/api_ref/quantify_engine.html#quantipy.Quantity.rescale">rescale() (quantipy.Quantity method)</a> </li> <li><a href="sites/api_ref/View.html#quantipy.View.rescaling">rescaling() (quantipy.View method)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.resolve_name">resolve_name() (quantipy.DataSet method)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.restore_item_texts">restore_item_texts() (quantipy.DataSet method)</a> +</li> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.restore_meta">restore_meta() (quantipy.Stack method)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.revert">revert() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/Rim_scheme.html#quantipy.Rim">Rim (class in quantipy)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.roll_up">roll_up() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/quantify_engine.html#quantipy.Test.run">run() (quantipy.Test method)</a> </li> @@ -758,10 +827,16 @@ <h2 id="S">S</h2> <ul> <li><a href="sites/api_ref/Cluster.html#quantipy.Cluster.save">(quantipy.Cluster method)</a> </li> - <li><a href="sites/api_ref/stack.html#quantipy.Stack.save">(quantipy.Stack method)</a> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.save">(quantipy.DataSet method)</a> +</li> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.save">(quantipy.Stack method)</a> </li> </ul></li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.select_text_keys">select_text_keys() (quantipy.DataSet method)</a> +</li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.set_encoding">set_encoding() (quantipy.DataSet class method)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.set_factors">set_factors() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.set_item_texts">set_item_texts() (quantipy.DataSet method)</a> </li> @@ -776,11 +851,11 @@ <h2 id="S">S</h2> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.set_text_key">set_text_key() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.set_value_texts">set_value_texts() (quantipy.DataSet method)</a> -</li> - <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.set_variable_text">set_variable_text() (quantipy.DataSet method)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.set_variable_text">set_variable_text() (quantipy.DataSet method)</a> +</li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.set_verbose_errmsg">set_verbose_errmsg() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.set_verbose_infomsg">set_verbose_infomsg() (quantipy.DataSet method)</a> @@ -795,7 +870,7 @@ <h2 id="S">S</h2> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.split">split() (quantipy.DataSet method)</a> </li> - <li><a href="sites/api_ref/stack.html#quantipy.Stack">Stack (class in quantipy)</a> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack">Stack (class in quantipy)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.start_meta">start_meta() (quantipy.DataSet static method)</a> </li> @@ -819,11 +894,13 @@ <h2 id="T">T</h2> </li> <li><a href="sites/api_ref/quantify_engine.html#quantipy.Test">Test (class in quantipy)</a> </li> - </ul></td> - <td style="width: 33%; vertical-align: top;"><ul> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.text">text() (quantipy.DataSet method)</a> </li> + </ul></td> + <td style="width: 33%; vertical-align: top;"><ul> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.to_array">to_array() (quantipy.DataSet method)</a> +</li> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.to_delimited_set">to_delimited_set() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.transpose">transpose() (quantipy.DataSet method)</a> </li> @@ -833,6 +910,8 @@ <h2 id="T">T</h2> <h2 id="U">U</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.unbind">unbind() (quantipy.DataSet method)</a> +</li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.uncode">uncode() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.undimensionize">undimensionize() (quantipy.DataSet method)</a> @@ -864,14 +943,12 @@ <h2 id="V">V</h2> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.value_texts">value_texts() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.values">values() (quantipy.DataSet method)</a> -</li> - <li><a href="sites/api_ref/stack.html#quantipy.Stack.variable_types">variable_types() (quantipy.Stack method)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.variables">variables() (quantipy.DataSet method)</a> + <li><a href="sites/api_ref/Stack.html#quantipy.Stack.variable_types">variable_types() (quantipy.Stack method)</a> </li> - <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.variables_from_set">variables_from_set() (quantipy.DataSet method)</a> + <li><a href="sites/api_ref/DataSet.html#quantipy.DataSet.variables">variables() (quantipy.DataSet method)</a> </li> <li><a href="sites/api_ref/View.html#quantipy.View">View (class in quantipy)</a> </li> @@ -947,7 +1024,7 @@ <h2 id="W">W</h2> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <script type="text/javascript" src="_static/custom.js"></script> - <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> diff --git a/docs/API/_build/html/index.html b/docs/API/_build/html/index.html index e0199f47c..31ebf4ba6 100644 --- a/docs/API/_build/html/index.html +++ b/docs/API/_build/html/index.html @@ -90,9 +90,18 @@ <h3>Quick search</h3> <ul> <li class="toctree-l1"><a class="reference internal" href="sites/release_notes/00_overview.html">Release notes</a><ul> -<li class="toctree-l2"><a class="reference internal" href="sites/release_notes/01_latest.html">Latest (15/09/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="sites/release_notes/01_latest.html">Latest (01/10/2018)</a></li> <li class="toctree-l2"><a class="reference internal" href="sites/release_notes/02_archive.html">Archived release notes</a><ul> -<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#latest-31-08-2017">Latest (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> @@ -193,7 +202,7 @@ <h3>Quick search</h3> <li class="toctree-l3"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> <li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> -<li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> <li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> @@ -290,6 +299,7 @@ <h3>Quick search</h3> <li class="toctree-l2"><a class="reference internal" href="sites/api_ref/quantify_engine.html">quantify.engine</a></li> <li class="toctree-l2"><a class="reference internal" href="sites/api_ref/QuantipyViews.html">QuantipyViews</a></li> <li class="toctree-l2"><a class="reference internal" href="sites/api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="sites/api_ref/Stack.html">Stack</a></li> <li class="toctree-l2"><a class="reference internal" href="sites/api_ref/View.html">View</a></li> <li class="toctree-l2"><a class="reference internal" href="sites/api_ref/ViewMapper.html">ViewMapper</a></li> </ul> @@ -429,7 +439,7 @@ <h2>Key features<a class="headerlink" href="#key-features" title="Permalink to t <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <script type="text/javascript" src="_static/custom.js"></script> - <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> diff --git a/docs/API/_build/html/objects.inv b/docs/API/_build/html/objects.inv index 78cb686ed..09c47acdb 100644 Binary files a/docs/API/_build/html/objects.inv and b/docs/API/_build/html/objects.inv differ diff --git a/docs/API/_build/html/search.html b/docs/API/_build/html/search.html index 7e5631023..c4cf1e99c 100644 --- a/docs/API/_build/html/search.html +++ b/docs/API/_build/html/search.html @@ -86,9 +86,18 @@ <ul> <li class="toctree-l1"><a class="reference internal" href="sites/release_notes/00_overview.html">Release notes</a><ul> -<li class="toctree-l2"><a class="reference internal" href="sites/release_notes/01_latest.html">Latest (15/09/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="sites/release_notes/01_latest.html">Latest (01/10/2018)</a></li> <li class="toctree-l2"><a class="reference internal" href="sites/release_notes/02_archive.html">Archived release notes</a><ul> -<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#latest-31-08-2017">Latest (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="sites/release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> @@ -189,7 +198,7 @@ <li class="toctree-l3"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> <li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> -<li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> <li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="sites/lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> @@ -286,6 +295,7 @@ <li class="toctree-l2"><a class="reference internal" href="sites/api_ref/quantify_engine.html">quantify.engine</a></li> <li class="toctree-l2"><a class="reference internal" href="sites/api_ref/QuantipyViews.html">QuantipyViews</a></li> <li class="toctree-l2"><a class="reference internal" href="sites/api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="sites/api_ref/Stack.html">Stack</a></li> <li class="toctree-l2"><a class="reference internal" href="sites/api_ref/View.html">View</a></li> <li class="toctree-l2"><a class="reference internal" href="sites/api_ref/ViewMapper.html">ViewMapper</a></li> </ul> @@ -395,7 +405,7 @@ <h1 id="search-documentation">Search</h1> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <script type="text/javascript" src="_static/custom.js"></script> - <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> <script type="text/javascript" src="_static/searchtools.js"></script> diff --git a/docs/API/_build/html/searchindex.js b/docs/API/_build/html/searchindex.js index a9211028d..baec5bb34 100644 --- a/docs/API/_build/html/searchindex.js +++ b/docs/API/_build/html/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["index","sites/api_ref/00overview","sites/api_ref/Chain","sites/api_ref/Cluster","sites/api_ref/DataSet","sites/api_ref/QuantipyViews","sites/api_ref/Rim_scheme","sites/api_ref/View","sites/api_ref/ViewMapper","sites/api_ref/quantify_engine","sites/api_ref/stack","sites/lib_doc/batch/00_overview","sites/lib_doc/batch/01_create_load","sites/lib_doc/batch/02_variables","sites/lib_doc/batch/03_properties","sites/lib_doc/batch/04_subclass","sites/lib_doc/builds/00_overview","sites/lib_doc/builds/01_chains","sites/lib_doc/dataprocessing/00_overview","sites/lib_doc/dataprocessing/01_components","sites/lib_doc/dataprocessing/02_io","sites/lib_doc/dataprocessing/02a_management","sites/lib_doc/dataprocessing/03_inspection","sites/lib_doc/dataprocessing/04_editing","sites/lib_doc/dataprocessing/05_transforming","sites/lib_doc/dataprocessing/06_logics","sites/lib_doc/dataprocessing/07_custom_recoding","sites/lib_doc/engine/00_overview","sites/lib_doc/engine/01_links_stacks","sites/lib_doc/engine/02_quantity","sites/lib_doc/engine/03_test","sites/lib_doc/engine/04_agg_methods","sites/lib_doc/overview","sites/release_notes/00_overview","sites/release_notes/01_latest","sites/release_notes/02_archive","sites/release_notes/03_how_to_snippets","sites/release_notes/how_to_snippets/create_categorical_meta","sites/release_notes/how_to_snippets/derotate","sites/release_notes/how_to_snippets/dimensions_comp"],envversion:50,filenames:["index.rst","sites\\api_ref\\00overview.rst","sites\\api_ref\\Chain.rst","sites\\api_ref\\Cluster.rst","sites\\api_ref\\DataSet.rst","sites\\api_ref\\QuantipyViews.rst","sites\\api_ref\\Rim_scheme.rst","sites\\api_ref\\View.rst","sites\\api_ref\\ViewMapper.rst","sites\\api_ref\\quantify_engine.rst","sites\\api_ref\\stack.rst","sites\\lib_doc\\batch\\00_overview.rst","sites\\lib_doc\\batch\\01_create_load.rst","sites\\lib_doc\\batch\\02_variables.rst","sites\\lib_doc\\batch\\03_properties.rst","sites\\lib_doc\\batch\\04_subclass.rst","sites\\lib_doc\\builds\\00_overview.rst","sites\\lib_doc\\builds\\01_chains.rst","sites\\lib_doc\\dataprocessing\\00_overview.rst","sites\\lib_doc\\dataprocessing\\01_components.rst","sites\\lib_doc\\dataprocessing\\02_io.rst","sites\\lib_doc\\dataprocessing\\02a_management.rst","sites\\lib_doc\\dataprocessing\\03_inspection.rst","sites\\lib_doc\\dataprocessing\\04_editing.rst","sites\\lib_doc\\dataprocessing\\05_transforming.rst","sites\\lib_doc\\dataprocessing\\06_logics.rst","sites\\lib_doc\\dataprocessing\\07_custom_recoding.rst","sites\\lib_doc\\engine\\00_overview.rst","sites\\lib_doc\\engine\\01_links_stacks.rst","sites\\lib_doc\\engine\\02_quantity.rst","sites\\lib_doc\\engine\\03_test.rst","sites\\lib_doc\\engine\\04_agg_methods.rst","sites\\lib_doc\\overview.rst","sites\\release_notes\\00_overview.rst","sites\\release_notes\\01_latest.rst","sites\\release_notes\\02_archive.rst","sites\\release_notes\\03_how_to_snippets.rst","sites\\release_notes\\how_to_snippets\\create_categorical_meta.rst","sites\\release_notes\\how_to_snippets\\derotate.rst","sites\\release_notes\\how_to_snippets\\dimensions_comp.rst"],objects:{"quantipy.Chain":{concat:[2,2,1,""],copy:[2,2,1,""],describe:[2,2,1,""],load:[2,3,1,""],save:[2,2,1,""]},"quantipy.Cluster":{add_chain:[3,2,1,""],bank_chains:[3,2,1,""],load:[3,3,1,""],merge:[3,2,1,""],save:[3,2,1,""]},"quantipy.DataSet":{add_meta:[4,2,1,""],all:[4,2,1,""],any:[4,2,1,""],band:[4,2,1,""],categorize:[4,2,1,""],clone:[4,2,1,""],code_count:[4,2,1,""],code_from_label:[4,2,1,""],codes:[4,2,1,""],codes_in_data:[4,2,1,""],compare:[4,2,1,""],convert:[4,2,1,""],copy:[4,2,1,""],copy_array_data:[4,2,1,""],create_set:[4,2,1,""],crosstab:[4,2,1,""],cut_item_texts:[4,2,1,""],data:[4,2,1,""],derive:[4,2,1,""],derotate:[4,2,1,""],describe:[4,2,1,""],dimensionize:[4,2,1,""],dimensionizing_mapper:[4,2,1,""],drop:[4,2,1,""],duplicates:[4,2,1,""],extend_values:[4,2,1,""],filter:[4,2,1,""],find_duplicate_texts:[4,2,1,""],flatten:[4,2,1,""],force_texts:[4,2,1,""],from_components:[4,2,1,""],from_excel:[4,2,1,""],from_stack:[4,2,1,""],get_batch:[4,2,1,""],hiding:[4,2,1,""],hmerge:[4,2,1,""],interlock:[4,2,1,""],is_nan:[4,2,1,""],item_no:[4,2,1,""],item_texts:[4,2,1,""],items:[4,2,1,""],link:[4,2,1,""],list_variables:[4,2,1,""],merge_texts:[4,2,1,""],meta:[4,2,1,""],parents:[4,2,1,""],populate:[4,2,1,""],read_ascribe:[4,2,1,""],read_dimensions:[4,2,1,""],read_quantipy:[4,2,1,""],read_spss:[4,2,1,""],recode:[4,2,1,""],remove_html:[4,2,1,""],remove_items:[4,2,1,""],remove_values:[4,2,1,""],rename:[4,2,1,""],rename_from_mapper:[4,2,1,""],reorder_values:[4,2,1,""],repair:[4,2,1,""],repair_text_edits:[4,2,1,""],replace_texts:[4,2,1,""],set_encoding:[4,4,1,""],set_item_texts:[4,2,1,""],set_missings:[4,2,1,""],set_property:[4,2,1,""],set_text_key:[4,2,1,""],set_value_texts:[4,2,1,""],set_variable_text:[4,2,1,""],set_verbose_errmsg:[4,2,1,""],set_verbose_infomsg:[4,2,1,""],slicing:[4,2,1,""],sorting:[4,2,1,""],sources:[4,2,1,""],split:[4,2,1,""],start_meta:[4,3,1,""],subset:[4,2,1,""],take:[4,2,1,""],text:[4,2,1,""],to_array:[4,2,1,""],transpose:[4,2,1,""],uncode:[4,2,1,""],undimensionize:[4,2,1,""],undimensionizing_mapper:[4,2,1,""],unify_values:[4,2,1,""],unroll:[4,2,1,""],update:[4,2,1,""],validate:[4,2,1,""],value_texts:[4,2,1,""],values:[4,2,1,""],variables:[4,2,1,""],variables_from_set:[4,2,1,""],vmerge:[4,2,1,""],weight:[4,2,1,""],write_dimensions:[4,2,1,""],write_quantipy:[4,2,1,""],write_spss:[4,2,1,""]},"quantipy.QuantipyViews":{"default":[5,2,1,""],coltests:[5,2,1,""],descriptives:[5,2,1,""],frequency:[5,2,1,""]},"quantipy.Quantity":{calc:[9,2,1,""],count:[9,2,1,""],exclude:[9,2,1,""],filter:[9,2,1,""],group:[9,2,1,""],limit:[9,2,1,""],normalize:[9,2,1,""],rebase:[9,2,1,""],rescale:[9,2,1,""],summarize:[9,2,1,""],swap:[9,2,1,""],unweight:[9,2,1,""],weight:[9,2,1,""]},"quantipy.Rim":{add_group:[6,2,1,""],group_targets:[6,2,1,""],report:[6,2,1,""],set_targets:[6,2,1,""],validate:[6,2,1,""]},"quantipy.Stack":{add_data:[10,2,1,""],add_link:[10,2,1,""],add_nets:[10,2,1,""],add_stats:[10,2,1,""],add_tests:[10,2,1,""],aggregate:[10,2,1,""],cumulative_sum:[10,2,1,""],describe:[10,2,1,""],from_sav:[10,3,1,""],load:[10,3,1,""],reduce:[10,2,1,""],refresh:[10,2,1,""],remove_data:[10,2,1,""],save:[10,2,1,""],variable_types:[10,2,1,""]},"quantipy.Test":{get_se:[9,2,1,""],get_sig:[9,2,1,""],get_statistic:[9,2,1,""],run:[9,2,1,""],set_params:[9,2,1,""]},"quantipy.View":{get_edit_params:[7,2,1,""],get_std_params:[7,2,1,""],has_other_source:[7,2,1,""],is_base:[7,2,1,""],is_counts:[7,2,1,""],is_cumulative:[7,2,1,""],is_meanstest:[7,2,1,""],is_net:[7,2,1,""],is_pct:[7,2,1,""],is_propstest:[7,2,1,""],is_stat:[7,2,1,""],is_sum:[7,2,1,""],is_weighted:[7,2,1,""],meta:[7,2,1,""],missing:[7,2,1,""],nests:[7,2,1,""],notation:[7,2,1,""],rescaling:[7,2,1,""],spec_condition:[7,2,1,""],weights:[7,2,1,""]},"quantipy.ViewMapper":{add_method:[8,2,1,""],make_template:[8,2,1,""],subset:[8,2,1,""]},Chain:{filename:[2,0,1,""]},quantipy:{Chain:[2,1,1,""],Cluster:[3,1,1,""],DataSet:[4,1,1,""],QuantipyViews:[5,1,1,""],Quantity:[9,1,1,""],Rim:[6,1,1,""],Stack:[10,1,1,""],Test:[9,1,1,""],View:[7,1,1,""],ViewMapper:[8,1,1,""]}},objnames:{"0":["py","attribute","Python attribute"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","staticmethod","Python static method"],"4":["py","classmethod","Python class method"]},objtypes:{"0":"py:attribute","1":"py:class","2":"py:method","3":"py:staticmethod","4":"py:classmethod"},terms:{"0x0000000019ae06d8":[28,31],"\u00ecnt":[20,31],"\u00ectem":39,"boolean":[4,6,10,18,35],"case":[0,4,5,6,9,10,12,13,15,18,20,23,24,26,28,35,37,38],"class":[2,3,4,5,6,7,8,9,10,11,22,35],"default":[3,4,5,7,8,9,10,13,18,20,21,23,24,35,38,39],"export":[0,3,4,20,35],"final":26,"float":[4,5,9,10,19,20,21,22,23,24,31,35],"function":[4,10,20,25,26,28,31,34,35],"import":[4,9,11,15,20,22,25,26],"int":[4,5,9,10,19,20,21,22,23,24,25,35],"long":[25,34,35],"m\u00fcller":0,"new":[3,4,5,8,9,10,12,21,23,24,26,31,34,35,38,39],"null":31,"return":[3,4,5,6,7,8,9,10,21,22,24,26,35],"short":[8,19,21,24,35],"sigur\u00f0sson":0,"static":[2,3,4,10],"switch":[24,38],"true":[4,5,6,8,9,10,13,20,21,22,24,25,26,31,35,38,39],"try":[4,10,23,35],"var":[4,9,15,35,38],"while":[4,15,19,23,24,35],Adding:[11,18,31],Age:[24,26],Being:15,But:[13,23],Das:[19,23],For:[4,5,13,14,20,22,23,24,25,26,28,31],IDs:[],NPS:31,Not:[19,24,31],One:[4,13,26],That:[15,19,22,24],The:[2,3,4,5,7,8,9,10,11,13,14,15,18,20,21,22,23,24,25,27,31,34,35,36,37,38],Their:5,Then:[21,35],There:[13,19,21,22,31,35],These:[15,28,31,34,35],Use:[4,9,24,35],Uses:4,Using:[18,21,23],Will:[4,5,9,10,35],With:[13,22,23,24,26,31],Yes:[20,35],__init__:[12,35],__setitem__:35,_band:4,_batch:[10,31],_cumsum:[31,35],_data:[4,11,21],_grid:38,_intersect:[28,31],_meta:[4,11,12,13,22,28,39],_missingfi:9,_rec:[4,24],_remove_html:4,_suffix:4,_sum:31,_tran:4,abbrevi:25,abl:[5,28,35],about:[13,19,22,36],abov:[24,31,39],absorb:34,accept:[23,26,35],access:[4,19,20,22,35,36],accessor:22,accid:[21,34],accommod:14,accompani:[19,35],accord:[4,9,10,26,31],accordingli:26,account:[4,5],achiev:21,across:[9,22,35],act:[5,24,28],activ:[19,20,24],add:[3,4,5,8,10,13,14,23,24,28,31,34,35,37],add_batch:[12,31],add_chain:3,add_data:10,add_filt:14,add_group:6,add_i:13,add_link:[10,28,31],add_meta:[4,23,35,37,39],add_method:8,add_net:[10,31,35],add_open_end:[13,34,35],add_stat:[10,31,35],add_test:[10,31,35],add_x:[13,31],add_y_on_i:[13,28,31],adddit:20,added:[4,10,12,13,14,23,24,28,31,34,35,38],adding:[4,14,18,20,31,39],addit:[4,13,19,22,31,34,35],addition:[19,35],adjust:35,adopt:13,aerob:24,affix:10,after:[4,9,10,21,26,28,31],afternoon:22,again:[22,23,31],against:[5,9,13,35],age:[4,13,14,22,24,26,28,31,35],age_band:24,age_cb:26,age_grp_rc:26,age_rec:4,age_xb:26,age_xb_1:26,agegrp:[4,35],agg:[7,13,31],aggnam:7,aggreg:[0,2,3,4,5,7,8,9,10,11,14,16,35],aim:[0,35],alasdair:0,alexand:0,algorithm:[4,5,9],alia:[4,21],all:[2,3,4,5,9,10,11,12,13,14,19,20,21,22,23,24,25,26,28,31,35,37,38],allign:35,allow:[4,14,15,23,24,31],alon:[22,35],along:[2,9],alongsid:[10,21,31],alphanumer:4,alreadi:[4,12,14,19,24,26,35],also:[4,9,10,11,12,13,14,22,23,24,26,28,31,35,37,38],altern:[4,23,31,37],although:22,alwai:[4,15,23,24,26,31,35,39],amount:[14,21,28,31],analysi:[0,35],ani:[4,5,7,9,10,13,19,21,22,23,25,26,35],anim:[4,19],anoth:[13,23,24,26,35],answer:[4,9,10,19,22,23,24,35],anymor:35,anyth:26,anywher:10,api:4,appear:[4,37],append:[4,5,18,31,38],appli:[4,5,8,9,10,15,20,21,22,24,28,31,35,39],applic:[24,26],apporach:21,approach:37,appropri:[4,5],arbitrari:10,arbitrarili:[4,21,25,26],archiv:33,argument:[5,8,11,20,23,24,35],aris:28,arithmet:9,around:[4,35],arrai:[4,9,10,11,18,21,22,23,31,35,36,37],array_item:35,array_var:39,array_var_1:39,array_var_2:39,array_var_3:39,array_var_grid:39,arriv:9,as_addit:[13,34],as_delimited_set:35,as_df:9,as_float:35,as_int:35,as_singl:35,as_str:35,as_typ:[4,35],ascend:4,ascii:4,ascrib:[0,4,18],asid:24,ask:[19,24],askia:[5,9],assess:[0,38],assign:[4,6,37],assignd:24,associ:[2,10],assum:[4,9,28,38],attach:[4,10,21,23],attempt:4,attribut:[2,4,11,22,28,31,35],auto:4,autom:[0,10],automat:[4,13,14,20,22,23,24,31,35,39],auxiliari:9,avail:4,avoid:26,axes:4,axi:[2,3,4,5,7,9,10,15,19,22,35],axis_edit:[4,35],b_name:31,back:[4,5,38],badli:[4,35],band:[4,10,18,35],band_numer:35,bank:3,bank_chain:3,bar:35,base:[4,5,7,8,9,10,18,20,22,31,35],base_al:9,base_text:15,based_on:[4,35],baselin:8,basi:26,basic:[20,22,25,27],basketbal:24,batch1:[12,13,28,31],batch2:[12,13,28,31],batch3:31,batch4:31,batch5:31,batch6:31,batch:[0,4,10,15,28,31,34,35],batchnam:[11,13],bchain:3,becaus:[24,26],becom:[4,9,26,35],been:[4,9,10,13,21,24,26,34,35,39],beer:38,befor:[4,9,10,13,14,24,26,31,35],begin:[4,26],behaviour:[5,7,22,26,35,39],being:[4,24,39],belong:[4,11,12,13,31,35,38],below:[9,13,26,34],benefici:21,benefit:26,better:28,between:[4,9,13,31,35],bia:9,big:21,binari:35,bird:19,birgir:0,birth_dai:22,birth_month:22,birth_year:22,bivari:5,bla:[],blacklist:[4,35],blank:37,blueprint:35,board:[19,24,39],bool:[4,5,8,9,10,22,38],both:[4,10,12,13,19,20,21,23,24,26,28,35,39],bottom3:10,bound:35,brand:38,break_bi:13,breakfast:22,brief:35,broader:19,buchhamm:0,bug:35,bugfix:35,build:[0,3,4,5,9,15,18,19,34,35],built:[14,31],by_typ:[21,22,34],bytestr:2,cach:10,calc:[5,7,9,10,31],calc_onli:[5,31],calcul:[5,9,10,14,27],call:[4,10,21,22,24,28,34,35,39],came:35,can:[2,4,5,9,10,11,12,13,14,15,19,20,21,22,23,24,25,26,28,31,34,35,37,38,39],cannot:[26,34,35],cap:6,carefulli:4,carri:5,case1:38,case2:38,case3:38,casedata:[4,20],cat:[4,19,23,37,39],categor:[4,5,10,18,22,23,27,35,36],categori:[4,5,10,19,22,23,35,37],categorized_nam:[4,35],caus:35,caution:4,cave:[19,24,39],cbase:[10,31],cell:[5,9,11,26,34,35],cell_item:14,central:5,certain:[4,22],chain:[0,1,3,16,22,35],chainnam:2,chang:[4,6,9,10,18,21,24,35],charact:[4,23,25],characterist:[19,24],chart:[0,35],check:[4,5,9,10,22,26,35],check_dup:35,checking_clust:10,choic:0,choos:5,clariti:25,classmethod:4,clean:[0,4,10,21,24,35],clean_text:[23,35],clean_up:[4,35],clear:35,clone:[4,18],close:12,cluster:[0,1,2,10,13,14,15,35],code:[4,5,6,7,9,10,18,19,22,23,24,31,35,37,39],code_count:[4,22,25,35],code_from_label:[4,35],code_map:4,codes_in_data:[4,22,35],cola:38,collect:[4,5,10,11,13,14,19,21,22,24,27,31,34,35],colour:35,coltest:[5,8,10],column:[2,4,5,6,7,9,10,18,20,22,23,24,26,31,35,38,39],combin:[4,5,10,16,22,25,26,28,31,35],combind:38,come:35,comma:25,common:[7,19,24,35],commun:10,compabl:4,compar:[4,5,9,35],comparison:9,compat:[4,10,20,35,36],compatibilti:39,complet:[9,35],complex:[4,5,6,18,19,21,22,26,31,34,35],compli:[4,26],complic:18,compon:[4,5,7,10,11,15,18,21,22,23,24,35],compos:10,compound:3,comprehens:26,compress:10,comput:[0,4,5,8,9,10,27,28,31,35],concat:[2,22,35],concaten:[2,26],concern:31,cond_map:4,condit:[4,7,9,18,21,22,25,35],confirm:10,conjunct:34,connect:[4,10,12,13,35,39],consequ:[28,37],consid:[4,5,9,10,24],consist:[4,9,11,19,21,23,24,35],constitut:13,constrcut:10,construct:[4,11,13,14,19,21,23,28,31,35,39],contain:[0,2,3,4,7,8,9,10,11,13,14,19,21,22,23,24,28,31,35,38],content:[21,28],context:[19,23],continu:[],contrast:[19,24],contributor:0,control:[4,5,7,9,10,23,24,26,35],convcrit:6,convent:[4,9,35,39],convers:[4,18,35],convert:[0,4,9,20,24,35,39],coordin:8,cope:28,copi:[2,4,8,12,18,21,23,26,34,35,39],copy_array_data:4,copy_batch:12,copy_d:21,copy_data:[4,24],copy_from:[4,23,35],copy_not:[4,35],copy_of_batch1:12,copy_onli:[4,35],copy_to:[4,23,35],core:[5,20,22,25,35,37],correct:[9,23,35],correctli:35,correspond:[4,5,9,22,23,24,35,37,39],could:[23,24,26],count:[4,5,7,9,10,31,35,38],count_not:[4,22,35],count_onli:[4,22,35],counterpart:35,counts_cumsum:[31,35],counts_sum:31,cpickl:2,crash:35,creat:[2,3,4,6,9,10,11,13,14,15,16,18,20,22,24,28,31,35,36],create_set:[4,35],creation:[9,18,23,35],cross:[13,28,31],crossbreak:28,crosstab:[4,24],crunch:35,csv:[0,4,10,11,18],cum_sum:9,cumul:[7,9,10,27,35],cumulative_sum:[10,31],current:[0,2,4,10,24,34,35],custom:[4,10,16,18,20,24,35],custom_text:[10,31],customis:35,customiz:0,cut:[4,21],cut_item_text:4,cwi_filt:9,cycl:[4,8],dai:[22,26],danish:19,data:[2,4,5,6,7,9,10,11,14,15,20,21,23,24,28,31,34,35,36,38],data_df:[4,35],data_kei:[4,10,14,28,35],datafil:[4,35],datafram:[3,4,6,7,9,10,18,19,21,22,23,28,31,34,35],datakei:35,dataset:[0,1,10,11,12,13,18,20,22,24,28,31,34,35,36,37],dataset_left:4,dataset_right:4,datasmoothi:0,date:[4,10,19,20,21,22,23,24,35],dates_as_str:20,ddf:[0,4,35],deafult:[5,9],deal:20,decim:4,deciph:[0,18],deck:0,decod:10,decode_str:10,decor:35,deep:4,deepcopi:35,defin:[2,3,4,9,10,13,14,19,21,23,28,31,35,37],definit:[2,4,5,9,10,14,19,24,26,27,28,34,35],definiton:[8,19,35],defint:[0,2,4,5,6,9,10,14,19,35],defintit:[21,39],defintiton:23,deleg:26,delet:[4,10],delimied_set:22,delimit:[4,10,19,20,21,22,23,24,25,26,35,37],delimited_set:[22,24,35],demograph:21,depend:[5,13,14,35],deprec:34,deriv:[4,9,18,21,35,37],derivc:8,derive_categor:35,derot:[4,35,36],desc:4,descend:4,describ:[0,2,3,4,10,14,19,21,28,31],descript:[4,5,8,9,10,19,27],design:20,desir:[4,6,22,35,37],detail:[7,18,19],detect:[4,6],determin:[4,5,10],detractor:31,deutsch:[19,23],dff:20,diagram:28,dicat:24,dice:18,dichot:20,dichotom:[4,19,20,35],dict:[2,3,4,5,6,7,8,9,10,19,23,24,26,31,35,38],dictat:21,dictionari:[4,6,7,8,10,35],differ:[5,7,9,10,13,19,20,23,24,28,31,35,36,38],digest:19,dim:[5,9,31],dim_comp:35,dimens:[0,4,5,9,18,35,36],dimension:4,dimensionizing_mapp:4,dimensions_comp:[4,20,35,39],dinner:22,direct:26,directli:[2,4,22,35],discret:[10,13],disk:[4,21,34],dispers:5,distinct:[19,31],distribut:[5,9],div:10,dive:[19,24,39],divid:9,dk_filter:4,dms:4,dmsrun:4,doc:[22,35],docstr:6,document:[0,4,10,19,20,23,35],doe:[4,11,23,26,35],doesn:[4,25,26],dog:19,don:[19,22,24,37],done:[4,13,14],doubl:22,down:39,downbreak:[28,31],download:39,draw:[21,24],drawn:[4,35],drink:38,drink_1:38,drink_2:38,drink_level:38,driven:0,drop:[4,5,9,10,21,35],drop_delimit:4,drope:[4,38],dropna:[4,6,35,38],dropx:4,dto:39,dtype:[20,22,26,35],dump:20,duplic:[4,23,35],durat:22,dure:[4,9,10,24],each:[2,4,5,6,10,13,14,19,23,24,28,31,38,39],eagleston:0,eas:35,easi:[0,19,22,23,35],easier:[12,22,28],easiest:22,easili:[12,20,31,35],ebas:10,echo:4,ect:35,edit:[0,4,7,9,13,14,15,18,19,21,24,26,35],edit_param:7,eff:9,effect:[6,9,26,34],ein:[19,23],either:[4,5,9,13,19,21,22,23,26,35],element:[4,9,10,19,35,39],eleph:4,els:26,emploi:19,empti:[4,10,22,24,26,35],en_u:10,enabl:[23,35],encod:4,encount:20,end:[2,4,10,11,12,34,35],end_tim:22,enforc:35,eng:[4,35],engin:[1,27],english:[19,35],enrich:35,ensur:[4,11],enter:[4,14],entir:[4,9,20,35],entri:[4,6,9,10,19,26,35],enumer:[4,10,23,24,26,37],eponym:35,equal:[9,35],equip:31,equival:[4,39],eras:[4,10],error:[4,9,34,35],escap:4,especi:[22,26,31],estim:9,etc:[4,19,21,28,31,35],ethnic:[13,22,28,31],even:[31,35],ever:20,everi:[22,23,26],everyon:26,everyth:26,evid:31,exact:[4,35],exactli:[4,24,25],exampl:[2,4,5,10,11,18,19,20,22,24,25,28,31,35,38,39],excel:[0,3,4,5,35],except:[4,21,34],exchang:[9,23],exclud:[4,5,7,9,10,31,35],exclus:[4,25,35],execut:4,exercis:[22,24],exist:[4,9,10,12,13,18,21,23,24,26,31,35],expand:[4,7,9,10,31],expect:24,experiment:4,explain:14,explicit:26,explicitli:[4,10,35,37],explor:19,expos:23,express:[4,5,6,9,10,22,25,35],ext_valu:4,ext_xk:35,ext_yk:35,extend:[4,5,13,18,22,31,35],extend_filt:14,extend_i:[13,35],extend_valid_tk:35,extend_valu:[4,23,35,37],extend_x:35,extens:[3,4,10,19,20,35],extra:35,extract:14,extrapol:25,factor:[4,6,10],factor_l:10,factor_label:10,fail:[4,35],failur:20,fall:[4,5,9],fallback:7,fals:[4,5,9,10,13,20,22,23,24,26,31,35],favour:9,featur:[19,35],feed:[4,35],feedback:4,femal:[4,22],few:[11,21,22,35,38],figur:9,file:[2,3,4,5,10,11,20,21,22,28,34,35,39],file_nam:20,filenam:[2,10],fill:[4,18,35],fillna:[4,18],filter:[4,6,9,10,11,15,18,28,31,35],filter_def:6,filter_kei:14,find:[4,11,22,28,35],find_duplicate_text:4,finish:[4,21],finnish:19,first:[4,5,9,13,19,21,26,31],fit:[19,23,24],fix:[4,15,35],flag:[4,5],flag_bas:9,flatten:[4,24,35],flexibl:[6,10,24],float64:20,folder:20,follow:[4,7,9,11,14,15,19,20,21,22,23,24,26,28,31,35,38,39],folow:26,footbal:24,forc:[26,35],force_text:[4,23,35],form:[3,4,9,10,14,20,23,24,25,26,28],format:[0,4,6,9,19,20,23,26,31,35,38],former:[4,10,22,23,24],fortnight:22,found:[2,3,4,9,10,20,22,24,26,31,35],four:[28,31],frang:[4,25,26,35,38],french:19,frequenc:[4,5,7,8,9,28,31,35],freysson:0,from:[0,2,3,4,5,9,10,12,14,15,18,19,21,24,25,26,28,31,34,35,38],from_compon:[4,20,35],from_excel:[4,35],from_sav:10,from_set:[4,20,35],from_stack:[4,35],front:35,fulfil:4,full:[3,4,5,10,21,23,25,39],fullnam:31,fun:34,further:21,futur:35,geir:0,gender:[4,13,14,15,22,24,26,28,31,35,38],gener:[2,4,5,7,8,10,11,20,22,23,26,31,35],german:[19,23],get:[4,7,10,11,12,13,14,22,28,31,35,37],get_batch:[4,12,13,28,31],get_edit_param:7,get_qp_dataset:35,get_s:9,get_sig:9,get_statist:9,get_std_param:7,give:[13,26,35],given:[4,5,6,9,10,20,26,35],global:[4,7,9,14,15,21,35],goe:4,going:37,grid:[4,35],griffith:0,group:[4,5,6,7,9,10,19,21,22,24,25,28,31,35],group_nam:6,group_target:6,grouped_ag:24,grp:9,grp_text_map:31,guid:35,gzip:10,hack:4,had:26,hand:24,handl:[0,6,8,9,10,20,31,35,37,39],happen:[4,24],happend:4,has:[2,4,10,12,15,19,21,25,26,31,34,35,38],has_al:[4,5,18],has_ani:[4,18],has_count:18,has_other_sourc:7,have:[4,9,10,13,20,23,24,25,26,28,34,35,38],head:[20,22,23,24,26,35,39],heirarch:4,hell:4,hello:20,help:[26,28,31],helper:[4,31],here:[4,26,28,35,39],hidden:[4,35],hide:[4,15,35],hide_valu:[4,35],high:[5,9],higher:9,hmerg:[4,35],hockei:24,hold:[2,4,9,10],horizont:[4,18],household:20,how:[3,4,10,14,19,22,24,28,31,37,39],howev:[23,24,26,37,39],hrafn:0,html:[4,23,35],ident:[4,20,24,35],identif:4,identifi:[4,5,23,35,38],ids:4,ignor:[4,9,10,22,24,35],ignore_cod:4,ignore_flag:9,ignore_item:[4,24,35],ignore_valu:[4,24],ill:23,implement:[9,19,22,34,35],impli:4,implicitli:9,impract:28,impute_method:6,incl:[10,35],includ:[2,3,4,5,9,10,13,25,26,28,31,35,38],inclus:[24,35],incom:[4,9,24],inconsist:[4,15,23,35],incorrect:35,incorrectli:35,independ:9,index:[0,2,4,9,10,35],indic:[4,5,9,10,23,24,26,35],individu:[3,4,35],industri:20,infer:[10,20,24,35],info:[4,18,19],inform:[0,4,7,8,13,14,15,19,20,23,26,31,35,37,38],inherit:11,inhomogen:9,init:26,initi:[4,18,35,38],inject:[4,26],innermost:7,inplac:[4,9,10,18,21,26,35],input:[6,9,10,11,20,35],insert:[4,13],insid:[2,4,8,9,19,20,22,23,35],inspect:[4,18,35],instal:[4,35],instanc:[2,3,4,8,9,10,11,14,20,21,22,23,24,28,31,35],instead:[4,9,20,25,26,35],instruct:[5,9,19,26,31,35],int64:[20,22],integ:9,integr:22,intend:10,inter:[4,6],interact:[2,3,21,22,34],interfac:0,interim:35,interlock:[4,18,35],intern:[2,35],interpret:[4,25],intersect:[4,18,22,35],intro:21,introduc:9,involv:26,iolocal:[10,20],ioutf8:10,ipython:[21,34],is_arrai:31,is_bas:7,is_block:31,is_count:7,is_cumul:7,is_g:[4,25,35],is_like_numer:[22,24,35],is_meanstest:7,is_multi:31,is_nan:[4,22,25],is_nest:31,is_net:7,is_pct:7,is_propstest:7,is_stat:7,is_sum:7,is_weight:[7,31],isol:35,issu:[20,35],ist:[19,23],item:[4,9,11,13,19,20,21,22,23,24,31,34,35,37,38,39],item_no:[4,35],item_text:[4,22,35],iter:[8,22,34,35],its:[2,4,5,7,9,10,11,12,13,14,15,19,20,22,24,25,26,31,34,35,38,39],itself:[4,9],jame:0,jjda:20,jog:24,join:[4,22],json:[4,10,11,18,35],jupyt:[21,34],keep:[4,8,9,21,23,24,35,38],keep_bas:9,keep_cod:[9,35],keep_origin:4,keep_variable_text:35,kei:[2,4,5,7,10,11,14,19,23,24,26,31,35,38],kept:[4,9,11,35],kerstin:0,keyword:[5,8],kind:[22,24,28],kite:[19,24,39],know:[14,19,22,24,37,39],kritik:31,kwarg:[4,5,7,8,35],lab:10,label:[4,5,10,14,19,20,22,23,24,26,35,37,38,39],lack:0,lang:19,languag:[4,11,18,23],larg:[14,21,28,31],last:4,later:[13,20,34],latest:[0,33],latter:[22,34],lead:[24,31],least:[4,22,23],leav:[23,24],left:[4,9,35],left_id:4,left_on:[4,35],legaci:4,lemonad:38,length:35,less:[22,38],let:[23,24,28],letter:[],level:[4,5,9,10,14,19,26,31,35,38],lib:[4,19,35,39],librari:[0,19,35],lift:24,like:[0,4,5,10,13,14,19,21,22,24,26,28,31,34,35,38,39],limit:[9,24,26,35],link:[2,4,5,7,8,9,10,11,14,27,31,35],list:[2,4,5,6,8,9,10,13,18,19,21,22,23,24,26,35,37,38],list_vari:[4,34,35],listen:26,load:[2,3,4,10,11,35],load_cach:10,loc:31,local:[10,13,22,28,31],locat:[2,4,10,35],logic:[4,5,7,9,18,22,24,26,35],logic_a:[25,26],logic_b:[25,26],logic_c:[25,26],london:4,longer:35,look:[13,24,26,35,38,39],loop:[35,38],lose:[13,24,38],lot:[4,21,22,26],low:[5,9],lower:[4,9,35],lower_q:9,lunch:22,machin:[4,20,35],made:2,mai:[4,25,26],main:[4,6,9,13,14,19,24,31,34,35],mainli:3,major:9,mak:35,make:[4,5,22,24,28,34,35],make_summari:13,make_templ:8,male:[22,26],manag:[0,18,26],mani:[13,28],manipul:[9,13,15],manual:[5,35,37],map:[4,5,6,8,9,10,18,20,23,35,37],mape:4,mapper:[4,18,25,35,38],mapper_to_meta:4,margin:[5,9],mark:9,market:[0,20],mask:[4,18,21,22,23,35,37,38,39],mass:5,massiv:26,master:35,match:[4,6,10,20,24,35,39],matric:9,matrix:9,matrixcach:10,matter:11,max:[9,10,31,35],max_iter:6,mdd:[0,4,20,35],mdm:4,mdm_lang:[4,35],mean:[4,5,6,7,9,10,13,15,20,22,24,25,26,31,35,38],measur:[5,9],median:[6,9,10,31,35],membership:22,memori:[21,34],men:[4,14,15,28,31],mention:[12,23],merg:[3,4,18,35],merge_text:[4,35],messag:35,meta:[4,5,7,10,11,12,14,15,18,20,21,22,24,26,31,35,37,38,39],meta_dict:[4,35],meta_edit:15,metadata:[0,4,10,18,19,20,24,26,35,37,39],method:[2,3,4,5,6,7,8,9,10,11,12,13,14,18,20,21,22,23,24,31,34,35,37,38,39],metric:[5,9,10],mid:[5,9,22],might:[10,21,23,24],mimic:[5,9],mimick:[5,9,22],min:[9,10,31,35],minimum:5,minor:35,miss:[4,6,7,14,20,22,23,24,37,39],missing_map:4,mix:[4,24],mode:[6,10,20,35,36],modifi:[4,9,10,15,24,35],modu:35,modul:[0,10],month:22,more:[2,4,22,25,26,31,35],morn:22,most:[9,21,22,26],mous:4,move:[0,4,21,35],mrs:4,mrset:4,mrset_tag_styl:4,much:[28,38],mul:10,multi:[5,9,19],multiindex:9,multipl:[0,3,4,5,19,22,23,25,26,34,35],multipli:9,multivari:9,must:[4,6,10,20,21,23,26,31,35,38],name:[2,3,4,5,6,7,8,9,10,12,13,19,20,21,22,23,24,26,28,31,35,37,38,39],name_data:[35,39],nan:[4,9,20,22,23,24,26,28,31,35,39],nate:4,nativ:[0,4,18,35],natur:[9,21,22],necessari:[9,21,35,38],need:[8,9,21,23,24,39],neg:35,nest:[7,10,19,25,26],net1:[],net2:[],net:[5,7,9,10,18,27],net_1:[10,31],net_2:[10,31],net_3:10,net_map:[10,31],never:[22,23],new_arrai:23,new_array_1:23,new_array_2:23,new_array_3:23,new_array_4:23,new_array_97:23,new_array_98:23,new_chain:35,new_cod:9,new_d:35,new_data:10,new_data_kei:10,new_dataset:4,new_int:23,new_meta:10,new_nam:[4,23,24,35],new_ord:[4,21,35],new_rul:35,new_set:[4,35],new_singl:23,new_stack:2,new_text:[4,23],new_var:35,new_weight:10,next:[4,10,11,19,31,39],no_data:24,no_filt:[4,10,28,31,35],non:[4,10,22,25,27,35],none:[2,3,4,5,6,7,8,9,10,13,20,21,22,23,24,26,28,34,35,37,39],none_band:35,nonea:4,normal:[4,5,9],norwegian:19,not_al:18,not_ani:[4,9,18,35],not_count:18,notat:[5,7,9,10],note:[2,4,5,26,31],notebook:[21,34],notimplementederror:[15,34,35],now:[13,14,21,31,34,35,38],num:5,number:[4,6,9,20,22,23,24,35],numer:[4,5,10,18,19,23,24,31,35,37],numpi:[0,9],obei:22,object:[2,3,4,5,9,10,18,20,21,24,26,28,31,35,37],obscur:26,observ:0,obvious:31,occur:26,oe_q8:13,oe_q9:13,offer:[0,4,19,22,24,34,37,39],often:[21,22,24],old:[4,5,10,35],old_cod:9,old_nam:35,older:35,omit:26,on_var:[10,31],onc:22,one:[2,4,5,12,13,19,21,22,23,24,26,28,31,34,35],ones:[4,9,15,21,22],onli:[4,8,9,10,11,13,14,21,23,24,26,28,31,34,35,37,38],only_men:24,only_typ:[4,10],onto:26,open:[0,11,12,34],oper:[4,5,20,22,24,25,26,34],operat:18,opportun:20,oppos:21,option:[4,5,6,9,10,13,14,19,22,23,31,35],order:[2,4,11,18,19,24,34,35],ordereddict:[3,10,13,28,31],organ:16,orgin:9,orient:2,origi:4,origin:[4,9,10,21,24,35],other:[4,5,9,11,12,13,19,23,24,25,26,35,38],other_sourc:[10,31,35],otherwis:[4,35],our:[0,22,26],out:[5,12,14,24,31,35],outcom:4,outdat:35,output:[4,9,10,13,22,35],outsid:35,over:[8,9,35],overcod:[4,10,31],overlap:9,overview:[4,10,22,28,35],overwrit:[4,15,21,26,35],overwrite_margin:9,overwrite_text:4,overwritten:[4,10,35],ovlp_correc:9,own:13,pack:4,packag:5,paint:3,pair:[4,5,9,18,23,26,35,37],panda:[0,3,4,6,9,10,19,20,22,26,35],pane:4,parachut:[19,24,39],parallel:10,paramet:[3,4,5,6,7,8,9,10,13,21,22,23,24,26,31,35,38],parent:[4,19,20,34,35],pars:5,part:[4,7,19,21,22,26],parti:18,particip:20,particular:4,pass:[4,5,9,10,21,22,24,35],past:26,path:[2,3,4,10,20,35],path_clust:3,path_csv:20,path_data:[4,39],path_ddf:[4,20,35],path_json:20,path_mdd:[4,20,35],path_meta:4,path_report:4,path_sav:[4,20],path_sav_analysi:20,path_stack:10,path_txt:20,path_xlsx:[4,35],path_xml:20,pct:4,peopl:20,per:[4,5,6,9,10,12,20,22,23,24,26,35,39],percentag:[7,9,10,31],perform:[4,5,7,9,10,21,26,31,35],perman:21,physic:34,pick:[4,24],pickl:2,pilat:24,pivot:10,place:[4,9,26],plai:22,plain:[0,7,20],plan:[11,13,14,19,24,28,31],pleas:[21,22,35],point:19,pointer:19,pool:9,popul:[4,11,13,14,27,31,35],portion:10,posit:[4,9,21,22,23,28,35],possibl:[3,4,5,10,12,13,19,22,23,25,31,34,35,38],power:0,powerpoint:[5,35],powerpointpaint:35,pptx:35,pre:[4,26,31],precis:[26,35],prefer:22,prefix:[4,10],prep:25,prepar:[3,21,23,31,35],present:[4,9,35],preset:[4,10],pretti:[4,26],prevent:[15,21,23,24,34,35],previou:[21,34],previous:35,print:[13,22,28,31,35],prior:[4,24],probabl:[19,24],problem:35,process:[0,4,8,10,20,21,22],produc:[5,9,13,24],product:38,profession:[4,35],progress:4,prohibit:23,project:0,promot:31,promotor:31,prop:[5,31],prop_nam:4,prop_valu:4,proper:[35,39],properli:39,properti:[4,9,11,20],proport:[5,6,7],protect:4,provid:[3,4,5,7,8,9,10,19,20,21,22,23,24,26,31,34,35,37],proxi:10,purpos:19,put:10,q11:35,q11_grid:35,q12:38,q12_10:38,q12_11:38,q12_12:38,q12_13:38,q12_1:38,q12_2:38,q12_3:38,q12_4:38,q12_5:38,q12_6:38,q12_7:38,q12_8:38,q12_9:38,q12_:38,q12a:38,q12a_10:38,q12a_11:38,q12a_12:38,q12a_13:38,q12a_1:38,q12a_2:38,q12a_3:38,q12a_4:38,q12a_5:38,q12a_6:38,q12a_7:38,q12a_8:38,q12a_9:38,q12a_grid:38,q12b:38,q12b_10:38,q12b_11:38,q12b_12:38,q12b_13:38,q12b_1:38,q12b_2:38,q12b_3:38,q12b_4:38,q12b_5:38,q12b_6:38,q12b_7:38,q12b_8:38,q12b_9:38,q12b_grid:38,q12c:38,q12c_10:38,q12c_11:38,q12c_12:38,q12c_13:38,q12c_1:38,q12c_2:38,q12c_3:38,q12c_4:38,q12c_5:38,q12c_6:38,q12c_7:38,q12c_8:38,q12c_9:38,q12c_grid:38,q12d:38,q12d_10:38,q12d_11:38,q12d_12:38,q12d_13:38,q12d_1:38,q12d_2:38,q12d_3:38,q12d_4:38,q12d_5:38,q12d_6:38,q12d_7:38,q12d_8:38,q12d_9:38,q12d_grid:38,q14_1:4,q14_1_1:4,q14_1_2:4,q14_1_3:4,q14_2:4,q14_2_1:4,q14_2_2:4,q14_2_3:4,q14_3:4,q14_3_1:4,q14_3_2:4,q14_3_3:4,q1_1:[4,25,26,38],q1_2:[4,26,38],q1_3:[4,26],q1_rec:4,q2_count:22,q2array_tran:4,q2b:[13,22,28,31],q3_no_data:24,q3_only_men:24,q3_rec:24,q3_version2:24,q4a:35,q4a_1:35,q4a_2:35,q4a_3:35,q4a_grid:35,q5_1:[19,21,22,24,35,39],q5_2:[19,21,22,24,35,39],q5_3:[19,21,22,24,35,39],q5_4:[19,21,22,24,35,39],q5_5:[19,21,22,24,35,39],q5_6:[19,21,22,24,35,39],q5_grid:39,q5_tran:24,q5_trans_1:24,q5_trans_2:24,q5_trans_3:24,q5_trans_4:24,q5_trans_5:24,q5_trans_97:24,q5_trans_98:24,q6_1:[13,21,22,28,31],q6_2:[13,21,22,28,31],q6_3:[13,21,22,28,31],q6_calc:31,q6_grid:39,q6_net:31,q6copi:39,q6new:39,q6new_grid:39,q6new_q6copi:39,q6new_q6copy_grid:39,q6new_q6copy_tran:39,q6new_q6copy_trans_grid:39,q7_1:[21,22,35],q7_2:[21,22,35],q7_3:[21,22,35],q7_4:[21,22,35],q7_5:[21,22,35],q7_6:[21,22,35],q7_grid:39,q8_with_a_new_nam:23,q8a:[13,22],q9a:[13,22],q_group:38,q_label:[4,35],qtp:38,qtype:[4,23,37,39],qualifi:[5,9],quantifi:1,quantipi:[2,3,4,5,6,7,8,9,10,11,19,20,22,25,31,35,37,39],quantipyview:[1,10,35],quantiti:[9,35],queri:[2,4,6,10,18,19,24,34,35,39],question:[4,9,19,24,26,31,35,38],questionnair:21,quick:[4,22,35],quickli:[6,21,22,24,35],radio:26,radio_st:26,radio_stations_cb:26,radio_stations_xb:26,rais:[4,15,21,31,34,35],rang:[4,5,18,21,35],rate:[35,38],raw:[5,9],raw_sum:9,rbase:10,read:[0,4,20,35],read_ascrib:[4,20],read_deciph:20,read_dimens:[4,20],read_quantipi:[4,11,20,35,39],read_spss:[4,20],rebas:9,rebuild:24,rec:[4,35],receiv:38,recod:[0,4,18,34,35],recode_seri:4,recommend:24,record_numb:[13,22],reduc:[4,9,10,21,35],reduced_d:21,reduct:4,refactor:35,refer:[4,9,10,19,23,26,28,31,35],referenc:[10,13,19,26,35],reflect:[9,21,35],refresh:10,refus:[19,24],regard:4,region:[4,35],regist:[4,22,35],regular:[4,19,31],regularli:[22,23,24],reindex:4,reintroduc:34,rel:21,rel_to:7,relat:[2,7,23,26,34,35],relation_str:7,relationship:10,relev:23,religion:22,reload:[21,34],remain:[4,5,21,26,35],rememb:37,remind:37,remov:[4,5,9,10,12,13,18,34,35],remove_data:10,remove_html:[4,35],remove_item:4,remove_valu:4,renam:[4,18,24,35,39],rename_from_mapp:4,renamed_item:4,renamed_v:4,reorder:18,reorder_valu:4,reorgan:0,repair:[4,35],repair_text_edit:[4,35],repeat:[21,28],repetit:26,replac:[4,9,13,23,26,31,34,35],replace_i:13,replace_text:[4,35],report:[0,4,5,6,35],reposit:[21,35],repres:[4,26],represent:[7,9,10,19,24],request:[5,10,13,21,23,26,31],requir:[4,21,23,35,39],rescal:[5,7,9,10,31],research:[0,20],reserach:[],reset:[4,35],reset_index:4,resid:35,respect:[4,9,24,35,37],respond:[9,21,38],respons:[19,22,25,26,35,38],restor:[21,35],restrict:[4,5,9,10,19,21,22,35],result:[3,4,5,8,9,10,16,20,22,23,24,26,28,35],result_onli:9,retain:8,retriev:9,revers:[24,25],revert:[21,34],right:[4,35],right_id:4,right_on:[4,35],rim:[1,4],rollback:[18,34],round:6,row:[4,5,9,18,20,22,35,39],row_id:4,row_id_nam:4,rule:[4,39],run:[4,9,10,15,24,28,31,35],safe:[4,23],safeguard:4,sai:26,same:[3,4,10,13,19,20,22,26,28,34,35,38,39],sampl:[5,7,9],sample_s:14,satisfi:35,sav:[4,10,20],save:[2,3,4,10,21,28,34,35],savepoint:18,scalar:35,scale:[5,6,9,19,38],scenario:39,scheme:[4,6,19],scratch:18,script:4,search:4,second:[4,5,9,15,31],sect:4,section:[7,9,11,14,21,26],see:[13,21,24,26,28,31,34,35],seen:[26,39],segemen:26,segment:18,select:[4,8,10,13,14,21,22,31,35,38],self:[2,4,9,26,28,35],sem:[9,10],separ:[4,26,37],septemb:[],seri:[4,19,22,26,35],serial:2,session:[21,34],set:[3,4,5,6,8,9,10,11,12,13,18,19,20,22,23,24,26,28,35,37],set_cell_item:14,set_col_text_edit:35,set_column_text:35,set_encod:4,set_item_text:[4,23,35],set_languag:14,set_mask_text:35,set_miss:4,set_opt:35,set_param:9,set_properti:[4,15],set_sigtest:[14,31],set_target:6,set_text_kei:4,set_val_text_text:35,set_value_text:[4,15,23,35],set_var:4,set_variable_text:[4,15,23,35],set_verbose_errmsg:4,set_verbose_infomsg:4,set_weight:14,setdefaultencod:4,setnam:[4,35],setup:[4,9,13,35],sever:[5,22,38],shape:[4,21,31],share:[4,19],sheet:[4,35],shop:4,short_item_text:35,shorten:[4,35],shorthand:[4,5],shortnam:[5,7],should:[3,4,10,14,21,22,26,35,38,39],show:[4,9,13,19,21,22,31,35],shown:[4,9,35],side:[8,34],sig:[5,9,10,14],signific:[5,9,11,27],similar:[28,38],similarli:[22,23],similiar:23,simpl:[5,6,9,19,25,35,37],simpli:[4,22,23,24,25,31],simplifi:[24,26],sinc:[9,26,31,39],singl:[3,4,10,19,20,21,22,23,24,26,35,37,39],sit:26,six:22,size:[5,7,9,21,22,31],skip:[22,23,31,35],slice:[4,7,15,18,35],slicer:[4,18,22,24,35],slicex:4,small:[5,35],snack:22,snapshot:[21,34],snowboard:[19,24,39],soccer:24,social:0,softwar:[0,4,5,9,20],solut:34,some:[13,14,15,22,25,26,35,38],someth:38,sometim:[21,28],soon:[34,35],sorri:0,sort:[4,15,35],sort_by_weight:4,sortx:4,sourc:[0,4,10,19,20,22,23,35,39],source_item:4,space:[4,25],speak:19,spec:3,spec_condit:7,specfic:14,special:[0,11,14,19,28,31,35],specif:[3,4,5,7,9,10,11,13,14,15,19,21,23,39],specifi:[2,4,5,6,9,10,13,20,23,31,35,37],split:[4,10,13,35],split_view_nam:10,sport:[20,22],spreadsheet:0,spss:[0,4,9,18,35],spss_limit:35,stack:[2,3,4,5,7,11,13,14,27,31,35],stage:34,standalon:18,standard:[7,9,20],standardli:24,start:[4,18,23,24,26],start_meta:[4,35],start_tim:22,stat:[5,9,10,31],state:[15,18,24,34],statement:[4,5,19,25,26],statisfi:35,statist:[0,4,5,7,9,10,18,27,28,35],std_paramet:7,stddev:[9,10,31,35],ste:35,stem:35,step:[31,37],still:26,store:[4,5,10,11,12,13,19,21,24,28,31,34,35],store_cach:10,str:[3,4,5,6,7,8,9,10,24,35,37,38],strict:[4,35],strict_select:8,strictli:23,string:[2,4,6,7,9,10,19,20,21,22,23,24,25,35],strip:35,structur:[0,4,6,8,10,11,13,19,20,21,24,28,35,38],studi:35,stuff:[],style:[4,10],sub:[10,31],subclass:[2,11],subclasss:15,subset:[4,8,18,22,24,35],subset_d:4,subtl:34,subtyp:[19,35,39],suffix:[4,5,24,39],sum:[4,5,7,9,10,27,35],summar:[4,5,9,35],summari:[4,5,6,7,9,10,13,22,31,34,35],summat:9,suppli:24,supporintg:10,support:[0,7,10,18,19,22,23,24,35,39],surf:[19,24,39],survei:21,sv_se:[31,35],swap:[7,9,10,35],swedish:[19,35],swim:24,sys:4,tab:20,tabl:[0,10],tabul:[5,13,28],tag:[4,23,35],take:[4,5,11,22,24,25,26,34,35,38],taken:[4,10,14,15,24,35],target:[4,6,18,23,35],target_item:4,task:22,team:22,temp:4,templat:[5,8,35],temporari:[4,34,35],ten:26,tend:4,term:[10,23,35],test:[2,4,5,7,9,11,22,27,35,37],test_cat_1:37,test_cat_2:37,test_cat_3:37,test_tot:[5,9],test_var:37,testtyp:9,text1:20,text:[4,5,7,10,14,18,20,21,22,24,26,31,35,37,39],text_kei:[3,4,10,11,18,22,23,31,35],text_label:[4,35],text_prefix:10,textkei:[4,35],than:[4,22,24,35],thei:[4,9,13,14,20,25,26,31,35],them:[4,5,13,20,22,26,31,35],themselv:[4,9],therefor:[4,5,24],thi:[2,3,4,5,6,9,10,13,14,15,20,21,22,23,24,26,28,31,35,38,39],third:18,thorugh:24,those:4,three:[4,21,22,24,26,35,37],threshold:5,through:[2,3,4,8],throughout:[4,19,20,35],thu:6,time:[10,19,21,22],titl:13,tks:35,to_arrai:[4,35,38],to_df:9,to_excel:10,todo:[4,5,6,8,9,10],togeth:[3,4,10,19,21],toggl:10,too:34,tool:[5,20,24,25],top2:31,top3:10,top:26,topic:[19,35],total:[4,5,6,9,13,35],toward:35,tracker:35,transform:[0,4,5,9,18],translat:23,transpos:[4,13,24,31,39],transpose_arrai:13,transposit:24,treat:[4,9,25,31],tree:28,treshhold:9,trigger:4,tstat:9,tupl:[4,7,23,24,35,37],turn:19,two:[4,5,9,13,19,21,23,28,31,34,35],txt:[4,20],type:[0,3,4,5,6,7,8,9,10,13,18,20,23,26,31,34,35,37,39],type_nam:10,typic:26,ultim:4,unabbrevi:25,unattend:4,uncod:[4,35],uncode_seri:4,uncodit:5,unconditi:9,under:[4,5],underli:19,understood:20,undimension:4,undimensionizing_mapp:4,uni:[5,9],unicod:10,unifi:[4,34],uniformli:20,unify_valu:4,union:[18,26],uniqu:[4,5,10,24,28,31],unique_id:22,unique_kei:[4,35,38],uniquify_kei:4,unkei:26,unless:4,unlik:[19,24],unpool:9,unqiu:24,unrol:[4,31,35],untouch:23,unusu:35,unwant:[4,35],unweight:[9,10,31],unweighted_bas:[10,31],upcom:[],updat:[4,7,8,9,23,34,35],update_axis_def:[9,35],update_exist:[4,35],upon:19,upper:[4,35],upper_q:9,usag:[23,35],use:[0,2,4,5,9,12,13,19,20,21,22,23,24,26,34,35,36],use_ebas:9,used:[2,3,4,5,7,8,9,10,11,14,15,20,21,24,26,31,35],useful:[21,22,34],user:[2,4,14,34,35,37],userwarn:[35,37],uses:[4,9],using:[0,2,3,4,6,10,19,20,21,24,25,26,28,31,35,39],usual:19,utf:10,val:4,val_text_sep:4,valid:[4,6,10,14,19,24,26,31,35,37],valid_cod:35,valid_tk:[11,35],valu:[3,4,5,6,7,8,9,10,18,20,21,24,25,26,31,35,36,39],value_count:[22,35],value_map:38,value_text:[4,22,35],valueerror:[4,21,23,35],var_exist:[22,35],var_grid:38,var_nam:38,varcoeff:9,vari:22,variabl:[0,4,5,6,7,9,10,11,18,19,20,23,27,34,35,37,38,39],variable_typ:10,variables_:[],variables_from_set:[4,34,35],varianc:9,variant:22,varibal:38,varibl:35,variou:[5,14,22,28,31],varlist:[4,35],varnam:[4,35],vector:9,verbatim:11,verbos:[4,10,25,31,35],veri:[19,23,24],versa:9,version2:24,version:[4,5,9,10,19,21,23,24,26,34,35],versu:31,vertic:[4,18],via:[0,4,5,10,21,22,23,24,31,34,35],vice:9,view:[1,2,3,4,5,8,9,10,14,16,22,27,28,35],view_kei:31,view_name_not:9,viewmapp:[1,10],viewmeta:7,visibl:[31,35],vmerg:[4,35],wai:[10,12,13,19,21,22,23,26,31,35,36],wait:21,want:[21,24,26],warn:[4,31,34,35],water:38,wave:21,week:22,weight:[0,4,6,7,9,10,11,12,22,24,31,35],weight_a:[14,22,31],weight_b:22,weight_column_nam:6,weight_nam:4,weight_schem:4,well:[4,9,20,22,25,26,31,35,39],went:34,were:[26,35],what:[16,19,20,24,26,27,36,39],whatev:[4,26],when:[4,5,9,10,20,21,23,24,26,35,39],where:[2,3,4,9,24,25,26],whether:[5,9],which:[4,5,9,10,11,13,14,15,22,23,24,26,28,31,35,38],whole:[4,35],whose:35,wide:35,wil:4,wildcard:26,window:20,windsurf:[19,24,39],wise:[4,31],witch:35,within:[4,9],without:35,women:15,work:[4,11,21,23,31,34,35],workbook:3,world:20,would:[4,19,24,26],wouldn:[19,24],wrap:35,wrapper:[4,9],write:[4,10,20,21,39],write_dimens:[4,35],write_quantipi:[4,21],write_spss:[4,20],writen:38,written:[21,34],wrong:34,x_filter_map:[28,31],x_kei:14,x_y_map:[13,14,28,31],xdef:9,xks:[10,31,35],xlsx:4,xml:[4,20],xsect:9,xtotal:4,y_kei:[14,28,31],y_on_i:[13,28,31],year:[19,22,39],yes:20,yield:22,yks:35,yoga:24,you:[4,11,13,14,19,20,21,22,23,24,26,28,31,34,35,38,39],younger:24,your:[4,19,20,21,24,26,35],ysect:9},titles:["Quantipy: Python survey data toolkit","API references","Chain","Cluster","DataSet","QuantipyViews","Rim","View","ViewMapper","quantify.engine","Stack","<code class=\"docutils literal\"><span class=\"pre\">Batch</span></code>","Creating/ Loading a <code class=\"docutils literal\"><span class=\"pre\">qp.Batch</span></code> instance","Adding variables to a <code class=\"docutils literal\"><span class=\"pre\">qp.Batch</span></code> instance","Set properties of a <code class=\"docutils literal\"><span class=\"pre\">qp.Batch</span></code>","Inherited <code class=\"docutils literal\"><span class=\"pre\">qp.DataSet</span></code> methods","Builds","Combining results","Data processing","DataSet components","I/O","DataSet management","Inspecting variables","Editing metadata","Transforming variables","Logic and set operaters","Custom data recoding","Analysis & aggregation","Collecting aggregations","The computational engine","Significance testing","View aggregation","Documentation","Release notes","Latest (15/09/2017)","Archived release notes","How-to-snippets","Different ways of creating categorical values","Derotation","<code class=\"docutils literal\"><span class=\"pre\">DataSet</span></code> Dimensions compatibility"],titleterms:{"boolean":25,"case":[19,21,22],"default":26,Adding:[13,26],The:[19,26,29,39],Using:20,about:38,access:39,adding:23,aggreg:[13,17,27,28,31],analysi:27,api:1,append:26,archiv:35,arrai:[13,19,24,38,39],ascrib:20,band:[24,26],base:26,basic:31,batch:[11,12,13,14],build:[16,26],calcul:31,categor:[19,24,31,37],cell:14,chain:[2,17],chang:23,clone:21,cluster:3,code:[25,26],collect:28,column:[19,21],combin:17,compat:39,complex:25,complic:26,compon:[19,20],comput:29,condit:26,convers:[20,24],copi:24,creat:[12,17,23,26,37,39],creation:26,csv:20,cumul:31,custom:[17,26],data:[0,18,19,22,26,39],datafram:20,dataset:[4,15,19,21,23,38,39],deciph:20,defin:[],definit:31,deriv:26,derot:38,descript:31,detail:26,dice:22,differ:37,dimens:[20,39],document:32,edit:23,end:13,engin:[9,29],exampl:26,exist:[22,25],extend:23,featur:0,file:[],fill:26,fillna:26,filter:[14,21],from:[20,23],full:[],gener:[],has_al:25,has_ani:25,has_count:25,horizont:21,how:[36,38],info:23,inherit:15,initi:26,inplac:24,inspect:22,instanc:[12,13],interlock:26,intersect:[25,26],item:14,json:20,kei:[0,13],languag:[14,19],latest:[34,35],link:28,list:25,load:12,logic:25,main:[],manag:21,map:19,mapper:26,mask:19,merg:21,meta:[19,23],metadata:[22,23],method:[15,26],mode:39,nativ:20,net:[26,31],non:31,not_al:25,not_ani:25,not_count:25,note:[33,35],numer:26,object:[19,22,23],open:13,operat:25,order:21,organ:17,pair:20,parti:20,popul:28,posit:[],process:18,properti:14,python:0,quantifi:9,quantipi:0,quantipyview:5,queri:22,rang:25,recod:26,refer:1,rel:[],releas:[33,35],remov:[23,26],renam:23,reorder:23,result:17,rim:6,rollback:21,row:21,savepoint:21,scratch:23,segment:26,septemb:[],set:[14,21,25],signific:[14,30,31],slice:22,slicer:25,snippet:36,special:13,spss:20,stack:[10,28],standalon:20,start:20,state:21,statist:[20,31],subset:21,sum:31,support:20,survei:0,target:26,test:[14,30,31],text:[19,23],text_kei:19,third:20,toolkit:0,transform:24,type:[19,22,24],union:25,upcom:[],use:38,valu:[19,22,23,37],variabl:[13,21,22,24,26,31],verbatim:13,vertic:21,view:[7,17,31],viewmapp:8,wai:37,weight:14,what:[17,28,38]}}) \ No newline at end of file +Search.setIndex({docnames:["index","sites/api_ref/00overview","sites/api_ref/Chain","sites/api_ref/Cluster","sites/api_ref/DataSet","sites/api_ref/QuantipyViews","sites/api_ref/Rim_scheme","sites/api_ref/Stack","sites/api_ref/View","sites/api_ref/ViewMapper","sites/api_ref/quantify_engine","sites/lib_doc/batch/00_overview","sites/lib_doc/batch/01_create_load","sites/lib_doc/batch/02_variables","sites/lib_doc/batch/03_properties","sites/lib_doc/batch/04_subclass","sites/lib_doc/builds/00_overview","sites/lib_doc/builds/01_chains","sites/lib_doc/dataprocessing/00_overview","sites/lib_doc/dataprocessing/01_components","sites/lib_doc/dataprocessing/02_io","sites/lib_doc/dataprocessing/02a_management","sites/lib_doc/dataprocessing/03_inspection","sites/lib_doc/dataprocessing/04_editing","sites/lib_doc/dataprocessing/05_transforming","sites/lib_doc/dataprocessing/06_logics","sites/lib_doc/dataprocessing/07_custom_recoding","sites/lib_doc/engine/00_overview","sites/lib_doc/engine/01_links_stacks","sites/lib_doc/engine/02_quantity","sites/lib_doc/engine/03_test","sites/lib_doc/engine/04_agg_methods","sites/release_notes/00_overview","sites/release_notes/01_latest","sites/release_notes/02_archive","sites/release_notes/03_how_to_snippets","sites/release_notes/how_to_snippets/create_categorical_meta","sites/release_notes/how_to_snippets/derotate","sites/release_notes/how_to_snippets/dimensions_comp"],envversion:52,filenames:["index.rst","sites\\api_ref\\00overview.rst","sites\\api_ref\\Chain.rst","sites\\api_ref\\Cluster.rst","sites\\api_ref\\DataSet.rst","sites\\api_ref\\QuantipyViews.rst","sites\\api_ref\\Rim_scheme.rst","sites\\api_ref\\Stack.rst","sites\\api_ref\\View.rst","sites\\api_ref\\ViewMapper.rst","sites\\api_ref\\quantify_engine.rst","sites\\lib_doc\\batch\\00_overview.rst","sites\\lib_doc\\batch\\01_create_load.rst","sites\\lib_doc\\batch\\02_variables.rst","sites\\lib_doc\\batch\\03_properties.rst","sites\\lib_doc\\batch\\04_subclass.rst","sites\\lib_doc\\builds\\00_overview.rst","sites\\lib_doc\\builds\\01_chains.rst","sites\\lib_doc\\dataprocessing\\00_overview.rst","sites\\lib_doc\\dataprocessing\\01_components.rst","sites\\lib_doc\\dataprocessing\\02_io.rst","sites\\lib_doc\\dataprocessing\\02a_management.rst","sites\\lib_doc\\dataprocessing\\03_inspection.rst","sites\\lib_doc\\dataprocessing\\04_editing.rst","sites\\lib_doc\\dataprocessing\\05_transforming.rst","sites\\lib_doc\\dataprocessing\\06_logics.rst","sites\\lib_doc\\dataprocessing\\07_custom_recoding.rst","sites\\lib_doc\\engine\\00_overview.rst","sites\\lib_doc\\engine\\01_links_stacks.rst","sites\\lib_doc\\engine\\02_quantity.rst","sites\\lib_doc\\engine\\03_test.rst","sites\\lib_doc\\engine\\04_agg_methods.rst","sites\\release_notes\\00_overview.rst","sites\\release_notes\\01_latest.rst","sites\\release_notes\\02_archive.rst","sites\\release_notes\\03_how_to_snippets.rst","sites\\release_notes\\how_to_snippets\\create_categorical_meta.rst","sites\\release_notes\\how_to_snippets\\derotate.rst","sites\\release_notes\\how_to_snippets\\dimensions_comp.rst"],objects:{"quantipy.Chain":{concat:[2,2,1,""],copy:[2,2,1,""],describe:[2,2,1,""],load:[2,3,1,""],save:[2,2,1,""]},"quantipy.Cluster":{add_chain:[3,2,1,""],bank_chains:[3,2,1,""],load:[3,3,1,""],merge:[3,2,1,""],save:[3,2,1,""]},"quantipy.DataSet":{add_meta:[4,2,1,""],all:[4,2,1,""],any:[4,2,1,""],band:[4,2,1,""],by_type:[4,2,1,""],categorize:[4,2,1,""],clear_factors:[4,2,1,""],clone:[4,2,1,""],code_count:[4,2,1,""],code_from_label:[4,2,1,""],codes:[4,2,1,""],codes_in_data:[4,2,1,""],compare:[4,2,1,""],convert:[4,2,1,""],copy:[4,2,1,""],copy_array_data:[4,2,1,""],create_set:[4,2,1,""],crosstab:[4,2,1,""],cut_item_texts:[4,2,1,""],data:[4,2,1,""],derive:[4,2,1,""],derotate:[4,2,1,""],describe:[4,2,1,""],dichotomize:[4,2,1,""],dimensionize:[4,2,1,""],dimensionizing_mapper:[4,2,1,""],drop:[4,2,1,""],drop_duplicates:[4,2,1,""],duplicates:[4,2,1,""],empty:[4,2,1,""],empty_items:[4,2,1,""],extend_items:[4,2,1,""],extend_values:[4,2,1,""],factors:[4,2,1,""],filter:[4,2,1,""],find:[4,2,1,""],find_duplicate_texts:[4,2,1,""],flatten:[4,2,1,""],force_texts:[4,2,1,""],from_batch:[4,2,1,""],from_components:[4,2,1,""],from_excel:[4,2,1,""],from_stack:[4,2,1,""],fully_hidden_arrays:[4,2,1,""],get_batch:[4,2,1,""],get_property:[4,2,1,""],hide_empty_items:[4,2,1,""],hiding:[4,2,1,""],hmerge:[4,2,1,""],interlock:[4,2,1,""],is_like_numeric:[4,2,1,""],is_nan:[4,2,1,""],item_no:[4,2,1,""],item_texts:[4,2,1,""],items:[4,2,1,""],link:[4,2,1,""],merge_texts:[4,2,1,""],meta:[4,2,1,""],meta_to_json:[4,2,1,""],min_value_count:[4,2,1,""],names:[4,2,1,""],order:[4,2,1,""],parents:[4,2,1,""],populate:[4,2,1,""],read_ascribe:[4,2,1,""],read_dimensions:[4,2,1,""],read_quantipy:[4,2,1,""],read_spss:[4,2,1,""],recode:[4,2,1,""],remove_html:[4,2,1,""],remove_items:[4,2,1,""],remove_values:[4,2,1,""],rename:[4,2,1,""],rename_from_mapper:[4,2,1,""],reorder_items:[4,2,1,""],reorder_values:[4,2,1,""],repair:[4,2,1,""],repair_text_edits:[4,2,1,""],replace_texts:[4,2,1,""],resolve_name:[4,2,1,""],restore_item_texts:[4,2,1,""],revert:[4,2,1,""],roll_up:[4,2,1,""],save:[4,2,1,""],select_text_keys:[4,2,1,""],set_encoding:[4,4,1,""],set_factors:[4,2,1,""],set_item_texts:[4,2,1,""],set_missings:[4,2,1,""],set_property:[4,2,1,""],set_text_key:[4,2,1,""],set_value_texts:[4,2,1,""],set_variable_text:[4,2,1,""],set_verbose_errmsg:[4,2,1,""],set_verbose_infomsg:[4,2,1,""],slicing:[4,2,1,""],sorting:[4,2,1,""],sources:[4,2,1,""],split:[4,2,1,""],start_meta:[4,3,1,""],subset:[4,2,1,""],take:[4,2,1,""],text:[4,2,1,""],to_array:[4,2,1,""],to_delimited_set:[4,2,1,""],transpose:[4,2,1,""],unbind:[4,2,1,""],uncode:[4,2,1,""],undimensionize:[4,2,1,""],undimensionizing_mapper:[4,2,1,""],unify_values:[4,2,1,""],unroll:[4,2,1,""],update:[4,2,1,""],validate:[4,2,1,""],value_texts:[4,2,1,""],values:[4,2,1,""],variables:[4,2,1,""],vmerge:[4,2,1,""],weight:[4,2,1,""],write_dimensions:[4,2,1,""],write_quantipy:[4,2,1,""],write_spss:[4,2,1,""]},"quantipy.QuantipyViews":{"default":[5,2,1,""],coltests:[5,2,1,""],descriptives:[5,2,1,""],frequency:[5,2,1,""]},"quantipy.Quantity":{calc:[10,2,1,""],count:[10,2,1,""],exclude:[10,2,1,""],filter:[10,2,1,""],group:[10,2,1,""],limit:[10,2,1,""],normalize:[10,2,1,""],rebase:[10,2,1,""],rescale:[10,2,1,""],summarize:[10,2,1,""],swap:[10,2,1,""],unweight:[10,2,1,""],weight:[10,2,1,""]},"quantipy.Rim":{add_group:[6,2,1,""],group_targets:[6,2,1,""],report:[6,2,1,""],set_targets:[6,2,1,""],validate:[6,2,1,""]},"quantipy.Stack":{add_data:[7,2,1,""],add_link:[7,2,1,""],add_nets:[7,2,1,""],add_stats:[7,2,1,""],add_tests:[7,2,1,""],aggregate:[7,2,1,""],apply_meta_edits:[7,2,1,""],cumulative_sum:[7,2,1,""],describe:[7,2,1,""],freeze_master_meta:[7,2,1,""],from_sav:[7,3,1,""],load:[7,3,1,""],recode_from_net_def:[7,3,1,""],reduce:[7,2,1,""],refresh:[7,2,1,""],remove_data:[7,2,1,""],restore_meta:[7,2,1,""],save:[7,2,1,""],variable_types:[7,2,1,""]},"quantipy.Test":{get_se:[10,2,1,""],get_sig:[10,2,1,""],get_statistic:[10,2,1,""],run:[10,2,1,""],set_params:[10,2,1,""]},"quantipy.View":{get_edit_params:[8,2,1,""],get_std_params:[8,2,1,""],has_other_source:[8,2,1,""],is_base:[8,2,1,""],is_counts:[8,2,1,""],is_cumulative:[8,2,1,""],is_meanstest:[8,2,1,""],is_net:[8,2,1,""],is_pct:[8,2,1,""],is_propstest:[8,2,1,""],is_stat:[8,2,1,""],is_sum:[8,2,1,""],is_weighted:[8,2,1,""],meta:[8,2,1,""],missing:[8,2,1,""],nests:[8,2,1,""],notation:[8,2,1,""],rescaling:[8,2,1,""],spec_condition:[8,2,1,""],weights:[8,2,1,""]},"quantipy.ViewMapper":{add_method:[9,2,1,""],make_template:[9,2,1,""],subset:[9,2,1,""]},Chain:{filename:[2,0,1,""]},quantipy:{Chain:[2,1,1,""],Cluster:[3,1,1,""],DataSet:[4,1,1,""],QuantipyViews:[5,1,1,""],Quantity:[10,1,1,""],Rim:[6,1,1,""],Stack:[7,1,1,""],Test:[10,1,1,""],View:[8,1,1,""],ViewMapper:[9,1,1,""]}},objnames:{"0":["py","attribute","Python attribute"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","staticmethod","Python static method"],"4":["py","classmethod","Python class method"]},objtypes:{"0":"py:attribute","1":"py:class","2":"py:method","3":"py:staticmethod","4":"py:classmethod"},terms:{"0x0000000019ae06d8":[28,31],"\u00ecnt":[20,31],"\u00ectem":38,"boolean":[4,6,7,18,34],"case":[0,4,5,6,7,10,12,13,15,18,20,23,24,26,28,33,34,36,37],"class":[2,3,4,5,6,7,8,9,10,11,22,33,34],"default":[3,4,5,7,8,9,10,13,18,20,21,23,24,33,34,37,38],"export":[0,3,4,20,34],"final":26,"float":[4,5,7,10,19,20,21,22,23,24,31,33,34],"function":[4,7,20,25,26,28,31,34],"import":[4,10,11,15,20,22,25,26],"int":[4,5,7,10,19,20,21,22,23,24,25,33,34],"long":[25,34],"m\u00fcller":0,"new":[3,4,5,7,9,10,12,21,23,24,26,31,33,34,37,38],"null":31,"return":[3,4,5,6,7,8,9,10,21,22,24,26,33,34],"short":[9,19,21,24,34],"sigur\u00f0sson":0,"static":[2,3,4,7],"switch":[24,33,37],"true":[4,5,6,7,9,10,13,20,21,22,24,25,26,31,34,37,38],"try":[4,7,23,34],"var":[4,10,15,33,34,37],"while":[4,15,19,23,24,33,34],Adding:[11,18,31],Age:[24,26],Being:15,But:[13,23],Das:[19,23],For:[4,5,13,14,20,22,23,24,25,26,28,31,33],NPS:31,Not:[19,24,31,34],One:[4,13,26],That:[15,19,22,24],The:[2,3,4,5,7,8,9,10,11,13,14,15,18,20,21,22,23,24,25,27,31,33,34,35,36,37],Their:5,Then:[21,34],There:[13,19,21,22,31,34],These:[15,28,31,34],Use:[4,10,24,34],Uses:4,Using:[7,18,21,23],Will:[4,5,7,10,34],With:[13,22,23,24,26,31],Yes:[20,34],__init__:[12,34],__setitem__:34,_band:4,_batch:[7,31],_cumsum:[31,34],_data:[4,11,21],_dimensions_suffix:34,_get_chain:34,_grid:[34,37],_intersect:[28,31],_meta:[4,11,12,13,22,28,38],_missingfi:10,_net:34,_rc:34,_rec:[4,24,34],_remove_html:4,_request_view:34,_suffix:4,_sum:31,_tran:4,abbrevi:25,abl:[5,28,34],about:[13,19,22,35],abov:[24,31,38],absorb:34,accept:[23,26,34],access:[4,7,19,20,22,34,35],accessor:22,accid:[21,34],accommod:14,accompani:[19,34],accord:[4,7,10,26,31],accordingli:26,account:[4,5,34],achiev:21,across:[10,22,34],act:[5,24,28],activ:[19,20,24,34],add:[3,4,5,7,9,13,14,23,24,28,31,33,34,36],add_batch:[12,31],add_chain:3,add_data:7,add_filt:[14,34],add_group:6,add_i:13,add_link:[7,28,31],add_meta:[4,23,33,34,36,38],add_method:9,add_net:[7,31,34],add_open_end:[13,33,34],add_stat:[7,31,34],add_test:[7,31,34],add_tot:34,add_x:[13,31],add_y_on_i:[13,28,31,34],adddit:20,added:[4,7,12,13,14,23,24,28,31,34,37],adding:[4,14,18,20,31,34,38],addit:[4,13,19,22,31,34],addition:[19,33,34],adjust:[33,34],adopt:13,aerob:24,affect:33,affix:7,after:[4,7,10,21,26,28,31,34],afternoon:22,again:[22,23,31],against:[4,5,10,13,34],age:[4,13,14,22,24,26,28,31,34],age_band:24,age_cb:26,age_grp_rc:26,age_rec:4,age_xb:26,age_xb_1:26,agegrp:[4,34],agg:[8,13,31],aggnam:8,aggreg:[0,2,3,4,5,7,8,9,10,11,14,16,33,34],aim:[0,34],alasdair:0,alert:33,alexand:0,algorithm:[4,5,10,34],alia:[4,21],align:34,all:[2,3,4,5,7,10,11,12,13,14,19,20,21,22,23,24,25,26,28,31,33,34,36,37],allign:34,allow:[4,14,15,23,24,31,33,34],alon:[22,34],along:[2,10],alongsid:[7,21,31],alphanumer:4,alreadi:[4,12,14,19,24,26,34],also:[4,7,10,11,12,13,14,22,23,24,26,28,31,33,34,36,37],altern:[4,23,31,36],although:22,alwai:[4,15,23,24,26,31,33,34,38],amount:[4,14,21,28,31],analysi:[0,34],ani:[4,5,7,8,10,13,19,21,22,23,25,26,33,34],anim:[4,19],anoth:[7,13,23,24,26,34],answer:[4,7,10,19,22,23,24,34],anymor:[33,34],anyth:26,anywher:7,api:4,appear:[4,34,36],append:[4,5,18,31,37],appli:[4,5,7,9,10,15,20,21,22,24,28,31,34,38],applic:[4,24,26],apply_edit:4,apply_meta_edit:7,apporach:21,approach:36,appropri:[4,5],arab:34,arbitrari:7,arbitrarili:[4,21,25,26],archiv:32,argument:[5,9,11,20,23,24,34],aris:28,arithmet:10,around:[4,34],arrai:[4,7,10,11,18,21,22,23,31,33,34,35,36],array_item:34,array_var:38,array_var_1:38,array_var_2:38,array_var_3:38,array_var_grid:38,arriv:10,as_addit:[13,34],as_delimited_set:34,as_df:10,as_float:34,as_int:34,as_singl:34,as_str:34,as_typ:[4,34],ascend:4,ascii:4,ascrib:[0,4,18],asid:24,ask:[19,24],askia:[5,10],aspect:34,assess:[0,37],assign:[4,6,34,36],assignd:24,associ:[2,7],assum:[4,10,28,37],attach:[4,7,21,23,34],attempt:[4,34],attribut:[2,4,11,22,28,31,34],audit:34,auto:[4,7,33],autom:[0,7],automat:[4,13,14,20,22,23,24,31,33,34,38],auxiliari:10,avail:[4,33],avoid:26,axes:4,axi:[2,3,4,5,7,8,10,15,19,22,34],axis_edit:[4,34],b_d:4,b_filter:34,b_name:31,back:[4,5,37],badli:[4,34],band:[4,7,18,34],band_numer:34,bank:3,bank_chain:3,bar:34,base:[4,5,7,8,9,10,18,20,22,31,34],base_al:10,base_text:15,based_on:[4,34],baselin:9,basi:26,basic:[20,22,25,27,34],basketbal:24,batch1:[12,13,28,31],batch2:[12,13,28,31],batch3:31,batch4:31,batch5:31,batch6:31,batch:[0,4,7,15,28,31,33,34],batch_nam:[4,7],batchnam:[11,13],bchain:3,becaus:[24,26,34],becom:[4,10,26,34],been:[4,7,10,13,21,24,26,34,38],beer:37,befor:[4,7,10,13,14,24,26,31,34],begin:[4,26],behaviour:[5,8,22,26,34,38],being:[4,24,38],belong:[4,11,12,13,31,33,34,37],below:[4,10,13,26,34],benefici:21,benefit:26,better:28,between:[4,10,13,31,33,34],bia:10,big:21,binari:34,bird:19,birgir:0,birth_dai:22,birth_month:22,birth_year:22,bivari:5,blacklist:[4,34],blank:36,blueprint:34,board:[19,24,38],bool:[4,5,7,9,10,22,37],border:4,both:[4,7,12,13,19,20,21,23,24,26,28,33,34,38],bottom3:7,bottom:34,bound:34,bracket:[7,34],brand:37,break_bi:[13,33],breakfast:22,brief:34,broader:19,buchhamm:0,bug:34,bugfix:34,build:[0,3,4,5,10,15,18,19,34],built:[14,31],bunch:34,by_nam:[4,34],by_typ:[4,21,22,34],bytestr:2,cach:[4,7],calc:[5,7,8,10,31,34],calc_onli:[5,31],calcul:[4,5,7,10,14,27,33,34],call:[4,7,21,22,24,28,34,38],came:34,can:[2,4,5,7,10,11,12,13,14,15,19,20,21,22,23,24,25,26,28,31,33,34,36,37,38],cannot:[26,34],cap:6,carefulli:4,carri:5,case1:37,case2:37,case3:37,casedata:[4,20],cast:34,cat:[4,19,23,33,34,36,38],cat_nam:[7,34],categor:[4,5,7,18,22,23,27,34,35],categori:[4,5,7,19,22,23,33,34,36],categorized_nam:[4,34],caught:34,caus:[33,34],caution:4,cave:[19,24,38],cbase:[7,31,34],cbase_gross:34,cell:[5,10,11,26,34],cell_item:14,cellitem:34,central:5,certain:[4,22,34],chain:[0,1,3,16,22,34],chainmanag:33,chainnam:2,chang:[4,6,7,10,18,21,24,34],charact:[4,23,25],characterist:[19,24],chart:[0,34],check:[4,5,7,10,22,26,33,34],check_dup:34,checking_clust:7,choic:0,choos:5,clariti:25,classmethod:4,clean:[0,4,7,21,24,34],clean_text:[23,34],clean_up:[4,34],clear:34,clear_factor:4,client:34,clone:[4,18],close:12,cluster:[0,1,2,7,13,14,15,34],code:[4,5,6,7,8,10,18,19,22,23,24,31,33,34,36,38],code_count:[4,22,25,34],code_from_label:[4,34],code_map:4,codes_from_nam:[4,34],codes_in_data:[4,22,34],cola:37,collect:[4,5,7,11,13,14,19,21,22,24,27,31,34],collect_cod:[7,34],colour:34,coltest:[5,7,9],column:[2,4,5,6,7,8,10,18,20,22,23,24,26,31,33,34,37,38],combin:[4,5,7,16,22,25,26,28,31,34],combind:37,come:34,comma:25,common:[8,19,24,34],commun:7,compabl:4,compar:[4,5,10,33,34],comparison:10,compat:[4,7,20,34,35],compatibilti:38,complet:[4,10,34],complex:[4,5,6,18,19,21,22,26,31,34],compli:[4,26],complic:18,compon:[4,5,7,8,11,15,18,21,22,23,24,34],compos:7,compound:3,comprehens:26,compress:7,comput:[0,4,5,7,9,10,27,28,31,34],concat:[2,22,34],concaten:[2,26],concern:31,cond_map:4,condit:[4,8,10,18,21,22,25,33,34],confirm:7,conflict:34,conjunct:34,connect:[4,7,12,13,34,38],consequ:[28,36],consid:[4,5,7,10,24,34],consist:[4,10,11,19,21,23,24,34],constitut:13,constrcut:7,construct:[4,11,13,14,19,21,23,28,31,34,38],contain:[0,2,3,4,7,8,9,10,11,13,14,19,21,22,23,24,28,31,34,37],content:[21,28],context:[19,23],contrast:[19,24],contributor:0,control:[4,5,7,8,10,23,24,26,34],convcrit:6,convent:[4,10,34,38],convers:[4,18,33,34],convert:[0,4,10,20,24,33,34,38],coordin:9,cope:28,copi:[2,4,9,12,18,21,23,26,34,38],copy_array_data:4,copy_batch:12,copy_d:21,copy_data:[4,24],copy_from:[4,23,34],copy_not:[4,34],copy_of_batch1:12,copy_onli:[4,34],copy_to:[4,23,34],core:[5,20,22,25,34,36],correct:[10,23,34],correctli:34,correspond:[4,5,10,22,23,24,34,36,38],correspons:34,corrupt:34,could:[23,24,26,34],count:[4,5,7,8,10,31,33,34,37],count_not:[4,22,34],count_onli:[4,22,34],counterpart:34,counts_cumsum:[31,34],counts_sum:31,cpickl:2,crash:34,creat:[2,3,4,6,7,10,11,13,14,15,16,18,20,22,24,28,31,33,34,35],create_set:[4,34],creation:[10,18,23,34],cross:[13,28,31,34],crossbreak:28,crosstab:[4,24],crunch:34,csv:[0,4,7,11,18],cum_sum:10,cumul:[7,8,10,27,34],cumulative_sum:[7,31],current:[0,2,4,7,24,34],custom:[4,7,16,18,20,24,34],custom_text:[7,31],customis:34,customiz:0,cut:[4,21],cut_item_text:4,cwi_filt:10,cycl:[4,9],dai:[22,26],danish:19,data:[2,4,5,6,7,8,10,11,14,15,20,21,23,24,28,31,33,34,35,37],data_df:[4,34],data_kei:[4,7,14,28,34],datafil:[4,34],datafram:[3,4,6,7,8,10,18,19,21,22,23,28,31,33,34],datakei:34,dataset:[0,1,7,11,12,13,18,20,22,24,28,31,33,34,35,36],dataset_left:4,dataset_right:4,datasmoothi:0,datast:33,date:[4,7,19,20,21,22,23,24,34],dates_as_str:20,ddf:[0,4,34],deafult:[5,10],deal:20,decim:4,deciph:[0,18],deck:0,decod:[7,33],decode_str:7,decor:34,deep:4,deepcopi:34,defin:[2,3,4,7,10,13,14,19,21,23,28,31,33,34,36],definit:[2,4,5,7,10,14,19,24,26,27,28,34],definiton:[9,19,34],defint:[0,2,4,5,6,7,10,14,19,34],defintit:[21,38],defintiton:23,del:34,deleg:26,delet:[4,7,34],delimied_set:22,delimit:[4,7,19,20,21,22,23,24,25,26,33,34,36],delimited_set:[22,24,34],demograph:21,depend:[5,13,14,33,34],deprec:[7,34],deriv:[4,10,18,21,34,36],derivc:9,derive_categor:34,derot:[4,34,35],desc:[4,33],descend:4,describ:[0,2,3,4,7,14,19,21,28,31,34],descript:[4,5,7,9,10,19,27],descrp:4,design:[4,20],desir:[4,6,22,34,36],detail:[8,18,19],detect:[4,6,33],determin:[4,5,7],detractor:31,deutsch:[19,23],dff:20,diagram:28,dicat:24,dice:18,dichot:20,dichotom:[4,19,20,34],dict:[2,3,4,5,6,7,8,9,10,19,23,24,26,31,34,37],dictat:21,dictionari:[4,6,7,8,9,34],differ:[4,5,7,8,10,13,19,20,23,24,28,31,33,34,35,37],digest:19,dim:[5,10,31],dim_comp:34,dimens:[0,4,5,10,18,34,35],dimension:[4,34],dimensionizing_mapp:4,dimensions_comp:[4,20,34,38],dimlabel:34,dinner:22,direct:26,directli:[2,4,22,34],discret:[7,13],disk:[4,21,34],dispers:5,distinct:[19,31],distribut:[5,10],div:[7,34],dive:[19,24,38],divid:10,dk_filter:4,dms:4,dmsrun:4,doc:[22,34],docstr:6,document:[0,4,7,19,20,23,34],doe:[4,11,23,26,34],doesn:[4,25,26],dog:19,don:[19,22,24,36],done:[4,13,14],doubl:22,down:38,downbreak:[28,31,34],download:38,draft:34,draw:[21,24],drawn:[4,34],drink:37,drink_1:37,drink_2:37,drink_level:37,driven:0,drop:[4,5,7,10,21,34],drop_cod:[7,34],drop_delimit:4,drop_dupl:4,drope:[4,37],dropna:[4,6,34,37],dropx:4,dto:38,dtype:[20,22,26,34],due:34,dump:20,dupe:33,duplic:[4,23,33,34],durat:22,dure:[4,7,10,24],each:[2,4,5,6,7,13,14,19,23,24,28,31,33,34,37,38],eagleston:0,eas:34,easi:[0,19,22,23,34],easier:[12,22,28,34],easiest:22,easili:[4,12,20,31,34],ebas:[7,34],echo:4,ect:34,edit:[0,4,8,10,13,14,15,18,19,21,24,26,34],edit_param:8,eff:10,effect:[6,10,26,34],effici:34,ein:[19,23],either:[4,5,10,13,19,21,22,23,26,34],element:[4,7,10,19,34,38],eleph:4,els:26,emploi:19,empti:[4,7,22,24,26,33,34],empty_item:[4,34],en_u:7,enabl:[23,34],encod:[4,33,34],encount:20,end:[2,4,7,11,12,33,34],end_tim:22,enforc:34,eng:34,engin:[1,27,33],english:[19,34],enhanc:34,enough:4,enrich:34,ensur:[4,11,34],enter:[4,14],entir:[4,10,20,34],entri:[4,6,7,10,19,26,34],enumer:[4,7,23,24,26,33,36],environ:4,eponym:34,eqaul:4,equal:[4,10,34],equip:31,equival:[4,38],eras:[4,7],error:[4,10,33,34],escap:4,especi:[22,26,31],estim:10,etc:[4,19,21,28,31,34],ethnic:[13,22,28,31],even:[4,31,34],ever:20,everi:[22,23,26],everyon:26,everyth:26,evid:31,exact:[4,34],exactli:[4,24,25],exampl:[2,4,5,7,11,18,19,20,22,24,25,28,31,34,37,38],excel:[0,3,4,5,34],except:[4,21,34],exchang:[10,23],exclud:[4,5,7,8,10,31,34],exclus:[4,25,34],execut:4,exercis:[22,24],exist:[4,7,10,12,13,18,21,23,24,26,31,33,34],expand:[4,7,8,10,31,33],expect:24,experiment:4,explain:14,explicit:26,explicitli:[4,7,34,36],explor:19,expos:23,express:[4,5,6,7,10,22,25,34],ext_item:[4,34],ext_valu:4,ext_xk:34,ext_yk:34,extend:[4,5,7,13,18,22,31,34],extend_cod:[7,34],extend_filt:14,extend_i:[13,34],extend_item:[4,34],extend_valid_tk:34,extend_valu:[4,23,34,36],extend_x:[33,34],extens:[3,4,7,19,20,34],extra:34,extract:14,extrapol:25,factor:[4,6,7,34],factor_label:[7,34],factormap:4,fail:[4,34],failur:20,fall:[4,5,10],fallback:8,fals:[4,5,7,10,13,20,22,23,24,26,31,34],fast_stack_filt:34,favour:10,featur:[19,34],feed:[4,34],feedback:4,femal:[4,22],few:[11,21,22,34,37],figur:10,file:[2,3,4,5,7,11,20,21,22,28,34,38],file_nam:20,filenam:[2,7],fill:[4,18,34],fillna:[4,18],filter1:34,filter2:34,filter:[4,6,7,10,11,15,18,28,31,33,34],filter_1:34,filter_2:34,filter_def:6,filter_kei:[7,14],filter_nam:34,find:[4,11,22,28,34],find_duplicate_text:4,finish:[4,21,34],finnish:19,first:[4,5,10,13,19,21,26,31,33,34],fit:[19,23,24],fix:[4,15,33,34],flag:[4,5,34],flag_bas:10,flat:4,flatten:[4,24,34],flexibl:[6,7,24],float64:20,folder:20,follow:[4,8,10,11,14,15,19,20,21,22,23,24,26,28,31,34,37,38],folow:26,footbal:24,forc:[26,34],force_text:[4,23,34],forcefulli:4,form:[3,4,7,10,14,20,23,24,25,26,28,34],format:[0,4,6,10,19,20,23,26,31,34,37],former:[4,7,22,23,24,34],fortnight:22,found:[2,3,4,7,10,20,22,24,26,31,33,34],four:[28,31],frang:[4,25,26,34,37],freez:7,freeze_master_meta:7,french:19,frequenc:[4,5,8,9,10,28,31,34],freysson:0,from:[0,2,3,4,5,7,10,12,14,15,18,19,21,24,25,26,28,31,33,34,37],from_batch:[4,34],from_compon:[4,20,34],from_dichotom:[4,34],from_excel:[4,34],from_sav:7,from_set:[4,20,34],from_stack:[4,34],front:34,fulfil:4,full:[3,4,5,7,21,23,25,34,38],fullnam:31,fully_hidden_arrai:4,fun:34,further:21,futur:[7,34],geir:0,gender:[4,13,14,15,22,24,26,28,31,34,37],gener:[2,4,5,7,8,9,11,20,22,23,26,31,34],generate_report:34,german:[19,23],get:[4,7,8,11,12,13,14,22,28,31,34,36],get_batch:[4,12,13,28,31,33],get_edit_param:8,get_properti:4,get_qp_dataset:34,get_s:10,get_sig:10,get_statist:10,get_std_param:8,getter:34,give:[13,26,34],given:[4,5,6,7,10,20,26,34],global:[4,8,10,14,15,21,34],goe:4,going:36,grab:33,greater:4,grid:[4,34],griffith:0,group:[4,5,6,7,8,10,19,21,22,24,25,28,31,33,34],group_nam:6,group_target:6,grouped_ag:24,grp:10,grp_text_map:31,guid:34,gzip:7,hack:4,had:26,hand:24,handl:[0,6,7,9,10,20,31,34,36,38],handler:34,happen:[4,24],happend:4,has:[2,4,7,12,15,19,21,25,26,31,33,34,37],has_al:[4,5,18],has_ani:[4,18],has_count:18,has_other_sourc:8,have:[4,7,10,13,20,23,24,25,26,28,33,34,37],head:[20,22,23,24,26,34,38],heirarch:4,hell:4,hello:20,help:[26,28,31],helper:[4,31,34],here:[4,7,26,28,33,34,38],hidden:[4,33,34],hide:[4,15,33,34],hide_empti:34,hide_empty_item:[4,34],hide_on_i:4,hide_valu:[4,34],high:[5,10],higher:10,hmerg:[4,33,34],hockei:24,hold:[2,4,7,10,34],horizont:[4,18],household:20,how:[3,4,7,14,19,22,24,28,31,36,38],howev:[23,24,26,36,38],hrafn:0,html:[4,23,34],hub:34,ident:[4,20,24,34],identif:4,identifi:[4,5,23,34,37],ids:4,ignor:[4,7,10,22,24,34],ignore_arrai:4,ignore_cod:4,ignore_flag:10,ignore_item:[4,24,34],ignore_valu:[4,24],ill:23,implement:[7,10,19,22,34],impli:4,implicitli:10,impract:28,impute_method:6,incl:[7,34],includ:[2,3,4,5,7,10,13,25,26,28,31,33,34,37],inclus:[24,34],incom:[4,10,24],inconsist:[4,15,23,33,34],incorrect:34,incorrectli:34,independ:[4,10],index:[0,2,4,7,10,34],indic:[4,5,7,10,23,24,26,34],individu:[3,4,34],industri:20,infer:[7,20,24,34],info:[4,18,19],inform:[0,4,8,9,13,14,15,19,20,23,26,31,34,36,37],inherit:[11,34],inhomogen:10,init:26,initi:[4,18,34,37],inject:[4,26],innermost:8,inplac:[4,7,10,18,21,26,34],input:[4,6,7,10,11,20,34],insert:[4,13,34],insid:[2,4,9,10,19,20,22,23,34],inspect:[4,18,34],instal:[4,34],instanc:[2,3,4,7,9,10,11,14,20,21,22,23,24,28,31,34],instead:[4,7,10,20,25,26,34],instruct:[5,10,19,26,31,34],int64:[20,22],integ:10,integr:22,intend:7,inter:[4,6],interact:[2,3,4,21,22,34],interfac:0,interim:34,interlock:[4,18,34],intern:[2,34],interpret:[4,25],intersect:[4,18,22,34],intro:21,introduc:10,involv:26,iolocal:[7,20],ioutf8:7,ipython:[4,21,34],is_arrai:[31,34],is_bas:8,is_block:31,is_count:8,is_cumul:8,is_dat:34,is_delimited_set:34,is_float:34,is_g:[4,25,34],is_int:34,is_like_numer:[4,22,24,34],is_meanstest:8,is_multi:31,is_nan:[4,22,25],is_nest:31,is_net:8,is_pct:8,is_propstest:8,is_singl:34,is_stat:8,is_str:34,is_sum:8,is_weight:[8,31],isol:34,issu:[20,33,34],ist:[19,23],item:[4,10,11,13,19,20,21,22,23,24,31,34,36,37,38],item_nam:[4,34],item_no:[4,34],item_text:[4,22,34],iter:[9,22,34],its:[2,4,5,7,8,10,11,12,13,14,15,19,20,22,24,25,26,31,34,37,38],itself:[4,10],jame:0,jjda:20,jog:24,join:[4,22],json:[4,7,11,18,34],jupyt:[4,21,34],just:34,keep:[4,9,10,21,23,24,34,37],keep_bas:10,keep_cod:[10,34],keep_origin:4,keep_variable_text:[4,34],kei:[2,4,5,7,8,11,14,19,23,24,26,31,34,37],kept:[4,10,11,34],kerstin:0,keyword:[5,9,34],kind:[22,24,28,34],kite:[19,24,38],know:[14,19,22,24,36,38],kritik:31,kwarg:[4,5,8,9,34],lab:7,label:[4,5,7,14,19,20,22,23,24,26,34,36,37,38],lack:0,lang:19,languag:[11,18,23,34],larg:[14,21,28,31,34],last:4,lastli:34,later:[4,13,20,34],latest:[0,32,34],latter:[22,34],lead:[24,31,34],least:[4,22,23],leav:[23,24],left:[4,10,33,34],left_id:4,left_on:[4,34],legaci:4,lemonad:37,length:[4,34],less:[22,33,37],let:[23,24,28],level:[4,5,7,10,14,19,26,31,34,37],lib:[4,19,34,38],librari:[0,19,34],lift:24,like:[0,4,5,7,13,14,19,21,22,24,26,28,31,34,37,38],limit:[4,10,24,26,34],link:[2,4,5,7,8,9,10,11,14,27,31,34],list:[2,4,5,6,7,9,10,13,18,19,21,22,23,24,26,33,34,36,37],list_vari:34,listen:26,load:[2,3,4,7,11,34],load_cach:7,loc:31,local:[7,13,22,28,31],locat:[2,4,7,34],logic1:34,logic2:34,logic:[4,5,8,10,18,22,24,26,34],logic_a:[25,26],logic_b:[25,26],logic_c:[25,26],london:4,longer:34,look:[4,13,24,26,34,37,38],loop:[34,37],lose:[13,24,37],lot:[4,21,22,26],low:[4,5,10,33],lower:[4,10,33,34],lower_q:[10,33],lunch:22,machin:[4,20,34],made:2,mai:[4,25,26],main:[4,6,10,13,14,19,24,31,34],main_filt:34,mainli:3,major:10,mak:34,make:[4,5,22,24,28,34],make_summari:[13,34],make_templ:9,male:[22,26],manag:[0,18,26],mani:[13,28],manifest:4,manipul:[10,13,15],manual:[4,5,34,36],map:[4,5,6,7,9,10,18,20,23,34,36],mapper:[4,18,25,34,37],mapper_to_meta:4,margin:[5,10],mark:10,market:[0,20],mask:[4,18,21,22,23,34,36,37,38],mass:5,massiv:26,master:34,master_meta:7,match:[4,6,7,20,24,34,38],matric:10,matrix:10,matrixcach:7,matter:[11,33],max:[7,10,31,33,34],max_iter:6,mdd:[0,4,20,34],mdm_lang:34,mean:[4,5,6,7,8,10,13,15,20,22,24,25,26,31,33,34,37],measur:[5,10],median:[6,7,10,31,33,34],membership:[22,34],memori:[21,34],memoryerror:34,men:[4,14,15,28,31],mention:[12,23],merg:[3,4,18,33,34],merge_exist:[4,33],merge_text:[4,34],messag:34,meta:[4,5,7,8,11,12,14,15,18,20,21,22,24,26,31,33,34,36,37,38],meta_dict:[4,34],meta_edit:[4,7,15],meta_to_json:[4,34],metadata:[0,4,7,18,19,20,24,26,34,36,38],metaobject:34,method:[2,3,4,5,6,7,8,9,10,11,12,13,14,18,20,21,22,23,24,31,33,34,36,37,38],metric:[5,7,10],mid:[5,10,22,34],middl:34,might:[7,21,23,24,34],mimic:[5,10],mimick:[5,10,22],min:[4,7,10,31,33,34],min_value_count:[4,33],minimum:5,minor:34,mismatch:34,miss:[4,6,8,14,20,22,23,24,33,36,38],missing_map:[4,34],mix:[4,24],mode:[6,7,20,34,35],modifi:[4,7,10,15,24,34],modu:34,modul:[0,4,7,33],month:22,more:[2,4,22,25,26,31,33,34],morn:22,most:[10,21,22,26,33,34],mous:4,move:[0,4,21,34],mrs:4,mrset:4,mrset_tag_styl:4,much:[28,37],mul:7,multi:[5,10,19],multiindex:10,multipl:[0,3,4,5,19,22,23,25,26,34],multipli:10,multivari:10,must:[4,6,7,20,21,23,26,31,34,37],name:[2,3,4,5,6,7,8,9,10,12,13,19,20,21,22,23,24,26,28,31,33,34,36,37,38],name_data:[34,38],nan:[4,10,20,22,23,24,26,28,31,34,38],nate:4,nativ:[0,4,18,34],natur:[10,21,22],necessari:[10,21,34,37],need:[4,7,9,10,21,23,24,34,38],neg:34,nest:[7,8,19,25,26],net:[5,7,8,10,18,27,33,34],net_1:[7,31,33],net_2:[7,31,33],net_3:7,net_def:33,net_map:[7,31],net_view:34,never:[22,23],new_arrai:23,new_array_1:23,new_array_2:23,new_array_3:23,new_array_4:23,new_array_97:23,new_array_98:23,new_chain:34,new_cod:10,new_column:4,new_d:34,new_data:7,new_data_kei:7,new_dataset:4,new_int:23,new_meta:7,new_nam:[4,23,24,34],new_ord:[4,21,34],new_rul:34,new_set:[4,34],new_singl:23,new_stack:2,new_text:[4,23],new_var:34,new_weight:7,newli:34,next:[4,7,11,19,31,34,38],no_data:24,no_filt:[4,7,28,31,34],non:[4,7,22,25,27,34],none:[2,3,4,5,6,7,8,9,10,13,20,21,22,23,24,26,28,33,34,36,38],none_band:34,nonea:4,normal:[4,5,7,10,33,34],norwegian:19,not_al:18,not_ani:[4,10,18,34],not_count:18,notat:[5,7,8,10],note:[2,4,5,26,31],notebook:[4,21,34],notimplementederror:[15,34],now:[13,14,21,31,34,37],num:5,number:[4,6,10,20,22,23,24,33,34],numer:[4,5,7,18,19,23,24,31,34,36],numpi:[0,10,34],obei:22,object:[2,3,4,5,7,10,18,20,21,24,26,28,31,34,36],obscur:26,observ:0,obvious:31,occur:26,oe_q8:13,oe_q9:13,offer:[0,4,19,22,24,34,36,38],often:[21,22,24],old:[4,5,7,34],old_cod:10,old_nam:34,older:34,omit:26,omnibu:34,on_var:[7,31],onc:22,one:[2,4,5,12,13,19,21,22,23,24,26,28,31,33,34],ones:[4,10,15,21,22,34],onli:[4,7,9,10,11,13,14,21,23,24,26,28,31,33,34,36,37],only_men:24,only_typ:[4,7],onto:26,oom:34,open:[0,11,12,34],oper:[4,5,20,22,24,25,26,34],operat:18,opportun:20,oppos:21,opt:4,option:[4,5,6,7,10,13,14,19,22,23,31,34],order:[2,4,11,18,19,24,34],ordereddict:[3,4,7,13,28,31],organ:16,orgin:10,orient:[2,34],origi:4,origin:[4,7,10,21,24,34],other:[4,5,7,10,11,12,13,19,23,24,25,26,33,34,37],other_sourc:[7,31,34],otherwis:[4,34],our:[0,22,26],out:[5,12,14,24,31,34],outcom:4,outdat:34,output:[4,7,10,13,22,34],outsid:34,over:[4,7,9,10,34],overcod:[4,7,31],overlap:10,overview:[4,7,22,28,34],overwrit:[4,15,21,26,34],overwrite_margin:10,overwrite_text:4,overwritten:[4,7,34],ovlp_correc:10,own:[13,34],pack:4,packag:5,paint:[3,34],painter:34,pair:[4,5,10,18,23,26,34,36],panda:[0,3,4,6,7,10,19,20,22,26,34],pane:4,parachut:[19,24,38],parallel:7,paramet:[3,4,5,6,7,8,9,10,13,21,22,23,24,26,31,33,34,37],parent:[4,19,20,34],pars:5,part:[4,8,19,21,22,26,34],parti:18,particip:20,particular:4,pass:[4,5,7,10,21,22,24,34],past:26,path:[2,3,4,7,20,34],path_clust:3,path_csv:20,path_data:[4,38],path_ddf:[4,20,34],path_json:20,path_mdd:[4,20,34],path_meta:4,path_report:4,path_sav:[4,20],path_sav_analysi:20,path_stack:7,path_txt:20,path_xlsx:[4,34],path_xml:20,pct:4,peopl:20,per:[4,5,6,7,10,12,20,22,23,24,26,34,38],percentag:[7,8,10,31,34],perform:[4,5,7,8,10,21,26,31,33,34],perman:21,physic:34,pick:[4,24],pickl:2,pilat:24,pivot:7,place:[10,26,34],plai:22,plain:[0,8,20],plan:[11,13,14,19,24,28,31],pleas:[7,21,22,34],point:19,pointer:19,pool:10,popul:[4,11,13,14,27,31,34],portion:7,posit:[4,10,21,22,23,28,34],possibl:[3,4,5,7,12,13,19,22,23,25,31,33,34,37],power:0,powerpoint:[5,34],powerpointpaint:34,pptx:34,pre:[4,26,31],precis:[26,34],prefer:22,prefix:[4,7],prep:25,prepar:[3,21,23,31,34],present:[4,10,34],preset:[4,7],pretti:[4,26],prevent:[4,15,21,23,24,33,34],previou:[21,34],previous:[4,34],primarili:4,print:[13,22,28,31,34],prior:[4,24],prioriti:34,probabl:[19,24,34],problem:[33,34],process:[0,4,7,9,20,21,22],produc:[5,10,13,24],product:[34,37],profession:[4,34],progress:[4,34],prohibit:23,project:0,promot:31,promotor:31,prop:[5,31],prop_nam:4,prop_valu:4,proper:[34,38],properli:38,properti:[4,10,11,20,34],proport:[5,6,8],protect:4,provid:[3,4,5,7,8,9,10,19,20,21,22,23,24,26,31,34,36],proxi:7,purpos:19,put:7,python:[4,33],q01_1:4,q01_3:4,q11:34,q11_grid:34,q12:37,q12_10:37,q12_11:37,q12_12:37,q12_13:37,q12_1:37,q12_2:37,q12_3:37,q12_4:37,q12_5:37,q12_6:37,q12_7:37,q12_8:37,q12_9:37,q12_:37,q12a:37,q12a_10:37,q12a_11:37,q12a_12:37,q12a_13:37,q12a_1:37,q12a_2:37,q12a_3:37,q12a_4:37,q12a_5:37,q12a_6:37,q12a_7:37,q12a_8:37,q12a_9:37,q12a_grid:37,q12b:37,q12b_10:37,q12b_11:37,q12b_12:37,q12b_13:37,q12b_1:37,q12b_2:37,q12b_3:37,q12b_4:37,q12b_5:37,q12b_6:37,q12b_7:37,q12b_8:37,q12b_9:37,q12b_grid:37,q12c:37,q12c_10:37,q12c_11:37,q12c_12:37,q12c_13:37,q12c_1:37,q12c_2:37,q12c_3:37,q12c_4:37,q12c_5:37,q12c_6:37,q12c_7:37,q12c_8:37,q12c_9:37,q12c_grid:37,q12d:37,q12d_10:37,q12d_11:37,q12d_12:37,q12d_13:37,q12d_1:37,q12d_2:37,q12d_3:37,q12d_4:37,q12d_5:37,q12d_6:37,q12d_7:37,q12d_8:37,q12d_9:37,q12d_grid:37,q14_1:4,q14_1_1:4,q14_1_2:4,q14_1_3:4,q14_2:4,q14_2_1:4,q14_2_2:4,q14_2_3:4,q14_3:4,q14_3_1:4,q14_3_2:4,q14_3_3:4,q1_1:[4,25,26,37],q1_2:[4,26,37],q1_3:[4,26],q1_rec:4,q2_count:22,q2array_tran:4,q2b:[13,22,28,31],q3_no_data:24,q3_only_men:24,q3_rec:24,q3_version2:24,q4a:34,q4a_1:34,q4a_2:34,q4a_3:34,q4a_grid:34,q5_1:[19,21,22,24,34,38],q5_2:[19,21,22,24,34,38],q5_3:[19,21,22,24,34,38],q5_4:[19,21,22,24,34,38],q5_5:[19,21,22,24,34,38],q5_6:[19,21,22,24,34,38],q5_grid:38,q5_tran:24,q5_trans_1:24,q5_trans_2:24,q5_trans_3:24,q5_trans_4:24,q5_trans_5:24,q5_trans_97:24,q5_trans_98:24,q6_1:[13,21,22,28,31],q6_2:[13,21,22,28,31],q6_3:[13,21,22,28,31],q6_calc:31,q6_grid:38,q6_net:31,q6copi:38,q6new:38,q6new_grid:38,q6new_q6copi:38,q6new_q6copy_grid:38,q6new_q6copy_tran:38,q6new_q6copy_trans_grid:38,q7_1:[21,22,34],q7_2:[21,22,34],q7_3:[21,22,34],q7_4:[21,22,34],q7_5:[21,22,34],q7_6:[21,22,34],q7_grid:38,q8_with_a_new_nam:23,q8a:[13,22],q9a:[13,22],q_group:37,q_label:[4,34],qtp:37,qtype:[4,23,33,36,38],qualifi:[4,5,10],quantifi:1,quantipi:[2,3,4,5,6,7,8,9,10,11,19,20,22,25,31,34,36,38],quantipyview:[1,7,34],quantiti:[10,34],queri:[2,4,6,7,18,19,24,34,38],question:[4,10,19,24,26,31,34,37],questionnair:21,quick:[4,22,34],quickli:[6,21,22,24,34],radio:26,radio_st:26,radio_stations_cb:26,radio_stations_xb:26,rais:[4,15,21,31,33,34],rake:34,rang:[4,5,18,21,34],rate:[34,37],raw:[5,10],raw_sum:10,rbase:7,read:[0,4,20,34],read_ascrib:[4,20],read_deciph:20,read_dimens:[4,20],read_quantipi:[4,11,20,34,38],read_spss:[4,20],rebas:10,rebuild:24,rec:[4,34],receiv:37,recod:[0,4,7,18,34],recode_from_net_def:7,recode_seri:4,recoded_filt:34,recommend:24,record_numb:[13,22],reduc:[4,7,10,21,34],reduced_d:21,reduct:4,refactor:34,refer:[4,7,10,19,23,26,28,31,34],referenc:[7,13,19,26,34],reflect:[4,10,21,34],refresh:7,refus:[19,24],regard:[4,34],region:[4,34],regist:[4,22,34],regroup:[4,34],regular:[4,19,31,34],regularli:[22,23,24],reindex:4,reintroduc:34,rel:21,rel_to:8,relat:[2,8,23,26,34],relation_str:8,relationship:7,relev:[23,34],religion:22,reload:[21,34],remain:[4,5,21,26,34],rememb:36,remind:36,remov:[4,5,7,10,12,13,18,34],remove_data:7,remove_filt:34,remove_html:[4,34],remove_item:4,remove_valu:[4,33],renam:[4,18,24,33,34,38],rename_from_mapp:4,renamed_item:4,renamed_v:4,reorder:[18,34],reorder_item:[4,34],reorder_valu:4,reorgan:0,repair:[4,33,34],repair_text_edit:[4,34],repeat:[21,28],repetit:26,replac:[4,10,13,23,26,31,34],replace_i:[13,34],replace_text:[4,34],report:[0,4,5,6,34],reposit:[4,21,34],repres:[4,26],represent:[7,8,10,19,24,34],request:[5,7,13,21,23,26,31,34],request_view:34,requir:[4,21,23,34,38],rescal:[5,7,8,10,31],research:[0,20],reset:[4,34],reset_index:4,resid:34,resolv:34,resolve_nam:[4,34],resp:34,respect:[4,10,24,34,36],respond:[10,21,37],respons:[19,22,25,26,34,37],responsess:34,restor:[4,7,21,34],restore_item_text:4,restore_meta:7,restrict:[4,5,7,10,19,21,22,34],result:[3,4,5,7,9,10,16,20,22,23,24,26,28,34],result_onli:10,retain:9,retriev:10,revers:[24,25],revert:[4,21,34],rewrit:33,right:[4,33,34],right_id:4,right_on:[4,34],rim:[1,4,34],roll:4,roll_up:4,rollback:[18,34],rolled_up:4,round:6,row:[4,5,10,18,20,22,34,38],row_id:4,row_id_nam:4,rule:[4,33,34,38],run:[4,7,10,15,24,28,31,34],safe:[4,23],safeguard:4,sai:26,same:[3,4,7,13,19,20,22,26,28,33,34,37,38],sampl:[5,8,10,33,34],sample_s:14,sandbox:34,satisfi:34,sav:[4,7,20],save:[2,3,4,7,21,28,34],savepoint:18,scalar:34,scale:[5,6,10,19,34,37],scan:4,scenario:38,scheme:[4,6,19,34],scratch:[18,34],script:4,search:4,second:[4,5,10,15,31],sect:4,section:[8,10,11,14,21,26],see:[13,21,24,26,28,31,34],seen:[26,38],segemen:26,segment:18,select:[4,7,9,13,14,21,22,31,34,37],select_text_kei:4,self:[2,4,7,10,26,28,34],sem:[7,10,33],semi:34,sensit:[4,33,34],separ:[4,26,36],septemb:[],sequenc:4,seri:[4,19,22,26,34],serial:2,session:[21,34],set:[3,4,5,6,7,9,10,11,12,13,18,19,20,22,23,24,26,28,33,34,36],set_cell_item:14,set_col_text_edit:34,set_column_text:34,set_dim_suffix:34,set_encod:4,set_factor:4,set_item_text:[4,23,34],set_languag:14,set_mask_text:34,set_miss:[4,34],set_opt:34,set_param:10,set_properti:[4,15],set_sigtest:[14,31,34],set_target:6,set_text_kei:4,set_unwgt_count:34,set_val_text_text:34,set_value_text:[4,15,23,34],set_variable_text:[4,15,23,34],set_verbose_errmsg:4,set_verbose_infomsg:4,set_weight:14,setdefaultencod:4,setnam:[4,34],setup:[4,10,13,34],sever:[5,22,37],shape:[4,21,31],share:[4,19],sheet:[4,34],shop:4,short_item_text:34,shorten:[4,34],shorthand:[4,5],shortnam:[5,8],should:[3,4,7,14,21,22,26,34,37,38],show:[4,10,13,19,21,22,31,34],shown:[4,10,33,34],side:[9,34],sig:[5,7,10,14,34],siglevel:34,signific:[5,10,11,27],significancetest:34,sigproperti:34,similar:[28,37],similarli:[22,23],similiar:23,simpl:[5,6,10,19,25,34,36],simpli:[4,22,23,24,25,31,34],simplifi:[24,26],sinc:[10,26,31,38],singl:[3,4,7,19,20,21,22,23,24,26,33,34,36,38],sit:26,six:22,size:[5,8,10,21,22,31,34],skip:[22,23,31,34],skip_item:34,slice:[4,8,15,18,34],slicer:[4,18,22,24,34],slicex:4,small:[5,34],snack:22,snapshot:[4,21,34],snowboard:[19,24,38],soccer:24,social:0,softwar:[0,4,5,10,20,33],solut:34,solv:34,some:[13,14,15,22,25,26,33,34,37],someth:37,sometim:[21,28,34],soon:34,sorri:0,sort:[4,15,33,34],sort_by_weight:[4,33],sort_on:33,sortx:4,sourc:[0,4,7,19,20,22,23,34,38],source_item:4,space:[4,25],speak:19,spec:3,spec_condit:8,specfic:14,special:[0,11,14,19,28,31,34],specif:[3,4,5,7,8,10,11,13,14,15,19,21,23,34,38],specifi:[2,4,5,6,7,10,13,20,23,31,34,36],speed:34,spell:[4,34],split:[4,7,13,34],split_view_nam:7,sport:[20,22],spreadsheet:0,spss:[0,4,10,18,34],spss_limit:[4,34],squar:7,stack:[1,2,3,4,5,8,11,13,14,27,31,34],stage:[4,34],standalon:18,standard:[8,10,20,34],standardli:24,start:[4,18,23,24,26],start_meta:[4,34],start_tim:22,stat:[4,5,7,10,31,34],state:[4,15,18,24,34],statement:[4,5,19,25,26],statisfi:34,statist:[0,4,5,7,8,10,18,27,28,34],std_paramet:8,stddev:[7,10,31,33,34],ste:34,stem:34,step:[31,36],still:[26,34],store:[4,5,7,11,12,13,19,21,24,28,31,34],store_cach:7,str:[3,4,5,6,7,8,9,10,24,34,36,37],str_tag:[4,34],strict:[4,34],strict_select:9,strictli:23,string:[2,4,6,7,8,10,19,20,21,22,23,24,25,34],strip:34,structur:[0,4,6,7,9,11,13,19,20,21,24,28,34,37],studi:34,style:[4,7],sub:[7,31],subclass:[2,11],subclasss:15,sublist:34,subset:[4,9,18,22,24,34],subset_d:4,substr:[4,34],subtl:34,subtyp:[19,34,38],suffix:[4,5,24,34,38],sum:[4,5,7,8,10,27,34],summar:[4,5,10,34],summari:[4,5,6,7,8,10,13,22,31,33,34],summaris:7,summat:10,suppli:24,supporintg:7,support:[0,7,8,18,19,22,23,24,33,34,38],surf:[19,24,38],survei:21,sv_se:[31,34],swap:[7,8,10,34],swedish:[19,34],swim:24,syntax:34,sys:4,tab:20,tabl:[0,7],tabul:[5,13,28],tag:[4,23,34],take:[4,5,7,11,22,24,25,26,34,37],taken:[4,7,14,15,24,33,34],target:[4,6,18,23,33,34],target_item:4,task:22,team:22,temp:4,templat:[5,9,34],temporari:[4,34],temporarili:4,ten:26,tend:4,term:[7,23,34],termin:34,test:[2,4,5,8,10,11,22,27,34,36],test_cat_1:36,test_cat_2:36,test_cat_3:36,test_tot:[5,10,34],test_var:[34,36],testtyp:10,text1:20,text:[4,5,7,8,14,18,20,21,22,24,26,31,34,36,38],text_kei:[3,4,7,11,18,22,23,31,34],text_label:[4,34],text_prefix:7,textkei:[4,34],than:[4,22,24,33,34],thei:[4,10,13,14,20,25,26,31,33,34],them:[4,5,13,20,22,26,31,33,34],themselv:[4,10],therefor:[4,5,24,34],thi:[2,3,4,5,6,7,10,13,14,15,20,21,22,23,24,26,28,31,34,37,38],third:18,thorugh:24,those:4,three:[4,21,22,24,26,34,36],threshold:5,through:[2,3,4,9],throughout:[4,19,20,34],thu:6,time:[7,19,21,22],titl:13,tks:34,to_arrai:[4,33,34,37],to_delimited_set:[4,34],to_df:10,to_excel:7,todo:[4,5,6,7,9,10],togeth:[3,4,7,19,21],toggl:7,too:34,tool:[5,20,24,25],top2:31,top3:7,top:26,topic:[19,34],total:[4,5,6,10,13,34],toward:34,tracker:34,tradit:10,transfer:34,transform:[0,4,5,10,18,34],translat:23,transpos:[4,13,24,31,38],transpose_arrai:13,transposit:24,treat:[4,10,25,31],tree:28,treshhold:10,trigger:4,tstat:10,tupl:[4,8,23,24,34,36],turn:19,two:[4,5,10,13,19,21,23,28,31,33,34],txt:[4,20],type:[0,3,4,5,6,7,8,9,10,13,18,20,23,26,31,33,34,36,38],type_nam:7,typic:26,ultim:4,unabbrevi:25,unattend:4,unbind:4,uncod:[4,34],uncode_seri:4,uncodit:5,unconditi:10,under:[4,5,34],underli:19,understood:20,undimension:4,undimensionizing_mapp:4,undo:7,uni:[5,10],unicod:7,unifi:[4,34],uniformli:20,unify_valu:4,union:[18,26],uniqu:[4,5,7,24,28,31,34],unique_id:[4,22],unique_kei:[4,34,37],uniquify_kei:4,unkei:26,unless:4,unlik:[19,24],unpool:10,unqiu:24,unrol:[4,31,34],untouch:[23,33],unusu:34,unwant:[4,34],unweight:[7,10,31,33,34],unweighted_bas:[7,31,34],unwgt:34,upcom:[],updat:[4,8,9,10,23,33,34],update_axis_def:[10,34],update_exist:[4,34],upon:19,upper:[4,34],upper_q:[10,33],uppercas:33,usag:[23,33,34],use:[0,2,4,5,7,10,12,13,19,20,21,22,23,24,26,34,35],use_ebas:10,used:[2,3,4,5,7,8,9,10,11,14,15,20,21,24,26,31,33,34],useful:[21,22,34],user:[2,4,14,34,36],userwarn:[34,36],uses:[4,10,34],using:[0,2,3,4,6,7,19,20,21,24,25,26,28,31,33,34,38],usual:19,utf8:33,utf:7,val:4,val_text_sep:4,valid:[4,6,7,14,19,24,26,31,34,36],valid_cod:34,valid_tk:[11,34],valu:[3,4,5,6,7,8,9,10,18,20,21,24,25,26,31,33,34,35,38],value_count:[4,22,34],value_map:37,value_text:[4,22,34],valueerror:[4,21,23,34],var_exist:[22,34],var_grid:37,var_nam:[34,37],var_suffix:4,varcoeff:10,vari:22,variabl:[0,4,5,6,7,8,10,11,18,19,20,23,27,33,34,36,37,38],variable_typ:7,variables_from_set:34,varianc:10,variant:[22,34],varibal:37,varibl:34,variou:[5,14,22,28,31],varlist:[4,34],varnam:[4,34],vector:10,verbatim:[11,34],verbos:[4,7,25,31,34],veri:[19,23,24,34],versa:10,version2:24,version:[4,5,7,10,19,21,23,24,26,34],versu:31,vertic:[4,18],via:[0,4,5,7,21,22,23,24,31,34],vice:10,view:[1,2,3,4,5,7,9,10,14,16,22,27,28,33,34],view_kei:31,view_name_not:10,viewmanag:34,viewmapp:[1,7],viewmeta:8,visibl:[31,34],vmerg:[4,33,34],wai:[7,12,13,19,21,22,23,26,31,34,35],wait:21,want:[21,24,26],warn:[4,31,33,34],water:37,wave:21,weak:[4,33],weak_dup:4,week:22,weight:[0,4,6,7,8,10,11,12,22,24,31,33,34],weight_a:[14,22,31],weight_b:22,weight_column_nam:6,weight_nam:4,weight_schem:4,weigth:4,well:[4,10,20,22,25,26,31,34,38],went:34,were:[26,33,34],wgt:34,what:[16,19,20,24,26,27,34,35,38],whatev:[4,26],when:[4,5,7,10,20,21,23,24,26,34,38],where:[2,3,4,10,24,25,26],whether:[5,10],which:[4,5,7,10,11,13,14,15,22,23,24,26,28,31,33,34,37],whole:[4,34],whose:[4,7,34],wide:34,wil:4,wildcard:26,window:20,windsurf:[19,24,38],wise:[4,31],witch:34,within:[4,10,33],without:[33,34],women:15,work:[4,11,21,23,31,34],workbook:3,workspac:34,world:20,would:[4,19,24,26,34],wouldn:[19,24],wrap:34,wrapper:[4,10,33],write:[4,7,20,21,34,38],write_dimens:[4,33,34],write_quantipi:[4,21],write_spss:[4,20],writen:37,written:[21,34],wrong:34,x_filter_map:[28,31],x_kei:14,x_y_map:[13,14,28,31],xdef:10,xks:[4,7,31,34],xlsx:4,xml:[4,20],xsect:10,xtotal:4,y_filter:34,y_kei:[14,28,31],y_on_i:[13,28,31,34],year:[19,22,38],yes:20,yet:33,yield:22,yks:[4,34],yoga:24,you:[4,11,13,14,19,20,21,22,23,24,26,28,31,34,37,38],younger:24,your:[4,19,20,21,24,26,34],ysect:10},titles:["Quantipy: Python survey data toolkit","API references","Chain","Cluster","DataSet","QuantipyViews","Rim","Stack","View","ViewMapper","quantify.engine","<code class=\"docutils literal\"><span class=\"pre\">Batch</span></code>","Creating/ Loading a <code class=\"docutils literal\"><span class=\"pre\">qp.Batch</span></code> instance","Adding variables to a <code class=\"docutils literal\"><span class=\"pre\">qp.Batch</span></code> instance","Set properties of a <code class=\"docutils literal\"><span class=\"pre\">qp.Batch</span></code>","Inherited <code class=\"docutils literal\"><span class=\"pre\">qp.DataSet</span></code> methods","Builds","Combining results","Data processing","DataSet components","I/O","DataSet management","Inspecting variables","Editing metadata","Transforming variables","Logic and set operaters","Custom data recoding","Analysis & aggregation","Collecting aggregations","The computational engine","Significance testing","View aggregation","Release notes","Latest (01/10/2018)","Archived release notes","How-to-snippets","Different ways of creating categorical values","Derotation","<code class=\"docutils literal\"><span class=\"pre\">DataSet</span></code> Dimensions compatibility"],titleterms:{"boolean":25,"case":[19,21,22],"default":26,Adding:[13,26],The:[19,26,29,38],Using:20,about:37,access:38,adding:23,aggreg:[13,17,27,28,31],analysi:27,api:1,append:26,archiv:34,arrai:[13,19,24,37,38],ascrib:20,band:[24,26],base:26,basic:31,batch:[11,12,13,14],build:[16,26],calcul:31,categor:[19,24,31,36],cell:14,chain:[2,17],chang:23,clone:21,cluster:3,code:[25,26],collect:28,column:[19,21],combin:17,compat:38,complex:25,complic:26,compon:[19,20],comput:29,condit:26,convers:[20,24],copi:24,creat:[12,17,23,26,36,38],creation:26,csv:20,cumul:31,custom:[17,26],data:[0,18,19,22,26,38],datafram:20,dataset:[4,15,19,21,23,37,38],deciph:20,definit:31,deriv:26,derot:37,descript:31,detail:26,dice:22,differ:36,dimens:[20,38],document:[],edit:23,end:13,engin:[10,29],exampl:26,exist:[22,25],extend:23,featur:0,fill:26,fillna:26,filter:[14,21],from:[20,23],has_al:25,has_ani:25,has_count:25,horizont:21,how:[35,37],info:23,inherit:15,initi:26,inplac:24,inspect:22,instanc:[12,13],interlock:26,intersect:[25,26],item:14,json:20,kei:[0,13],languag:[14,19],latest:33,link:28,list:25,load:12,logic:25,manag:21,map:19,mapper:26,mask:19,merg:21,meta:[19,23],metadata:[22,23],method:[15,26],mode:38,nativ:20,net:[26,31],non:31,not_al:25,not_ani:25,not_count:25,note:[32,34],numer:26,object:[19,22,23],open:13,operat:25,order:21,organ:17,pair:20,parti:20,popul:28,process:18,properti:14,python:0,quantifi:10,quantipi:0,quantipyview:5,queri:22,rang:25,recod:26,refer:1,releas:[32,34],remov:[23,26],renam:23,reorder:23,result:17,rim:6,rollback:21,row:21,savepoint:21,scratch:23,segment:26,septemb:[],set:[14,21,25],signific:[14,30,31],slice:22,slicer:25,snippet:35,special:13,spss:20,stack:[7,28],standalon:20,start:20,state:21,statist:[20,31],subset:21,sum:31,support:20,survei:0,target:26,test:[14,30,31],text:[19,23],text_kei:19,third:20,toolkit:0,transform:24,type:[19,22,24],union:25,upcom:[],use:37,valu:[19,22,23,36],variabl:[13,21,22,24,26,31],verbatim:13,vertic:21,view:[8,17,31],viewmapp:9,wai:36,weight:14,what:[17,28,37]}}) \ No newline at end of file diff --git a/docs/API/_build/html/sites/api_ref/00overview.html b/docs/API/_build/html/sites/api_ref/00overview.html new file mode 100644 index 000000000..b74e5a520 --- /dev/null +++ b/docs/API/_build/html/sites/api_ref/00overview.html @@ -0,0 +1,439 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>API references — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../genindex.html"/> + <link rel="search" title="Search" href="../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../index.html"/> + <link rel="next" title="Chain" href="Chain.html"/> + <link rel="prev" title="Combining results" href="../lib_doc/builds/01_chains.html"/> + + + <script src="../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Latest (01/10/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="current reference internal" href="#">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="Stack.html">Stack</a></li> +<li class="toctree-l2"><a class="reference internal" href="View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../index.html">Docs</a> »</li> + + <li>API references</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../_sources/sites/api_ref/00overview.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="section" id="api-references"> +<h1>API references<a class="headerlink" href="#api-references" title="Permalink to this headline">¶</a></h1> +<div class="toctree-wrapper compound"> +<ul> +<li class="toctree-l1"><a class="reference internal" href="Chain.html">Chain</a></li> +<li class="toctree-l1"><a class="reference internal" href="Cluster.html">Cluster</a></li> +<li class="toctree-l1"><a class="reference internal" href="DataSet.html">DataSet</a></li> +<li class="toctree-l1"><a class="reference internal" href="quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l1"><a class="reference internal" href="QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l1"><a class="reference internal" href="Rim_scheme.html">Rim</a></li> +<li class="toctree-l1"><a class="reference internal" href="Stack.html">Stack</a></li> +<li class="toctree-l1"><a class="reference internal" href="View.html">View</a></li> +<li class="toctree-l1"><a class="reference internal" href="ViewMapper.html">ViewMapper</a></li> +</ul> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="Chain.html" class="btn btn-neutral float-right" title="Chain" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="../lib_doc/builds/01_chains.html" class="btn btn-neutral" title="Combining results" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../_static/jquery.js"></script> + <script type="text/javascript" src="../../_static/underscore.js"></script> + <script type="text/javascript" src="../../_static/doctools.js"></script> + <script type="text/javascript" src="../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/api_ref/Chain.html b/docs/API/_build/html/sites/api_ref/Chain.html index 9c29d5c9d..b8893065b 100644 --- a/docs/API/_build/html/sites/api_ref/Chain.html +++ b/docs/API/_build/html/sites/api_ref/Chain.html @@ -92,9 +92,18 @@ <h3>Quick search</h3> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../release_notes/00_overview.html">Release notes</a><ul> -<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Upcoming (September 2017)</a></li> -<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html#latest-31-08-2017">Latest (31/08/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Latest (01/10/2018)</a></li> <li class="toctree-l2"><a class="reference internal" href="../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> @@ -195,7 +204,7 @@ <h3>Quick search</h3> <li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> -<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> @@ -292,6 +301,7 @@ <h3>Quick search</h3> <li class="toctree-l2"><a class="reference internal" href="quantify_engine.html">quantify.engine</a></li> <li class="toctree-l2"><a class="reference internal" href="QuantipyViews.html">QuantipyViews</a></li> <li class="toctree-l2"><a class="reference internal" href="Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="Stack.html">Stack</a></li> <li class="toctree-l2"><a class="reference internal" href="View.html">View</a></li> <li class="toctree-l2"><a class="reference internal" href="ViewMapper.html">ViewMapper</a></li> </ul> @@ -381,8 +391,8 @@ <h1>Chain<a class="headerlink" href="#chain" title="Permalink to this headline"> <dl class="attribute"> <dt id="Chain.filename"> <code class="descname">filename</code><a class="headerlink" href="#Chain.filename" title="Permalink to this definition">¶</a></dt> -<dd><p><em>string</em> – Specifies the name of the file to be loaded. -Example of use: new_stack = Chain.load(”./tests/ChainName.chain”)</p> +<dd><p><em>string</em> – Specifies the name of the file to be loaded. +Example of use: new_stack = Chain.load(“./tests/ChainName.chain”)</p> </dd></dl> </dd></dl> @@ -395,8 +405,8 @@ <h1>Chain<a class="headerlink" href="#chain" title="Permalink to this headline"> <dt>Attributes :</dt> <dd><dl class="first last docutils"> <dt>path (string)</dt> -<dd>Specifies the location of the saved file, NOTE: has to end with ‘/’ -Example: ‘./tests/’</dd> +<dd>Specifies the location of the saved file, NOTE: has to end with ‘/’ +Example: ‘./tests/’</dd> </dl> </dd> </dl> @@ -457,7 +467,7 @@ <h1>Chain<a class="headerlink" href="#chain" title="Permalink to this headline"> <script type="text/javascript" src="../../_static/underscore.js"></script> <script type="text/javascript" src="../../_static/doctools.js"></script> <script type="text/javascript" src="../../_static/custom.js"></script> - <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> diff --git a/docs/API/_build/html/sites/api_ref/Cluster.html b/docs/API/_build/html/sites/api_ref/Cluster.html index b21e9acaf..c9c98c291 100644 --- a/docs/API/_build/html/sites/api_ref/Cluster.html +++ b/docs/API/_build/html/sites/api_ref/Cluster.html @@ -92,9 +92,18 @@ <h3>Quick search</h3> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../release_notes/00_overview.html">Release notes</a><ul> -<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Upcoming (September 2017)</a></li> -<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html#latest-31-08-2017">Latest (31/08/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> <li class="toctree-l2"><a class="reference internal" href="../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> @@ -195,7 +204,7 @@ <h3>Quick search</h3> <li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> -<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> @@ -372,13 +381,13 @@ <h1>Cluster<a class="headerlink" href="#cluster" title="Permalink to this headli <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>spec</strong> (<em>dict</em>) – The banked chain specification object.</li> -<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default='values'</em>) – Paint the x-axis of the banked chain using the spec provided +<li><strong>spec</strong> (<em>dict</em>) – The banked chain specification object.</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default='values'</em>) – Paint the x-axis of the banked chain using the spec provided and this text_key.</li> </ul> </td> </tr> -<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>bchain</strong> – The banked chain.</p> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>bchain</strong> – The banked chain.</p> </td> </tr> <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference internal" href="Chain.html#quantipy.Chain" title="quantipy.Chain">quantipy.Chain</a></p> @@ -396,7 +405,7 @@ <h1>Cluster<a class="headerlink" href="#cluster" title="Permalink to this headli <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>path_cluster</strong> (<em>str</em>) – The full path to the .cluster file that should be created, including +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>path_cluster</strong> (<em>str</em>) – The full path to the .cluster file that should be created, including the extension.</td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td> @@ -421,7 +430,7 @@ <h1>Cluster<a class="headerlink" href="#cluster" title="Permalink to this headli <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>path_cluster</strong> (<em>str</em>) – The full path to the .cluster file that should be created, including +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>path_cluster</strong> (<em>str</em>) – The full path to the .cluster file that should be created, including the extension.</td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td> @@ -487,7 +496,7 @@ <h1>Cluster<a class="headerlink" href="#cluster" title="Permalink to this headli <script type="text/javascript" src="../../_static/underscore.js"></script> <script type="text/javascript" src="../../_static/doctools.js"></script> <script type="text/javascript" src="../../_static/custom.js"></script> - <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> diff --git a/docs/API/_build/html/sites/api_ref/DataSet.html b/docs/API/_build/html/sites/api_ref/DataSet.html new file mode 100644 index 000000000..8b2405e70 --- /dev/null +++ b/docs/API/_build/html/sites/api_ref/DataSet.html @@ -0,0 +1,3403 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>DataSet — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../genindex.html"/> + <link rel="search" title="Search" href="../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../index.html"/> + <link rel="up" title="API references" href="00overview.html"/> + <link rel="next" title="quantify.engine" href="quantify_engine.html"/> + <link rel="prev" title="Cluster" href="Cluster.html"/> + + + <script src="../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Latest (01/10/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00overview.html">API references</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="Cluster.html">Cluster</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="Stack.html">Stack</a></li> +<li class="toctree-l2"><a class="reference internal" href="View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../index.html">Docs</a> »</li> + + <li><a href="00overview.html">API references</a> »</li> + + <li>DataSet</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../_sources/sites/api_ref/DataSet.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="dataset"> +<h1>DataSet<a class="headerlink" href="#dataset" title="Permalink to this headline">¶</a></h1> +<dl class="class"> +<dt id="quantipy.DataSet"> +<em class="property">class </em><code class="descclassname">quantipy.</code><code class="descname">DataSet</code><span class="sig-paren">(</span><em>name</em>, <em>dimensions_comp=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet" title="Permalink to this definition">¶</a></dt> +<dd><p>A set of casedata (required) and meta data (optional).</p> +<p>DESC.</p> +<dl class="method"> +<dt id="quantipy.DataSet.add_meta"> +<code class="descname">add_meta</code><span class="sig-paren">(</span><em>name</em>, <em>qtype</em>, <em>label</em>, <em>categories=None</em>, <em>items=None</em>, <em>text_key=None</em>, <em>replace=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.add_meta" title="Permalink to this definition">¶</a></dt> +<dd><p>Create and insert a well-formed meta object into the existing meta document.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">meta['columns']</span></code>.</li> +<li><strong>qtype</strong> (<em>{'int'</em><em>, </em><em>'float'</em><em>, </em><em>'single'</em><em>, </em><em>'delimited set'</em><em>, </em><em>'date'</em><em>, </em><em>'string'}</em>) – The structural type of the data the meta describes.</li> +<li><strong>label</strong> (<em>str</em>) – The <code class="docutils literal"><span class="pre">text</span></code> label information.</li> +<li><strong>categories</strong> (<em>list of str</em><em>, </em><em>int</em><em>, or </em><em>tuples in form of</em><em> (</em><em>int</em><em>, </em><em>str</em><em>)</em><em>, </em><em>default None</em>) – When a list of str is given, the categorical values will simply be +enumerated and mapped to the category labels. If only int are +provided, text labels are assumed to be an empty str (‘’) and a +warning is triggered. Alternatively, codes can be mapped to categorical +labels, e.g.: <code class="docutils literal"><span class="pre">[(1,</span> <span class="pre">'Elephant'),</span> <span class="pre">(2,</span> <span class="pre">'Mouse'),</span> <span class="pre">(999,</span> <span class="pre">'No</span> <span class="pre">animal')]</span></code></li> +<li><strong>items</strong> (<em>list of str</em><em>, </em><em>int</em><em>, or </em><em>tuples in form of</em><em> (</em><em>int</em><em>, </em><em>str</em><em>)</em><em>, </em><em>default None</em>) – If provided will automatically create an array type mask. +When a list of str is given, the item number will simply be +enumerated and mapped to the category labels. If only int are +provided, item text labels are assumed to be an empty str (‘’) and +a warning is triggered. Alternatively, numerical values can be +mapped explicitly to items labels, e.g.: +<code class="docutils literal"><span class="pre">[(1</span> <span class="pre">'The</span> <span class="pre">first</span> <span class="pre">item'),</span> <span class="pre">(2,</span> <span class="pre">'The</span> <span class="pre">second</span> <span class="pre">item'),</span> <span class="pre">(99,</span> <span class="pre">'Last</span> <span class="pre">item')]</span></code></li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – Text key for text-based label information. Uses the +<code class="docutils literal"><span class="pre">DataSet.text_key</span></code> information if not provided.</li> +<li><strong>replace</strong> (<em>bool</em><em>, </em><em>default True</em>) – If True, an already existing corresponding <code class="docutils literal"><span class="pre">pd.DataFrame</span></code> +column in the case data component will be overwritten with a +new (empty) one.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><code class="docutils literal"><span class="pre">DataSet</span></code> is modified inplace, meta data and <code class="docutils literal"><span class="pre">_data</span></code> columns +will be added</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.all"> +<code class="descname">all</code><span class="sig-paren">(</span><em>name</em>, <em>codes</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.all" title="Permalink to this definition">¶</a></dt> +<dd><p>Return a logical has_all() slicer for the passed codes.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">When applied to an array mask, the has_all() logic is ex- +tended to the item sources, i.e. the it must itself be true for +<em>all</em> the items.</p> +</div> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em><em>, </em><em>default None</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code> or +<code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</li> +<li><strong>codes</strong> (<em>int</em><em> or </em><em>list of int</em>) – The codes to build the logical slicer from.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>slicer</strong> – The indices fulfilling has_all([codes]).</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">pandas.Index</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.any"> +<code class="descname">any</code><span class="sig-paren">(</span><em>name</em>, <em>codes</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.any" title="Permalink to this definition">¶</a></dt> +<dd><p>Return a logical has_any() slicer for the passed codes.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">When applied to an array mask, the has_any() logic is ex- +tended to the item sources, i.e. the it must itself be true for +<em>at least one of</em> the items.</p> +</div> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em><em>, </em><em>default None</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code> or +<code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</li> +<li><strong>codes</strong> (<em>int</em><em> or </em><em>list of int</em>) – The codes to build the logical slicer from.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>slicer</strong> – The indices fulfilling has_any([codes]).</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">pandas.Index</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.band"> +<code class="descname">band</code><span class="sig-paren">(</span><em>name</em>, <em>bands</em>, <em>new_name=None</em>, <em>label=None</em>, <em>text_key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.band" title="Permalink to this definition">¶</a></dt> +<dd><p>Group numeric data with band definitions treated as group text labels.</p> +<p>Wrapper around <code class="docutils literal"><span class="pre">derive()</span></code> for quick banding of numeric +data.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code> that will +be banded into summarized categories.</li> +<li><strong>bands</strong> (list of int/tuple <em>or</em> dict mapping the former to value texts) – The categorical bands to be used. Bands can be single numeric +values or ranges, e.g.: [0, (1, 10), 11, 12, (13, 20)]. +Be default, each band will also make up the value text of the +category created in the <code class="docutils literal"><span class="pre">_meta</span></code> component. To specify custom +texts, map each band to a category name e.g.: +[{‘A’: 0}, +{‘B’: (1, 10)}, +{‘C’: 11}, +{‘D’: 12}, +{‘E’: (13, 20)}]</li> +<li><strong>new_name</strong> (<em>str</em><em>, </em><em>default None</em>) – The created variable will be named <code class="docutils literal"><span class="pre">'<name>_banded'</span></code>, unless a +desired name is provided explicitly here.</li> +<li><strong>label</strong> (<em>str</em><em>, </em><em>default None</em>) – The created variable’s text label will be identical to the origi- +nating one’s passed in <code class="docutils literal"><span class="pre">name</span></code>, unless a desired label is provided +explicitly here.</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – Text key for text-based label information. Uses the +<code class="docutils literal"><span class="pre">DataSet.text_key</span></code> information if not provided.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><code class="docutils literal"><span class="pre">DataSet</span></code> is modified inplace.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.by_type"> +<code class="descname">by_type</code><span class="sig-paren">(</span><em>types=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.by_type" title="Permalink to this definition">¶</a></dt> +<dd><p>Get an overview of all the variables ordered by their type.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>types</strong> (<em>str</em><em> or </em><em>list of str</em><em>, </em><em>default None</em>) – Restrict the overview to these data types.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>overview</strong> – The variables per data type inside the <code class="docutils literal"><span class="pre">DataSet</span></code>.</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">pandas.DataFrame</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.categorize"> +<code class="descname">categorize</code><span class="sig-paren">(</span><em>name</em>, <em>categorized_name=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.categorize" title="Permalink to this definition">¶</a></dt> +<dd><p>Categorize an <code class="docutils literal"><span class="pre">int</span></code>/<code class="docutils literal"><span class="pre">string</span></code>/<code class="docutils literal"><span class="pre">text</span></code> variable to <code class="docutils literal"><span class="pre">single</span></code>.</p> +<p>The <code class="docutils literal"><span class="pre">values</span></code> object of the categorized variable is populated with the +unique values found in the originating variable (ignoring np.NaN / +empty row entries).</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">meta['columns']</span></code> that will +be categorized.</li> +<li><strong>categorized_name</strong> (<em>str</em>) – If provided, the categorized variable’s new name will be drawn +from here, otherwise a default name in form of <code class="docutils literal"><span class="pre">'name#'</span></code> will be +used.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">DataSet is modified inplace, adding the categorized variable to it.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.clear_factors"> +<code class="descname">clear_factors</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.clear_factors" title="Permalink to this definition">¶</a></dt> +<dd><p>Remove all factors set in the variable’s <code class="docutils literal"><span class="pre">'values'</span></code> object.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code> or +<code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">None</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.clone"> +<code class="descname">clone</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.clone" title="Permalink to this definition">¶</a></dt> +<dd><p>Get a deep copy of the <code class="docutils literal"><span class="pre">DataSet</span></code> instance.</p> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.code_count"> +<code class="descname">code_count</code><span class="sig-paren">(</span><em>name</em>, <em>count_only=None</em>, <em>count_not=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.code_count" title="Permalink to this definition">¶</a></dt> +<dd><p>Get the total number of codes/entries found per row.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Will be 0/1 for type <code class="docutils literal"><span class="pre">single</span></code> and range between 0 and the +number of possible values for type <code class="docutils literal"><span class="pre">delimited</span> <span class="pre">set</span></code>.</p> +</div> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">meta['columns']</span></code> or +<code class="docutils literal"><span class="pre">meta['masks']</span></code>.</li> +<li><strong>count_only</strong> (<em>int</em><em> or </em><em>list of int</em><em>, </em><em>default None</em>) – Pass a list of codes to restrict counting to.</li> +<li><strong>count_not</strong> (<em>int</em><em> or </em><em>list of int</em><em>, </em><em>default None</em>) – Pass a list of codes that should no be counted.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>count</strong> – A series with the results as ints.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">pandas.Series</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.code_from_label"> +<code class="descname">code_from_label</code><span class="sig-paren">(</span><em>name</em>, <em>text_label</em>, <em>text_key=None</em>, <em>exact=True</em>, <em>flat=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.code_from_label" title="Permalink to this definition">¶</a></dt> +<dd><p>Return the code belonging to the passed <code class="docutils literal"><span class="pre">text</span></code> label (if present).</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The originating variable name keyed in <code class="docutils literal"><span class="pre">meta['columns']</span></code> +or <code class="docutils literal"><span class="pre">meta['masks']</span></code>.</li> +<li><strong>text_label</strong> (<em>str</em><em> or </em><em>list of str</em>) – The value text(s) to search for.</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – The desired <code class="docutils literal"><span class="pre">text_key</span></code> to search through. Uses the +<code class="docutils literal"><span class="pre">DataSet.text_key</span></code> information if not provided.</li> +<li><strong>exact</strong> (<em>bool</em><em>, </em><em>default True</em>) – <code class="docutils literal"><span class="pre">text_label</span></code> must exactly match a categorical value’s <code class="docutils literal"><span class="pre">text</span></code>. +If False, it is enough that the category <em>contains</em> the <code class="docutils literal"><span class="pre">text_label</span></code>.</li> +<li><strong>flat</strong> (If a list is passed for <code class="docutils literal"><span class="pre">text_label</span></code>, return all found codes) – as a regular list. If False, return a list of lists matching the order +of the <code class="docutils literal"><span class="pre">text_label</span></code> list.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>codes</strong> – The list of value codes found for the passed label <code class="docutils literal"><span class="pre">text</span></code>.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.codes"> +<code class="descname">codes</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.codes" title="Permalink to this definition">¶</a></dt> +<dd><p>Get categorical data’s numerical code values.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code>.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>codes</strong> – The list of category codes.</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">list</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.codes_in_data"> +<code class="descname">codes_in_data</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.codes_in_data" title="Permalink to this definition">¶</a></dt> +<dd><p>Get a list of codes that exist in data.</p> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.compare"> +<code class="descname">compare</code><span class="sig-paren">(</span><em>dataset</em>, <em>variables=None</em>, <em>strict=False</em>, <em>text_key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.compare" title="Permalink to this definition">¶</a></dt> +<dd><p>Compares types, codes, values, question labels of two datasets.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>dataset</strong> (<em>quantipy.DataSet instance</em>) – Test if all variables in the provided <code class="docutils literal"><span class="pre">dataset</span></code> are also in +<code class="docutils literal"><span class="pre">self</span></code> and compare their metadata definitions.</li> +<li><strong>variables</strong> (<em>str</em><em>, </em><em>list of str</em>) – Check only these variables</li> +<li><strong>strict</strong> (<em>bool</em><em>, </em><em>default False</em>) – If True lower/ upper cases and spaces are taken into account.</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>list of str</em>) – The textkeys for which texts are compared.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.convert"> +<code class="descname">convert</code><span class="sig-paren">(</span><em>name</em>, <em>to</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.convert" title="Permalink to this definition">¶</a></dt> +<dd><p>Convert meta and case data between compatible variable types.</p> +<p>Wrapper around the separate <code class="docutils literal"><span class="pre">as_TYPE()</span></code> conversion methods.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">meta['columns']</span></code> that will +be converted.</li> +<li><strong>to</strong> (<em>{'int'</em><em>, </em><em>'float'</em><em>, </em><em>'single'</em><em>, </em><em>'delimited set'</em><em>, </em><em>'string'}</em>) – The variable type to convert to.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The DataSet variable is modified inplace.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.copy"> +<code class="descname">copy</code><span class="sig-paren">(</span><em>name</em>, <em>suffix='rec'</em>, <em>copy_data=True</em>, <em>slicer=None</em>, <em>copy_only=None</em>, <em>copy_not=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.copy" title="Permalink to this definition">¶</a></dt> +<dd><p>Copy meta and case data of the variable defintion given per <code class="docutils literal"><span class="pre">name</span></code>.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The originating column variable name keyed in <code class="docutils literal"><span class="pre">meta['columns']</span></code> +or <code class="docutils literal"><span class="pre">meta['masks']</span></code>.</li> +<li><strong>suffix</strong> (<em>str</em><em>, </em><em>default 'rec'</em>) – The new variable name will be constructed by suffixing the original +<code class="docutils literal"><span class="pre">name</span></code> with <code class="docutils literal"><span class="pre">_suffix</span></code>, e.g. <code class="docutils literal"><span class="pre">'age_rec</span></code>.</li> +<li><strong>copy_data</strong> (<em>bool</em><em>, </em><em>default True</em>) – The new variable assumes the <code class="docutils literal"><span class="pre">data</span></code> of the original variable.</li> +<li><strong>slicer</strong> (<em>dict</em>) – If the data is copied it is possible to filter the data with a +complex logic. Example: slicer = {‘q1’: not_any([99])}</li> +<li><strong>copy_only</strong> (<em>int</em><em> or </em><em>list of int</em><em>, </em><em>default None</em>) – If provided, the copied version of the variable will only contain +(data and) meta for the specified codes.</li> +<li><strong>copy_not</strong> (<em>int</em><em> or </em><em>list of int</em><em>, </em><em>default None</em>) – If provided, the copied version of the variable will contain +(data and) meta for the all codes, except of the indicated.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">DataSet is modified inplace, adding a copy to both the data and meta +component.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.copy_array_data"> +<code class="descname">copy_array_data</code><span class="sig-paren">(</span><em>source</em>, <em>target</em>, <em>source_items=None</em>, <em>target_items=None</em>, <em>slicer=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.copy_array_data" title="Permalink to this definition">¶</a></dt> +<dd></dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.create_set"> +<code class="descname">create_set</code><span class="sig-paren">(</span><em>setname='new_set'</em>, <em>based_on='data file'</em>, <em>included=None</em>, <em>excluded=None</em>, <em>strings='keep'</em>, <em>arrays='masks'</em>, <em>replace=None</em>, <em>overwrite=False</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.create_set" title="Permalink to this definition">¶</a></dt> +<dd><p>Create a new set in <code class="docutils literal"><span class="pre">dataset._meta['sets']</span></code>.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>setname</strong> (<em>str</em><em>, </em><em>default 'new_set'</em>) – Name of the new set.</li> +<li><strong>based_on</strong> (<em>str</em><em>, </em><em>default 'data file'</em>) – Name of set that can be reduced or expanded.</li> +<li><strong>included</strong> (<em>str</em><em> or </em><em>list/set/tuple of str</em>) – Names of the variables to be included in the new set. If None all +variables in <code class="docutils literal"><span class="pre">based_on</span></code> are taken.</li> +<li><strong>excluded</strong> (<em>str</em><em> or </em><em>list/set/tuple of str</em>) – Names of the variables to be excluded in the new set.</li> +<li><strong>strings</strong> (<em>{'keep'</em><em>, </em><em>'drop'</em><em>, </em><em>'only'}</em><em>, </em><em>default 'keep'</em>) – Keep, drop or only include string variables.</li> +<li><strong>arrays</strong> (<em>{'masks'</em><em>, </em><em>'columns'}</em><em>, </em><em>default masks</em>) – For arrays add <code class="docutils literal"><span class="pre">masks@varname</span></code> or <code class="docutils literal"><span class="pre">columns@varname</span></code>.</li> +<li><strong>replace</strong> (<em>dict</em>) – Replace a variable in the set with an other. +Example: {‘q1’: ‘q1_rec’}, ‘q1’ and ‘q1_rec’ must be included in +<code class="docutils literal"><span class="pre">based_on</span></code>. ‘q1’ will be removed and ‘q1_rec’ will be +moved to this position.</li> +<li><strong>overwrite</strong> (<em>bool</em><em>, </em><em>default False</em>) – Overwrite if <code class="docutils literal"><span class="pre">meta['sets'][name]</span></code> already exist.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The <code class="docutils literal"><span class="pre">DataSet</span></code> is modified inplace.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.crosstab"> +<code class="descname">crosstab</code><span class="sig-paren">(</span><em>x</em>, <em>y=None</em>, <em>w=None</em>, <em>pct=False</em>, <em>decimals=1</em>, <em>text=True</em>, <em>rules=False</em>, <em>xtotal=False</em>, <em>f=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.crosstab" title="Permalink to this definition">¶</a></dt> +<dd></dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.cut_item_texts"> +<code class="descname">cut_item_texts</code><span class="sig-paren">(</span><em>arrays=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.cut_item_texts" title="Permalink to this definition">¶</a></dt> +<dd><p>Remove array text from array item texts.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arrays</strong> (<em>str</em><em>, </em><em>list of str</em><em>, </em><em>default None</em>) – Cut texts for items of these arrays. If None, all keys in +<code class="docutils literal"><span class="pre">._meta['masks']</span></code> are taken.</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.data"> +<code class="descname">data</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.data" title="Permalink to this definition">¶</a></dt> +<dd><p>Return the <code class="docutils literal"><span class="pre">data</span></code> component of the <code class="docutils literal"><span class="pre">DataSet</span></code> instance.</p> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.derive"> +<code class="descname">derive</code><span class="sig-paren">(</span><em>name</em>, <em>qtype</em>, <em>label</em>, <em>cond_map</em>, <em>text_key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.derive" title="Permalink to this definition">¶</a></dt> +<dd><p>Create meta and recode case data by specifying derived category logics.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">meta['columns']</span></code>.</li> +<li><strong>qtype</strong> ([<code class="docutils literal"><span class="pre">int</span></code>, <code class="docutils literal"><span class="pre">float</span></code>, <code class="docutils literal"><span class="pre">single</span></code>, <code class="docutils literal"><span class="pre">delimited</span> <span class="pre">set</span></code>]) – The structural type of the data the meta describes.</li> +<li><strong>label</strong> (<em>str</em>) – The <code class="docutils literal"><span class="pre">text</span></code> label information.</li> +<li><strong>cond_map</strong> (<em>list of tuples</em>) – <p>Tuples of either two or three elements of following structures:</p> +<p>2 elements, no labels provided: +(code, <qp logic expression here>), e.g.: +<code class="docutils literal"><span class="pre">(1,</span> <span class="pre">intersection([{'gender':</span> <span class="pre">[1]},</span> <span class="pre">{'age':</span> <span class="pre">frange('30-40')}]))</span></code></p> +<p>2 elements, no codes provided: +(‘text label’, <qp logic expression here>), e.g.: +<code class="docutils literal"><span class="pre">('Cat</span> <span class="pre">1',</span> <span class="pre">intersection([{'gender':</span> <span class="pre">[1]},</span> <span class="pre">{'age':</span> <span class="pre">frange('30-40')}]))</span></code></p> +<p>3 elements, with codes + labels: +(code, ‘Label goes here’, <qp logic expression here>), e.g.: +<code class="docutils literal"><span class="pre">(1,</span> <span class="pre">'Men,</span> <span class="pre">30</span> <span class="pre">to</span> <span class="pre">40',</span> <span class="pre">intersection([{'gender':</span> <span class="pre">[1]},</span> <span class="pre">{'age':</span> <span class="pre">frange('30-40')}]))</span></code></p> +</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – Text key for text-based label information. Will automatically fall +back to the instance’s text_key property information if not provided.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><code class="docutils literal"><span class="pre">DataSet</span></code> is modified inplace.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.derotate"> +<code class="descname">derotate</code><span class="sig-paren">(</span><em>levels</em>, <em>mapper</em>, <em>other=None</em>, <em>unique_key='identity'</em>, <em>dropna=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.derotate" title="Permalink to this definition">¶</a></dt> +<dd><p>Derotate data and meta using the given mapper, and appending others.</p> +<p>This function derotates data using the specification defined in +mapper, which is a list of dicts of lists, describing how +columns from data can be read as a heirarchical structure.</p> +<p>Returns derotated DataSet instance and saves data and meta as json +and csv.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>levels</strong> (<em>dict</em>) – The name and values of a new column variable to identify cases.</li> +<li><strong>mapper</strong> (<em>list of dicts of lists</em>) – <p>A list of dicts matching where the new column names are keys to +to lists of source columns. Example:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">mapper</span> <span class="o">=</span> <span class="p">[{</span><span class="s1">'q14_1'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q14_1_1'</span><span class="p">,</span> <span class="s1">'q14_1_2'</span><span class="p">,</span> <span class="s1">'q14_1_3'</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q14_2'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q14_2_1'</span><span class="p">,</span> <span class="s1">'q14_2_2'</span><span class="p">,</span> <span class="s1">'q14_2_3'</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q14_3'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q14_3_1'</span><span class="p">,</span> <span class="s1">'q14_3_2'</span><span class="p">,</span> <span class="s1">'q14_3_3'</span><span class="p">]}]</span> +</pre></div> +</div> +</li> +<li><strong>unique_key</strong> (<em>str</em>) – Name of column variable that will be copied to new dataset.</li> +<li><strong>other</strong> (<em>list</em><em> (</em><em>optional; default=None</em><em>)</em>) – A list of additional columns from the source data to be appended +to the end of the resulting stacked dataframe.</li> +<li><strong>dropna</strong> (<em>boolean</em><em> (</em><em>optional; default=True</em><em>)</em>) – Passed through to the pandas.DataFrame.stack() operation.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">new <code class="docutils literal"><span class="pre">qp.DataSet</span></code> instance</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.describe"> +<code class="descname">describe</code><span class="sig-paren">(</span><em>var=None</em>, <em>only_type=None</em>, <em>text_key=None</em>, <em>axis_edit=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.describe" title="Permalink to this definition">¶</a></dt> +<dd><p>Inspect the DataSet’s global or variable level structure.</p> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.dichotomize"> +<code class="descname">dichotomize</code><span class="sig-paren">(</span><em>name</em>, <em>value_texts=None</em>, <em>keep_variable_text=True</em>, <em>ignore=None</em>, <em>replace=False</em>, <em>text_key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.dichotomize" title="Permalink to this definition">¶</a></dt> +<dd></dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.dimensionize"> +<code class="descname">dimensionize</code><span class="sig-paren">(</span><em>names=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.dimensionize" title="Permalink to this definition">¶</a></dt> +<dd><p>Rename the dataset columns for Dimensions compatibility.</p> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.dimensionizing_mapper"> +<code class="descname">dimensionizing_mapper</code><span class="sig-paren">(</span><em>names=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.dimensionizing_mapper" title="Permalink to this definition">¶</a></dt> +<dd><p>Return a renaming dataset mapper for dimensionizing names.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>None</strong> – </td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>mapper</strong> – A renaming mapper in the form of a dict of {old: new} that +maps non-Dimensions naming conventions to Dimensions naming +conventions.</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">dict</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.drop"> +<code class="descname">drop</code><span class="sig-paren">(</span><em>name</em>, <em>ignore_items=False</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.drop" title="Permalink to this definition">¶</a></dt> +<dd><p>Drops variables from meta and data components of the <code class="docutils literal"><span class="pre">DataSet</span></code>.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em><em> or </em><em>list of str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code> or +<code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</li> +<li><strong>ignore_items</strong> (<em>bool</em>) – If False source variables for arrays in <code class="docutils literal"><span class="pre">_meta['columns']</span></code> +are dropped, otherwise kept.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">DataSet is modified inplace.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.drop_duplicates"> +<code class="descname">drop_duplicates</code><span class="sig-paren">(</span><em>unique_id='identity'</em>, <em>keep='first'</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.drop_duplicates" title="Permalink to this definition">¶</a></dt> +<dd><p>Drop duplicated cases from self._data.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> +<li><strong>unique_id</strong> (<em>str</em>) – Variable name that gets scanned for duplicates.</li> +<li><strong>keep</strong> (<em>str</em><em>, </em><em>{'first'</em><em>, </em><em>'last'}</em>) – Keep first or last of the duplicates.</li> +</ul> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.duplicates"> +<code class="descname">duplicates</code><span class="sig-paren">(</span><em>name='identity'</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.duplicates" title="Permalink to this definition">¶</a></dt> +<dd><p>Returns a list with duplicated values for the provided name.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> (<em>str</em><em>, </em><em>default 'identity'</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">meta['columns']</span></code>.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>vals</strong> – A list of duplicated values found in the named variable.</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">list</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.empty"> +<code class="descname">empty</code><span class="sig-paren">(</span><em>name</em>, <em>condition=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.empty" title="Permalink to this definition">¶</a></dt> +<dd><p>Check variables for emptiness (opt. restricted by a condition).</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>(</em><em>list of</em><em>) </em><em>str</em>) – The mask variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code>.</li> +<li><strong>condition</strong> (<em>Quantipy logic expression</em><em>, </em><em>default None</em>) – A logical condition expressed as Quantipy logic that determines +which subset of the case data rows to be considered.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>empty</strong></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.empty_items"> +<code class="descname">empty_items</code><span class="sig-paren">(</span><em>name</em>, <em>condition=None</em>, <em>by_name=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.empty_items" title="Permalink to this definition">¶</a></dt> +<dd><p>Test arrays for item emptiness (opt. restricted by a condition).</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>(</em><em>list of</em><em>) </em><em>str</em>) – The mask variable name keyed in <code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</li> +<li><strong>condition</strong> (<em>Quantipy logic expression</em><em>, </em><em>default None</em>) – A logical condition expressed as Quantipy logic that determines +which subset of the case data rows to be considered.</li> +<li><strong>by_name</strong> (<em>bool</em><em>, </em><em>default True</em>) – Return array items by their name or their index.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>empty</strong> – The list of empty items by their source names or positional index +(starting from 1!, mapped to their parent mask name if more than +one).</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.extend_items"> +<code class="descname">extend_items</code><span class="sig-paren">(</span><em>name</em>, <em>ext_items</em>, <em>text_key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.extend_items" title="Permalink to this definition">¶</a></dt> +<dd><p>Extend mask items of an existing array.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> +<li><strong>name</strong> (<em>str</em>) – The originating column variable name keyed in <code class="docutils literal"><span class="pre">meta['masks']</span></code>.</li> +<li><strong>ext_items</strong> (<em>list of str/ list of dict</em>) – The label of the new item. It can be provided as str, then the new +column is named by the grid and the item_no, or as dict +{‘new_column’: ‘label’}.</li> +<li><strong>text_key</strong> (<em>str/ list of str</em><em>, </em><em>default None</em>) – Text key for text-based label information. Will automatically fall +back to the instance’s text_key property information if not provided.</li> +</ul> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.extend_values"> +<code class="descname">extend_values</code><span class="sig-paren">(</span><em>name</em>, <em>ext_values</em>, <em>text_key=None</em>, <em>safe=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.extend_values" title="Permalink to this definition">¶</a></dt> +<dd><p>Add to the ‘values’ object of existing column or mask meta data.</p> +<p>Attempting to add already existing value codes or providing already +present value texts will both raise a <code class="docutils literal"><span class="pre">ValueError</span></code>!</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code> or +<code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</li> +<li><strong>ext_values</strong> (<em>list of str</em><em> or </em><em>tuples in form of</em><em> (</em><em>int</em><em>, </em><em>str</em><em>)</em><em>, </em><em>default None</em>) – When a list of str is given, the categorical values will simply be +enumerated and mapped to the category labels. Alternatively codes can +mapped to categorical labels, e.g.: +[(1, ‘Elephant’), (2, ‘Mouse’), (999, ‘No animal’)]</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – Text key for text-based label information. Will automatically fall +back to the instance’s text_key property information if not provided.</li> +<li><strong>safe</strong> (<em>bool</em><em>, </em><em>default True</em>) – If set to False, duplicate value texts are allowed when extending +the <code class="docutils literal"><span class="pre">values</span></code> object.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The <code class="docutils literal"><span class="pre">DataSet</span></code> is modified inplace.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.factors"> +<code class="descname">factors</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.factors" title="Permalink to this definition">¶</a></dt> +<dd><p>Get categorical data’s stat. factor values.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code> or +<code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>factors</strong> – A <code class="docutils literal"><span class="pre">{value:</span> <span class="pre">factor}</span></code> mapping.</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">OrderedDict</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.filter"> +<code class="descname">filter</code><span class="sig-paren">(</span><em>alias</em>, <em>condition</em>, <em>inplace=False</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.filter" title="Permalink to this definition">¶</a></dt> +<dd><p>Filter the DataSet using a Quantipy logical expression.</p> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.find"> +<code class="descname">find</code><span class="sig-paren">(</span><em>str_tags=None</em>, <em>suffixed=False</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.find" title="Permalink to this definition">¶</a></dt> +<dd><p>Find variables by searching their names for substrings.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>str_tags</strong> (<em>(</em><em>list of</em><em>) </em><em>str</em>) – The strings tags to look for in the variable names. If not provided, +the modules’ default global list of substrings from VAR_SUFFIXES +will be used.</li> +<li><strong>suffixed</strong> (<em>bool</em><em>, </em><em>default False</em>) – If set to True, only variable names that end with a given string +sequence will qualify.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>found</strong> – The list of matching variable names.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.find_duplicate_texts"> +<code class="descname">find_duplicate_texts</code><span class="sig-paren">(</span><em>name</em>, <em>text_key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.find_duplicate_texts" title="Permalink to this definition">¶</a></dt> +<dd><p>Collect values that share the same text information to find duplicates.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> +<li><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code> or +<code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – Text key for text-based label information. Will automatically fall +back to the instance’s <code class="docutils literal"><span class="pre">text_key</span></code> property information if not +provided.</li> +</ul> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.flatten"> +<code class="descname">flatten</code><span class="sig-paren">(</span><em>name</em>, <em>codes</em>, <em>new_name=None</em>, <em>text_key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.flatten" title="Permalink to this definition">¶</a></dt> +<dd><p>Create a variable that groups array mask item answers to categories.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The array variable name keyed in <code class="docutils literal"><span class="pre">meta['masks']</span></code> that will +be converted.</li> +<li><strong>codes</strong> (<em>int</em><em>, </em><em>list of int</em>) – The answers codes that determine the categorical grouping. +Item labels will become the category labels.</li> +<li><strong>new_name</strong> (<em>str</em><em>, </em><em>default None</em>) – The name of the new delimited set variable. If None, <code class="docutils literal"><span class="pre">name</span></code> is +suffixed with ‘_rec’.</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – Text key for text-based label information. Uses the +<code class="docutils literal"><span class="pre">DataSet.text_key</span></code> information if not provided.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The DataSet is modified inplace, delimited set variable is added.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.force_texts"> +<code class="descname">force_texts</code><span class="sig-paren">(</span><em>copy_to=None</em>, <em>copy_from=None</em>, <em>update_existing=False</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.force_texts" title="Permalink to this definition">¶</a></dt> +<dd><p>Copy info from existing text_key to a new one or update the existing one.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>copy_to</strong> (<em>str</em>) – {‘en-GB’, ‘da-DK’, ‘fi-FI’, ‘nb-NO’, ‘sv-SE’, ‘de-DE’} +None -> _meta[‘lib’][‘default text’] +The text key that will be filled.</li> +<li><strong>copy_from</strong> (<em>str / list</em>) – {‘en-GB’, ‘da-DK’, ‘fi-FI’, ‘nb-NO’, ‘sv-SE’, ‘de-DE’} +You can also enter a list with text_keys, if the first text_key +doesn’t exist, it takes the next one</li> +<li><strong>update_existing</strong> (<em>bool</em>) – True : copy_to will be filled in any case +False: copy_to will be filled if it’s empty/not existing</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.from_batch"> +<code class="descname">from_batch</code><span class="sig-paren">(</span><em>batch_name</em>, <em>include='identity'</em>, <em>text_key=[]</em>, <em>apply_edits=True</em>, <em>additions='variables'</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.from_batch" title="Permalink to this definition">¶</a></dt> +<dd><p>Get a filtered subset of the DataSet using qp.Batch definitions.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>batch_name</strong> (<em>str</em>) – Name of a Batch included in the DataSet.</li> +<li><strong>include</strong> (<em>str/ list of str</em>) – Name of variables that get included even if they are not in Batch.</li> +<li><strong>text_key</strong> (<em>str/ list of str</em><em>, </em><em>default None</em>) – Take over all texts of the included text_key(s), if None is provided +all included text_keys are taken.</li> +<li><strong>apply_edits</strong> (<em>bool</em><em>, </em><em>default True</em>) – meta_edits and rules are used as/ applied on global meta of the +new DataSet instance.</li> +<li><strong>additions</strong> (<em>{'variables'</em><em>, </em><em>'filters'</em><em>, </em><em>'full'</em><em>, </em><em>None}</em>) – Extend included variables by the xks, yks and weights of the +additional batches if set to ‘variables’, ‘filters’ will create +new 1/0-coded variables that reflect any filters defined. Selecting +‘full’ will do both, <code class="docutils literal"><span class="pre">None</span></code> will ignore additional Batches completely.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>b_ds</strong></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><code class="docutils literal"><span class="pre">quantipy.DataSet</span></code></p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.from_components"> +<code class="descname">from_components</code><span class="sig-paren">(</span><em>data_df</em>, <em>meta_dict=None</em>, <em>reset=True</em>, <em>text_key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.from_components" title="Permalink to this definition">¶</a></dt> +<dd><p>Attach data and meta directly to the <code class="docutils literal"><span class="pre">DataSet</span></code> instance.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Except testing for appropriate object types, this method +offers no additional safeguards or consistency/compability checks +with regard to the passed data and meta documents!</p> +</div> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>data_df</strong> (<em>pandas.DataFrame</em>) – A DataFrame that contains case data entries for the <code class="docutils literal"><span class="pre">DataSet</span></code>.</li> +<li><strong>meta_dict</strong> (<em>dict</em><em>, </em><em>default None</em>) – A dict that stores meta data describing the columns of the data_df. +It is assumed to be well-formed following the Quantipy meta data +structure.</li> +<li><strong>reset</strong> (<em>bool</em><em>, </em><em>default True</em>) – Clean the <cite>‘lib’</cite> and <code class="docutils literal"><span class="pre">'sets'</span></code> metadata collections from non-native +entries, e.g. user-defined information or helper metadata.</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – The text_key to be used. If not provided, it will be attempted to +use the ‘default text’ from the <code class="docutils literal"><span class="pre">meta['lib']</span></code> definition.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.from_excel"> +<code class="descname">from_excel</code><span class="sig-paren">(</span><em>path_xlsx</em>, <em>merge=True</em>, <em>unique_key='identity'</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.from_excel" title="Permalink to this definition">¶</a></dt> +<dd><p>Converts excel files to a dataset or/and merges variables.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>path_xlsx</strong> (<em>str</em>) – Path where the excel file is stored. The file must have exactly +one sheet with data.</li> +<li><strong>merge</strong> (<em>bool</em>) – If True the new data from the excel file will be merged on the +dataset.</li> +<li><strong>unique_key</strong> (<em>str</em>) – If <code class="docutils literal"><span class="pre">merge=True</span></code> an hmerge is done on this variable.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>new_dataset</strong> – Contains only the data from excel. +If <code class="docutils literal"><span class="pre">merge=True</span></code> dataset is modified inplace.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><code class="docutils literal"><span class="pre">quantipy.DataSet</span></code></p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.from_stack"> +<code class="descname">from_stack</code><span class="sig-paren">(</span><em>stack</em>, <em>data_key=None</em>, <em>dk_filter=None</em>, <em>reset=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.from_stack" title="Permalink to this definition">¶</a></dt> +<dd><p>Use <code class="docutils literal"><span class="pre">quantipy.Stack</span></code> data and meta to create a <code class="docutils literal"><span class="pre">DataSet</span></code> instance.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>stack</strong> (<a class="reference internal" href="Stack.html#quantipy.Stack" title="quantipy.Stack"><em>quantipy.Stack</em></a>) – The Stack instance to convert.</li> +<li><strong>data_key</strong> (<em>str</em>) – The reference name where meta and data information are stored.</li> +<li><strong>dk_filter</strong> (<em>string</em><em>, </em><em>default None</em>) – Filter name if the stack contains more than one filters. If None +‘no_filter’ will be used.</li> +<li><strong>reset</strong> (<em>bool</em><em>, </em><em>default True</em>) – Clean the <cite>‘lib’</cite> and <code class="docutils literal"><span class="pre">'sets'</span></code> metadata collections from non-native +entries, e.g. user-defined information or helper metadata.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.fully_hidden_arrays"> +<code class="descname">fully_hidden_arrays</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.fully_hidden_arrays" title="Permalink to this definition">¶</a></dt> +<dd><p>Get all array definitions that contain only hidden items.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><strong>hidden</strong> – The list of array mask names.</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">list</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.get_batch"> +<code class="descname">get_batch</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.get_batch" title="Permalink to this definition">¶</a></dt> +<dd><p>Get existing Batch instance from DataSet meta information.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> (<em>str</em>) – Name of existing Batch instance.</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.get_property"> +<code class="descname">get_property</code><span class="sig-paren">(</span><em>name</em>, <em>prop_name</em>, <em>text_key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.get_property" title="Permalink to this definition">¶</a></dt> +<dd></dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.hide_empty_items"> +<code class="descname">hide_empty_items</code><span class="sig-paren">(</span><em>condition=None</em>, <em>arrays=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.hide_empty_items" title="Permalink to this definition">¶</a></dt> +<dd><p>Apply <code class="docutils literal"><span class="pre">rules</span></code> meta to automatically hide empty array items.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>(</em><em>list of</em><em>) </em><em>str</em><em>, </em><em>default None</em>) – The array mask variable names keyed in <code class="docutils literal"><span class="pre">_meta['masks']</span></code>. If not +explicitly provided will test all array mask definitions.</li> +<li><strong>condition</strong> (<em>Quantipy logic expression</em>) – A logical condition expressed as Quantipy logic that determines +which subset of the case data rows to be considered.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.hiding"> +<code class="descname">hiding</code><span class="sig-paren">(</span><em>name</em>, <em>hide</em>, <em>axis='y'</em>, <em>hide_values=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.hiding" title="Permalink to this definition">¶</a></dt> +<dd><p>Set or update <code class="docutils literal"><span class="pre">rules[axis]['dropx']</span></code> meta for the named column.</p> +<p>Quantipy builds will respect the hidden codes and <em>cut</em> them from +results.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This is not equivalent to <code class="docutils literal"><span class="pre">DataSet.set_missings()</span></code> as +missing values are respected also in computations.</p> +</div> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em><em> or </em><em>list of str</em>) – The column variable(s) name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code>.</li> +<li><strong>hide</strong> (<em>int</em><em> or </em><em>list of int</em>) – Values indicated by their <code class="docutils literal"><span class="pre">int</span></code> codes will be dropped from +<code class="docutils literal"><span class="pre">Quantipy.View.dataframe</span></code>s.</li> +<li><strong>axis</strong> (<em>{'x'</em><em>, </em><em>'y'}</em><em>, </em><em>default 'y'</em>) – The axis to drop the values from.</li> +<li><strong>hide_values</strong> (<em>bool</em><em>, </em><em>default True</em>) – Only considered if <code class="docutils literal"><span class="pre">name</span></code> refers to a mask. If True, values are +hidden on all mask items. If False, mask items are hidden by position +(only for array summaries).</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.hmerge"> +<code class="descname">hmerge</code><span class="sig-paren">(</span><em>dataset</em>, <em>on=None</em>, <em>left_on=None</em>, <em>right_on=None</em>, <em>overwrite_text=False</em>, <em>from_set=None</em>, <em>inplace=True</em>, <em>merge_existing=None</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.hmerge" title="Permalink to this definition">¶</a></dt> +<dd><p>Merge Quantipy datasets together using an index-wise identifer.</p> +<p>This function merges two Quantipy datasets together, updating variables +that exist in the left dataset and appending others. New variables +will be appended in the order indicated by the ‘data file’ set if +found, otherwise they will be appended in alphanumeric order. +This merge happend horizontally (column-wise). Packed kwargs will be +passed on to the pandas.DataFrame.merge() method call, but that merge +will always happen using how=’left’.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>dataset</strong> (<code class="docutils literal"><span class="pre">quantipy.DataSet</span></code>) – The dataset to merge into the current <code class="docutils literal"><span class="pre">DataSet</span></code>.</li> +<li><strong>on</strong> (<em>str</em><em>, </em><em>default=None</em>) – The column to use as a join key for both datasets.</li> +<li><strong>left_on</strong> (<em>str</em><em>, </em><em>default=None</em>) – The column to use as a join key for the left dataset.</li> +<li><strong>right_on</strong> (<em>str</em><em>, </em><em>default=None</em>) – The column to use as a join key for the right dataset.</li> +<li><strong>overwrite_text</strong> (<em>bool</em><em>, </em><em>default=False</em>) – If True, text_keys in the left meta that also exist in right +meta will be overwritten instead of ignored.</li> +<li><strong>from_set</strong> (<em>str</em><em>, </em><em>default=None</em>) – Use a set defined in the right meta to control which columns are +merged from the right dataset.</li> +<li><strong>inplace</strong> (<em>bool</em><em>, </em><em>default True</em>) – If True, the <code class="docutils literal"><span class="pre">DataSet</span></code> will be modified inplace with new/updated +columns. Will return a new <code class="docutils literal"><span class="pre">DataSet</span></code> instance if False.</li> +<li><strong>verbose</strong> (<em>bool</em><em>, </em><em>default=True</em>) – Echo progress feedback to the output pane.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>None or new_dataset</strong> – If the merge is not applied <code class="docutils literal"><span class="pre">inplace</span></code>, a <code class="docutils literal"><span class="pre">DataSet</span></code> instance +is returned.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><code class="docutils literal"><span class="pre">quantipy.DataSet</span></code></p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.interlock"> +<code class="descname">interlock</code><span class="sig-paren">(</span><em>name</em>, <em>label</em>, <em>variables</em>, <em>val_text_sep='/'</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.interlock" title="Permalink to this definition">¶</a></dt> +<dd><p>Build a new category-intersected variable from >=2 incoming variables.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The new column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code>.</li> +<li><strong>label</strong> (<em>str</em>) – The new text label for the created variable.</li> +<li><strong>variables</strong> (<em>list of >= 2 str</em><em> or </em><em>dict</em><em> (</em><em>mapper</em><em>)</em>) – <p>The column names of the variables that are feeding into the +intersecting recode operation. Or dicts/mapper to create temporary +variables for interlock. Can also be a mix of str and dict. Example:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">[</span><span class="s1">'gender'</span><span class="p">,</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'agegrp'</span><span class="p">:</span> <span class="p">[(</span><span class="mi">1</span><span class="p">,</span> <span class="s1">'18-34'</span><span class="p">,</span> <span class="p">{</span><span class="s1">'age'</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'18-34'</span><span class="p">)}),</span> +<span class="gp">... </span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="s1">'35-54'</span><span class="p">,</span> <span class="p">{</span><span class="s1">'age'</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'35-54'</span><span class="p">)}),</span> +<span class="gp">... </span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="s1">'55+'</span><span class="p">,</span> <span class="p">{</span><span class="s1">'age'</span><span class="p">:</span> <span class="n">is_ge</span><span class="p">(</span><span class="mi">55</span><span class="p">)})]},</span> +<span class="gp">... </span> <span class="s1">'region'</span><span class="p">]</span> +</pre></div> +</div> +</li> +<li><strong>val_text_sep</strong> (<em>str</em><em>, </em><em>default '/'</em>) – The passed character (or any other str value) wil be used to +separate the incoming individual value texts to make up the inter- +sected category value texts, e.g.: ‘Female/18-30/London’.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.is_like_numeric"> +<code class="descname">is_like_numeric</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.is_like_numeric" title="Permalink to this definition">¶</a></dt> +<dd><p>Test if a <code class="docutils literal"><span class="pre">string</span></code>-typed variable can be expressed numerically.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code>.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">bool</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.is_nan"> +<code class="descname">is_nan</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.is_nan" title="Permalink to this definition">¶</a></dt> +<dd><p>Detect empty entries in the <code class="docutils literal"><span class="pre">_data</span></code> rows.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">meta['columns']</span></code>.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>count</strong> – A series with the results as bool.</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">pandas.Series</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.item_no"> +<code class="descname">item_no</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.item_no" title="Permalink to this definition">¶</a></dt> +<dd><p>Return the order/position number of passed array item variable name.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code>.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>no</strong> – The positional index of the item (starting from 1).</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">int</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.item_texts"> +<code class="descname">item_texts</code><span class="sig-paren">(</span><em>name</em>, <em>text_key=None</em>, <em>axis_edit=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.item_texts" title="Permalink to this definition">¶</a></dt> +<dd><p>Get the <code class="docutils literal"><span class="pre">text</span></code> meta data for the items of the passed array mask name.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The mask variable name keyed in <code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – The text_key that should be used when taking labels from the +source meta.</li> +<li><strong>axis_edit</strong> (<em>{'x'</em><em>, </em><em>'y'}</em><em>, </em><em>default None</em>) – If provided the text_key is taken from the x/y edits dict.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>texts</strong> – The list of item texts for the array elements.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.items"> +<code class="descname">items</code><span class="sig-paren">(</span><em>name</em>, <em>text_key=None</em>, <em>axis_edit=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.items" title="Permalink to this definition">¶</a></dt> +<dd><p>Get the array’s paired item names and texts information from the meta.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – The text_key that should be used when taking labels from the +source meta.</li> +<li><strong>axis_edit</strong> (<em>{'x'</em><em>, </em><em>'y'}</em><em>, </em><em>default None</em>) – If provided the text_key is taken from the x/y edits dict.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>items</strong> – The list of source item names (from <code class="docutils literal"><span class="pre">_meta['columns']</span></code>) and their +<code class="docutils literal"><span class="pre">text</span></code> information packed as tuples.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list of tuples</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.link"> +<code class="descname">link</code><span class="sig-paren">(</span><em>filters=None</em>, <em>x=None</em>, <em>y=None</em>, <em>views=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.link" title="Permalink to this definition">¶</a></dt> +<dd><p>Create a Link instance from the DataSet.</p> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.merge_texts"> +<code class="descname">merge_texts</code><span class="sig-paren">(</span><em>dataset</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.merge_texts" title="Permalink to this definition">¶</a></dt> +<dd><p>Add additional <code class="docutils literal"><span class="pre">text</span></code> versions from other <code class="docutils literal"><span class="pre">text_key</span></code> meta.</p> +<p>Case data will be ignored during the merging process.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>dataset</strong> ((A list of multiple) <code class="docutils literal"><span class="pre">quantipy.DataSet</span></code>) – One or multiple datasets that provide new <code class="docutils literal"><span class="pre">text_key</span></code> meta.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">None</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.meta"> +<code class="descname">meta</code><span class="sig-paren">(</span><em>name=None</em>, <em>text_key=None</em>, <em>axis_edit=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.meta" title="Permalink to this definition">¶</a></dt> +<dd><p>Provide a <em>pretty</em> summary for variable meta given as per <code class="docutils literal"><span class="pre">name</span></code>.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em><em>, </em><em>default None</em>) – The variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code> or <code class="docutils literal"><span class="pre">_meta['masks']</span></code>. +If None, the entire <code class="docutils literal"><span class="pre">meta</span></code> component of the <code class="docutils literal"><span class="pre">DataSet</span></code> instance +will be returned.</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – The text_key that should be used when taking labels from the +source meta.</li> +<li><strong>axis_edit</strong> (<em>{'x'</em><em>, </em><em>'y'}</em><em>, </em><em>default None</em>) – If provided the text_key is taken from the x/y edits dict.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>meta</strong> – Either a DataFrame that sums up the meta information on a <code class="docutils literal"><span class="pre">mask</span></code> +or <code class="docutils literal"><span class="pre">column</span></code> or the meta dict as a whole is</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">dict or pandas.DataFrame</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.meta_to_json"> +<code class="descname">meta_to_json</code><span class="sig-paren">(</span><em>key=None</em>, <em>collection=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.meta_to_json" title="Permalink to this definition">¶</a></dt> +<dd><p>Save a meta object as json file.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>key</strong> (<em>str</em><em>, </em><em>default None</em>) – Name of the variable whose metadata is saved, if key is not +provided included collection or the whole meta is saved.</li> +<li><strong>collection</strong> (<em>str {'columns'</em><em>, </em><em>'masks'</em><em>, </em><em>'sets'</em><em>, </em><em>'lib'}</em><em>, </em><em>default None</em>) – The meta object is taken from this collection.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.min_value_count"> +<code class="descname">min_value_count</code><span class="sig-paren">(</span><em>name</em>, <em>min=50</em>, <em>weight=None</em>, <em>condition=None</em>, <em>axis='y'</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.min_value_count" title="Permalink to this definition">¶</a></dt> +<dd><p>Wrapper for self.hiding(), which is hiding low value_counts.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> +<li><strong>variables</strong> (<em>str/ list of str</em>) – Name(s) of the variable(s) whose values are checked against the +defined border.</li> +<li><strong>min</strong> (<em>int</em>) – If the amount of counts for a value is below this number, the +value is hidden.</li> +<li><strong>weight</strong> (<em>str</em><em>, </em><em>default None</em>) – Name of the weight, which is used to calculate the weigthed counts.</li> +<li><strong>condition</strong> (<em>complex logic</em>) – The data, which is used to calculate the counts, can be filtered +by the included condition.</li> +<li><strong>axis</strong> (<em>{'y'</em><em>, </em><em>'x'</em><em>, </em><em>[</em><em>'x'</em><em>, </em><em>'y'</em><em>]</em><em>}</em><em>, </em><em>default None</em>) – The axis on which the values are hidden.</li> +</ul> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.names"> +<code class="descname">names</code><span class="sig-paren">(</span><em>ignore_items=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.names" title="Permalink to this definition">¶</a></dt> +<dd><p>Find all weak-duplicate variable names that are different only by case.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Will return self.variables() if no weak-duplicates are found.</p> +</div> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><strong>weak_dupes</strong> – An overview of case-sensitive spelling differences in otherwise +equal variable names.</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">pd.DataFrame</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.order"> +<code class="descname">order</code><span class="sig-paren">(</span><em>new_order=None</em>, <em>reposition=None</em>, <em>regroup=False</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.order" title="Permalink to this definition">¶</a></dt> +<dd><p>Set the global order of the DataSet variables collection.</p> +<p>The global order of the DataSet is reflected in the data component’s +pd.DataFrame.columns order and the variable references in the meta +component’s ‘data file’ items.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>new_order</strong> (<em>list</em>) – A list of all DataSet variables in the desired order.</li> +<li><strong>reposition</strong> (<em>(</em><em>List of</em><em>) </em><em>dict</em>) – Each dict maps one or a list of variables to a reference variable +name key. The mapped variables are moved before the reference key.</li> +<li><strong>regroup</strong> (<em>bool</em><em>, </em><em>default False</em>) – Attempt to regroup non-native variables (i.e. created either +manually with <code class="docutils literal"><span class="pre">add_meta()</span></code>, <code class="docutils literal"><span class="pre">recode()</span></code>, <code class="docutils literal"><span class="pre">derive()</span></code>, etc. +or automatically by manifesting <code class="docutils literal"><span class="pre">qp.View</span></code> objects) with their +originating variables.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.parents"> +<code class="descname">parents</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.parents" title="Permalink to this definition">¶</a></dt> +<dd><p>Get the <code class="docutils literal"><span class="pre">parent</span></code> meta information for masks-structured column elements.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> (<em>str</em>) – The mask variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code>.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>parents</strong> – The list of parents the <code class="docutils literal"><span class="pre">_meta['columns']</span></code> variable is attached to.</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">list</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.populate"> +<code class="descname">populate</code><span class="sig-paren">(</span><em>batches='all'</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.populate" title="Permalink to this definition">¶</a></dt> +<dd><p>Create a <code class="docutils literal"><span class="pre">qp.Stack</span></code> based on all available <code class="docutils literal"><span class="pre">qp.Batch</span></code> definitions.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>batches</strong> (<em>str/ list of str</em>) – Name(s) of <code class="docutils literal"><span class="pre">qp.Batch</span></code> instances that are used to populate the +<code class="docutils literal"><span class="pre">qp.Stack</span></code>.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">qp.Stack</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.read_ascribe"> +<code class="descname">read_ascribe</code><span class="sig-paren">(</span><em>path_meta</em>, <em>path_data</em>, <em>text_key</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.read_ascribe" title="Permalink to this definition">¶</a></dt> +<dd><p>Load Dimensions .xml/.txt files, connecting as data and meta components.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>path_meta</strong> (<em>str</em>) – The full path (optionally with extension <code class="docutils literal"><span class="pre">'.xml'</span></code>, otherwise +assumed as such) to the meta data defining <code class="docutils literal"><span class="pre">'.xml'</span></code> file.</li> +<li><strong>path_data</strong> (<em>str</em>) – The full path (optionally with extension <code class="docutils literal"><span class="pre">'.txt'</span></code>, otherwise +assumed as such) to the case data defining <code class="docutils literal"><span class="pre">'.txt'</span></code> file.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The <code class="docutils literal"><span class="pre">DataSet</span></code> is modified inplace, connected to Quantipy data +and meta components that have been converted from their Ascribe +source files.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.read_dimensions"> +<code class="descname">read_dimensions</code><span class="sig-paren">(</span><em>path_meta</em>, <em>path_data</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.read_dimensions" title="Permalink to this definition">¶</a></dt> +<dd><p>Load Dimensions .ddf/.mdd files, connecting as data and meta components.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>path_meta</strong> (<em>str</em>) – The full path (optionally with extension <code class="docutils literal"><span class="pre">'.mdd'</span></code>, otherwise +assumed as such) to the meta data defining <code class="docutils literal"><span class="pre">'.mdd'</span></code> file.</li> +<li><strong>path_data</strong> (<em>str</em>) – The full path (optionally with extension <code class="docutils literal"><span class="pre">'.ddf'</span></code>, otherwise +assumed as such) to the case data defining <code class="docutils literal"><span class="pre">'.ddf'</span></code> file.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The <code class="docutils literal"><span class="pre">DataSet</span></code> is modified inplace, connected to Quantipy data +and meta components that have been converted from their Dimensions +source files.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.read_quantipy"> +<code class="descname">read_quantipy</code><span class="sig-paren">(</span><em>path_meta</em>, <em>path_data</em>, <em>reset=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.read_quantipy" title="Permalink to this definition">¶</a></dt> +<dd><p>Load Quantipy .csv/.json files, connecting as data and meta components.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>path_meta</strong> (<em>str</em>) – The full path (optionally with extension <code class="docutils literal"><span class="pre">'.json'</span></code>, otherwise +assumed as such) to the meta data defining <code class="docutils literal"><span class="pre">'.json'</span></code> file.</li> +<li><strong>path_data</strong> (<em>str</em>) – The full path (optionally with extension <code class="docutils literal"><span class="pre">'.csv'</span></code>, otherwise +assumed as such) to the case data defining <code class="docutils literal"><span class="pre">'.csv'</span></code> file.</li> +<li><strong>reset</strong> (<em>bool</em><em>, </em><em>default True</em>) – Clean the <cite>‘lib’</cite> and <code class="docutils literal"><span class="pre">'sets'</span></code> metadata collections from non-native +entries, e.g. user-defined information or helper metadata.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The <code class="docutils literal"><span class="pre">DataSet</span></code> is modified inplace, connected to Quantipy native +data and meta components.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.read_spss"> +<code class="descname">read_spss</code><span class="sig-paren">(</span><em>path_sav</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.read_spss" title="Permalink to this definition">¶</a></dt> +<dd><p>Load SPSS Statistics .sav files, converting and connecting data/meta.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>path_sav</strong> (<em>str</em>) – The full path (optionally with extension <code class="docutils literal"><span class="pre">'.sav'</span></code>, otherwise +assumed as such) to the <code class="docutils literal"><span class="pre">'.sav'</span></code> file.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The <code class="docutils literal"><span class="pre">DataSet</span></code> is modified inplace, connected to Quantipy data +and meta components that have been converted from the SPSS +source file.</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">None</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.recode"> +<code class="descname">recode</code><span class="sig-paren">(</span><em>target</em>, <em>mapper</em>, <em>default=None</em>, <em>append=False</em>, <em>intersect=None</em>, <em>initialize=None</em>, <em>fillna=None</em>, <em>inplace=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.recode" title="Permalink to this definition">¶</a></dt> +<dd><p>Create a new or copied series from data, recoded using a mapper.</p> +<p>This function takes a mapper of {key: logic} entries and injects the +key into the target column where its paired logic is True. The logic +may be arbitrarily complex and may refer to any other variable or +variables in data. Where a pre-existing column has been used to +start the recode, the injected values can replace or be appended to +any data found there to begin with. Note that this function does +not edit the target column, it returns a recoded copy of the target +column. The recoded data will always comply with the column type +indicated for the target column according to the meta.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>target</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code> that is the +target of the recode. If not found in <code class="docutils literal"><span class="pre">_meta</span></code> this will fail +with an error. If <code class="docutils literal"><span class="pre">target</span></code> is not found in data.columns the +recode will start from an empty series with the same index as +<code class="docutils literal"><span class="pre">_data</span></code>. If <code class="docutils literal"><span class="pre">target</span></code> is found in data.columns the recode will +start from a copy of that column.</li> +<li><strong>mapper</strong> (<em>dict</em>) – A mapper of {key: logic} entries.</li> +<li><strong>default</strong> (<em>str</em><em>, </em><em>default None</em>) – The column name to default to in cases where unattended lists +are given in your logic, where an auto-transformation of +{key: list} to {key: {default: list}} is provided. Note that +lists in logical statements are themselves a form of shorthand +and this will ultimately be interpreted as: +{key: {default: has_any(list)}}.</li> +<li><strong>append</strong> (<em>bool</em><em>, </em><em>default False</em>) – Should the new recoded data be appended to values already found +in the series? If False, data from series (where found) will +overwrite whatever was found for that item instead.</li> +<li><strong>intersect</strong> (<em>logical statement</em><em>, </em><em>default None</em>) – If a logical statement is given here then it will be used as an +implied intersection of all logical conditions given in the +mapper.</li> +<li><strong>initialize</strong> (<em>str</em><em> or </em><em>np.NaN</em><em>, </em><em>default None</em>) – If not None, a copy of the data named column will be used to +populate the target column before the recode is performed. +Alternatively, initialize can be used to populate the target +column with np.NaNs (overwriting whatever may be there) prior +to the recode.</li> +<li><strong>fillna</strong> (<em>int</em><em>, </em><em>default=None</em>) – If not None, the value passed to fillna will be used on the +recoded series as per pandas.Series.fillna().</li> +<li><strong>inplace</strong> (<em>bool</em><em>, </em><em>default True</em>) – If True, the <code class="docutils literal"><span class="pre">DataSet</span></code> will be modified inplace with new/updated +columns. Will return a new recoded <code class="docutils literal"><span class="pre">pandas.Series</span></code> instance if +False.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Either the <code class="docutils literal"><span class="pre">DataSet._data</span></code> is modified inplace or a new +<code class="docutils literal"><span class="pre">pandas.Series</span></code> is returned.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None or recode_series</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.remove_html"> +<code class="descname">remove_html</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.remove_html" title="Permalink to this definition">¶</a></dt> +<dd><p>Cycle through all meta <code class="docutils literal"><span class="pre">text</span></code> objects removing html tags.</p> +<p>Currently uses the regular expression ‘<.*?>’ in _remove_html() +classmethod.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"></td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">None</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.remove_items"> +<code class="descname">remove_items</code><span class="sig-paren">(</span><em>name</em>, <em>remove</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.remove_items" title="Permalink to this definition">¶</a></dt> +<dd><p>Erase array mask items safely from both meta and case data components.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The originating column variable name keyed in <code class="docutils literal"><span class="pre">meta['masks']</span></code>.</li> +<li><strong>remove</strong> (<em>int</em><em> or </em><em>list of int</em>) – The items listed by their order number in the +<code class="docutils literal"><span class="pre">_meta['masks'][name]['items']</span></code> object will be droped from the +<code class="docutils literal"><span class="pre">mask</span></code> definition.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">DataSet is modified inplace.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.remove_values"> +<code class="descname">remove_values</code><span class="sig-paren">(</span><em>name</em>, <em>remove</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.remove_values" title="Permalink to this definition">¶</a></dt> +<dd><p>Erase value codes safely from both meta and case data components.</p> +<p>Attempting to remove all value codes from the variable’s value object +will raise a <code class="docutils literal"><span class="pre">ValueError</span></code>!</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The originating column variable name keyed in <code class="docutils literal"><span class="pre">meta['columns']</span></code> +or <code class="docutils literal"><span class="pre">meta['masks']</span></code>.</li> +<li><strong>remove</strong> (<em>int</em><em> or </em><em>list of int</em>) – The codes to be removed from the <code class="docutils literal"><span class="pre">DataSet</span></code> variable.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">DataSet is modified inplace.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.rename"> +<code class="descname">rename</code><span class="sig-paren">(</span><em>name</em>, <em>new_name</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.rename" title="Permalink to this definition">¶</a></dt> +<dd><p>Change meta and data column name references of the variable defintion.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The originating column variable name keyed in <code class="docutils literal"><span class="pre">meta['columns']</span></code> +or <code class="docutils literal"><span class="pre">meta['masks']</span></code>.</li> +<li><strong>new_name</strong> (<em>str</em>) – The new variable name.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">DataSet is modified inplace. The new name reference replaces the +original one.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.rename_from_mapper"> +<code class="descname">rename_from_mapper</code><span class="sig-paren">(</span><em>mapper</em>, <em>keep_original=False</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.rename_from_mapper" title="Permalink to this definition">¶</a></dt> +<dd><p>Rename meta objects and data columns using mapper.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mapper</strong> (<em>dict</em>) – A renaming mapper in the form of a dict of {old: new} that +will be used to rename columns throughout the meta and data.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">DataSet is modified inplace.</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">None</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.reorder_items"> +<code class="descname">reorder_items</code><span class="sig-paren">(</span><em>name</em>, <em>new_order</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.reorder_items" title="Permalink to this definition">¶</a></dt> +<dd><p>Apply a new order to mask items.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The variable name keyed in <code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</li> +<li><strong>new_order</strong> (<em>list of int</em><em>, </em><em>default None</em>) – The new order of the mask items. The included ints match up to +the number of the items (<code class="docutils literal"><span class="pre">DataSet.item_no('item_name')</span></code>).</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">DataSet is modified inplace.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.reorder_values"> +<code class="descname">reorder_values</code><span class="sig-paren">(</span><em>name</em>, <em>new_order=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.reorder_values" title="Permalink to this definition">¶</a></dt> +<dd><p>Apply a new order to the value codes defined by the meta data component.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code> or +<code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</li> +<li><strong>new_order</strong> (<em>list of int</em><em>, </em><em>default None</em>) – The new code order of the DataSet variable. If no order is given, +the <code class="docutils literal"><span class="pre">values</span></code> object is sorted ascending.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">DataSet is modified inplace.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.repair"> +<code class="descname">repair</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.repair" title="Permalink to this definition">¶</a></dt> +<dd><p>Try to fix legacy meta data inconsistencies and badly shaped array / +datafile items <code class="docutils literal"><span class="pre">'sets'</span></code> meta definitions.</p> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.repair_text_edits"> +<code class="descname">repair_text_edits</code><span class="sig-paren">(</span><em>text_key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.repair_text_edits" title="Permalink to this definition">¶</a></dt> +<dd><p>Cycle through all meta <code class="docutils literal"><span class="pre">text</span></code> objects repairing axis edits.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>text_key</strong> (<em>str / list of str</em><em>, </em><em>default None</em>) – {None, ‘en-GB’, ‘da-DK’, ‘fi-FI’, ‘nb-NO’, ‘sv-SE’, ‘de-DE’} +The text_keys for which text edits should be included.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">None</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.replace_texts"> +<code class="descname">replace_texts</code><span class="sig-paren">(</span><em>replace</em>, <em>text_key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.replace_texts" title="Permalink to this definition">¶</a></dt> +<dd><p>Cycle through all meta <code class="docutils literal"><span class="pre">text</span></code> objects replacing unwanted strings.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>replace</strong> (<em>dict</em><em>, </em><em>default Nonea</em>) – A dictionary mapping {unwanted string: replacement string}.</li> +<li><strong>text_key</strong> (<em>str / list of str</em><em>, </em><em>default None</em>) – {None, ‘en-GB’, ‘da-DK’, ‘fi-FI’, ‘nb-NO’, ‘sv-SE’, ‘de-DE’} +The text_keys for which unwanted strings are replaced.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.resolve_name"> +<code class="descname">resolve_name</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.resolve_name" title="Permalink to this definition">¶</a></dt> +<dd></dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.restore_item_texts"> +<code class="descname">restore_item_texts</code><span class="sig-paren">(</span><em>arrays=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.restore_item_texts" title="Permalink to this definition">¶</a></dt> +<dd><p>Restore array item texts.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>arrays</strong> (<em>str</em><em>, </em><em>list of str</em><em>, </em><em>default None</em>) – Restore texts for items of these arrays. If None, all keys in +<code class="docutils literal"><span class="pre">._meta['masks']</span></code> are taken.</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.revert"> +<code class="descname">revert</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.revert" title="Permalink to this definition">¶</a></dt> +<dd><p>Return to a previously saved state of the DataSet.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This method is designed primarily for use in interactive +Python environments like iPython/Jupyter and their notebook +applications.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.roll_up"> +<code class="descname">roll_up</code><span class="sig-paren">(</span><em>varlist</em>, <em>ignore_arrays=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.roll_up" title="Permalink to this definition">¶</a></dt> +<dd><p>Replace any array items with their parent mask variable definition name.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>varlist</strong> (<em>list</em>) – A list of meta <code class="docutils literal"><span class="pre">'columns'</span></code> and/or <code class="docutils literal"><span class="pre">'masks'</span></code> names.</li> +<li><strong>ignore_arrays</strong> (<em>(</em><em>list of</em><em>) </em><em>str</em>) – A list of array mask names that should not be rolled up if their +items are found inside <code class="docutils literal"><span class="pre">varlist</span></code>.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>rolled_up</strong> – The modified <code class="docutils literal"><span class="pre">varlist</span></code>.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.save"> +<code class="descname">save</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.save" title="Permalink to this definition">¶</a></dt> +<dd><p>Save the current state of the DataSet’s data and meta.</p> +<p>The saved file will be temporarily stored inside the cache. Use this +to take a snapshot of the DataSet state to easily revert back to at a +later stage.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This method is designed primarily for use in interactive +Python environments like iPython/Jupyter notebook applications.</p> +</div> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.select_text_keys"> +<code class="descname">select_text_keys</code><span class="sig-paren">(</span><em>text_key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.select_text_keys" title="Permalink to this definition">¶</a></dt> +<dd><p>Cycle through all meta <code class="docutils literal"><span class="pre">text</span></code> objects keep only selected text_key.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>text_key</strong> (<em>str / list of str</em><em>, </em><em>default None</em>) – {None, ‘en-GB’, ‘da-DK’, ‘fi-FI’, ‘nb-NO’, ‘sv-SE’, ‘de-DE’} +The text_keys which should be kept.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">None</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="classmethod"> +<dt id="quantipy.DataSet.set_encoding"> +<em class="property">classmethod </em><code class="descname">set_encoding</code><span class="sig-paren">(</span><em>encoding</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.set_encoding" title="Permalink to this definition">¶</a></dt> +<dd><p>Hack sys.setdefaultencoding() to escape ASCII hell.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>encoding</strong> (<em>str</em>) – The name of the encoding to default to.</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.set_factors"> +<code class="descname">set_factors</code><span class="sig-paren">(</span><em>name</em>, <em>factormap</em>, <em>safe=False</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.set_factors" title="Permalink to this definition">¶</a></dt> +<dd><p>Apply numerical factors to (<code class="docutils literal"><span class="pre">single</span></code>-type categorical) variables.</p> +<p>Factors can be read while aggregating descrp. stat. <code class="docutils literal"><span class="pre">qp.Views</span></code>.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code> or +<code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</li> +<li><strong>factormap</strong> (<em>dict</em>) – A mapping of <code class="docutils literal"><span class="pre">{value:</span> <span class="pre">factor}</span></code> (<code class="docutils literal"><span class="pre">int</span></code> to <code class="docutils literal"><span class="pre">int</span></code>).</li> +<li><strong>safe</strong> (<em>bool</em><em>, </em><em>default False</em>) – Set to <code class="docutils literal"><span class="pre">True</span></code> to prevent setting factors to the <code class="docutils literal"><span class="pre">values</span></code> meta +data of non-<code class="docutils literal"><span class="pre">single</span></code> type variables.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.set_item_texts"> +<code class="descname">set_item_texts</code><span class="sig-paren">(</span><em>name</em>, <em>renamed_items</em>, <em>text_key=None</em>, <em>axis_edit=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.set_item_texts" title="Permalink to this definition">¶</a></dt> +<dd><p>Rename or add item texts in the <code class="docutils literal"><span class="pre">items</span></code> objects of <code class="docutils literal"><span class="pre">masks</span></code>.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</li> +<li><strong>renamed_items</strong> (<em>dict</em>) – <p>A dict mapping with following structure (array mask items are +assumed to be passed by their order number):</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">{</span><span class="mi">1</span><span class="p">:</span> <span class="s1">'new label for item #1'</span><span class="p">,</span> +<span class="gp">... </span> <span class="mi">5</span><span class="p">:</span> <span class="s1">'new label for item #5'</span><span class="p">}</span> +</pre></div> +</div> +</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – Text key for text-based label information. Will automatically fall +back to the instance’s <code class="docutils literal"><span class="pre">text_key</span></code> property information if not +provided.</li> +<li><strong>axis_edit</strong> (<em>{'x'</em><em>, </em><em>'y'</em><em>, </em><em>[</em><em>'x'</em><em>, </em><em>'y'</em><em>]</em><em>}</em><em>, </em><em>default None</em>) – If the <code class="docutils literal"><span class="pre">new_text</span></code> of the variable should only be considered temp. +for build exports, the axes on that the edited text should appear +can be provided.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The <code class="docutils literal"><span class="pre">DataSet</span></code> is modified inplace.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.set_missings"> +<code class="descname">set_missings</code><span class="sig-paren">(</span><em>var</em>, <em>missing_map='default'</em>, <em>hide_on_y=True</em>, <em>ignore=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.set_missings" title="Permalink to this definition">¶</a></dt> +<dd><p>Flag category definitions for exclusion in aggregations.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>var</strong> (<em>str</em><em> or </em><em>list of str</em>) – Variable(s) to apply the meta flags to.</li> +<li><strong>missing_map</strong> (<em>'default'</em><em> or </em><em>list of codes</em><em> or </em><em>dict of {'flag': code</em><em>(</em><em>s</em><em>)</em><em>}</em><em>, </em><em>default 'default'</em>) – A mapping of codes to flags that can either be ‘exclude’ (globally +ignored) or ‘d.exclude’ (only ignored in descriptive statistics). +Codes provided in a list are flagged as ‘exclude’. +Passing ‘default’ is using a preset list of (TODO: specify) values +for exclusion.</li> +<li><strong>ignore</strong> (<em>str</em><em> or </em><em>list of str</em><em>, </em><em>default None</em>) – A list of variables that should be ignored when applying missing +flags via the ‘default’ list method.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.set_property"> +<code class="descname">set_property</code><span class="sig-paren">(</span><em>name</em>, <em>prop_name</em>, <em>prop_value</em>, <em>ignore_items=False</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.set_property" title="Permalink to this definition">¶</a></dt> +<dd><p>Access and set the value of a meta object’s <code class="docutils literal"><span class="pre">properties</span></code> collection.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The originating column variable name keyed in <code class="docutils literal"><span class="pre">meta['columns']</span></code> +or <code class="docutils literal"><span class="pre">meta['masks']</span></code>.</li> +<li><strong>prop_name</strong> (<em>str</em>) – The property key name.</li> +<li><strong>prop_value</strong> (<a class="reference internal" href="#quantipy.DataSet.any" title="quantipy.DataSet.any"><em>any</em></a>) – The value to be set for the property. Must be of valid type and +have allowed values(s) with regard to the property.</li> +<li><strong>ignore_items</strong> (<em>bool</em><em>, </em><em>default False</em>) – When <code class="docutils literal"><span class="pre">name</span></code> refers to a variable from the <code class="docutils literal"><span class="pre">'masks'</span></code> collection, +setting to True will ignore any <code class="docutils literal"><span class="pre">items</span></code> and only apply the +property to the <code class="docutils literal"><span class="pre">mask</span></code> itself.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.set_text_key"> +<code class="descname">set_text_key</code><span class="sig-paren">(</span><em>text_key</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.set_text_key" title="Permalink to this definition">¶</a></dt> +<dd><p>Set the default text_key of the <code class="docutils literal"><span class="pre">DataSet</span></code>.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">A lot of the instance methods will fall back to the default +text key in <code class="docutils literal"><span class="pre">_meta['lib']['default</span> <span class="pre">text']</span></code>. It is therefore +important to use this method with caution, i.e. ensure that the +meta contains <code class="docutils literal"><span class="pre">text</span></code> entries for the <code class="docutils literal"><span class="pre">text_key</span></code> set.</p> +</div> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>text_key</strong> (<em>{'en-GB'</em><em>, </em><em>'da-DK'</em><em>, </em><em>'fi-FI'</em><em>, </em><em>'nb-NO'</em><em>, </em><em>'sv-SE'</em><em>, </em><em>'de-DE'}</em>) – The text key that will be set in <code class="docutils literal"><span class="pre">_meta['lib']['default</span> <span class="pre">text']</span></code>.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">None</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.set_value_texts"> +<code class="descname">set_value_texts</code><span class="sig-paren">(</span><em>name</em>, <em>renamed_vals</em>, <em>text_key=None</em>, <em>axis_edit=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.set_value_texts" title="Permalink to this definition">¶</a></dt> +<dd><p>Rename or add value texts in the ‘values’ object.</p> +<p>This method works for array masks and column meta data.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code> or +<code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</li> +<li><strong>renamed_vals</strong> (<em>dict</em>) – A dict mapping with following structure: +<code class="docutils literal"><span class="pre">{1:</span> <span class="pre">'new</span> <span class="pre">label</span> <span class="pre">for</span> <span class="pre">code=1',</span> <span class="pre">5:</span> <span class="pre">'new</span> <span class="pre">label</span> <span class="pre">for</span> <span class="pre">code=5'}</span></code> +Codes will be ignored if they do not exist in the ‘values’ object.</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – Text key for text-based label information. Will automatically fall +back to the instance’s <code class="docutils literal"><span class="pre">text_key</span></code> property information if not +provided.</li> +<li><strong>axis_edit</strong> (<em>{'x'</em><em>, </em><em>'y'</em><em>, </em><em>[</em><em>'x'</em><em>, </em><em>'y'</em><em>]</em><em>}</em><em>, </em><em>default None</em>) – If <code class="docutils literal"><span class="pre">renamed_vals</span></code> should only be considered temp. for build +exports, the axes on that the edited text should appear can be +provided.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The <code class="docutils literal"><span class="pre">DataSet</span></code> is modified inplace.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.set_variable_text"> +<code class="descname">set_variable_text</code><span class="sig-paren">(</span><em>name</em>, <em>new_text</em>, <em>text_key=None</em>, <em>axis_edit=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.set_variable_text" title="Permalink to this definition">¶</a></dt> +<dd><p>Apply a new or update a column’s/masks’ meta text object.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The originating column variable name keyed in <code class="docutils literal"><span class="pre">meta['columns']</span></code> +or <code class="docutils literal"><span class="pre">meta['masks']</span></code>.</li> +<li><strong>new_text</strong> (<em>str</em>) – The <code class="docutils literal"><span class="pre">text</span></code> (label) to be set.</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – Text key for text-based label information. Will automatically fall +back to the instance’s text_key property information if not provided.</li> +<li><strong>axis_edit</strong> (<em>{'x'</em><em>, </em><em>'y'</em><em>, </em><em>[</em><em>'x'</em><em>, </em><em>'y'</em><em>]</em><em>}</em><em>, </em><em>default None</em>) – If the <code class="docutils literal"><span class="pre">new_text</span></code> of the variable should only be considered temp. +for build exports, the axes on that the edited text should appear +can be provided.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The <code class="docutils literal"><span class="pre">DataSet</span></code> is modified inplace.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.set_verbose_errmsg"> +<code class="descname">set_verbose_errmsg</code><span class="sig-paren">(</span><em>verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.set_verbose_errmsg" title="Permalink to this definition">¶</a></dt> +<dd></dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.set_verbose_infomsg"> +<code class="descname">set_verbose_infomsg</code><span class="sig-paren">(</span><em>verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.set_verbose_infomsg" title="Permalink to this definition">¶</a></dt> +<dd></dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.slicing"> +<code class="descname">slicing</code><span class="sig-paren">(</span><em>name</em>, <em>slicer</em>, <em>axis='y'</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.slicing" title="Permalink to this definition">¶</a></dt> +<dd><p>Set or update <code class="docutils literal"><span class="pre">rules[axis]['slicex']</span></code> meta for the named column.</p> +<p>Quantipy builds will respect the kept codes and <em>show them exclusively</em> +in results.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">This is not a replacement for <code class="docutils literal"><span class="pre">DataSet.set_missings()</span></code> as +missing values are respected also in computations.</p> +</div> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em><em> or </em><em>list of str</em>) – The column variable(s) name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code>.</li> +<li><strong>slice</strong> (<em>int</em><em> or </em><em>list of int</em>) – Values indicated by their <code class="docutils literal"><span class="pre">int</span></code> codes will be shown in +<code class="docutils literal"><span class="pre">Quantipy.View.dataframe</span></code>s, respecting the provided order.</li> +<li><strong>axis</strong> (<em>{'x'</em><em>, </em><em>'y'}</em><em>, </em><em>default 'y'</em>) – The axis to slice the values on.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.sorting"> +<code class="descname">sorting</code><span class="sig-paren">(</span><em>name</em>, <em>on='@'</em>, <em>within=False</em>, <em>between=False</em>, <em>fix=None</em>, <em>ascending=False</em>, <em>sort_by_weight=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.sorting" title="Permalink to this definition">¶</a></dt> +<dd><p>Set or update <code class="docutils literal"><span class="pre">rules['x']['sortx']</span></code> meta for the named column.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em><em> or </em><em>list of str</em>) – The column variable(s) name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code>.</li> +<li><strong>within</strong> (<em>bool</em><em>, </em><em>default True</em>) – Applies only to variables that have been aggregated by creating a +an <code class="docutils literal"><span class="pre">expand</span></code> grouping / overcode-style <code class="docutils literal"><span class="pre">View</span></code>: +If True, will sort frequencies inside each group.</li> +<li><strong>between</strong> (<em>bool</em><em>, </em><em>default True</em>) – Applies only to variables that have been aggregated by creating a +an <code class="docutils literal"><span class="pre">expand</span></code> grouping / overcode-style <code class="docutils literal"><span class="pre">View</span></code>: +If True, will sort group and regular code frequencies with regard +to each other.</li> +<li><strong>fix</strong> (<em>int</em><em> or </em><em>list of int</em><em>, </em><em>default None</em>) – Values indicated by their <code class="docutils literal"><span class="pre">int</span></code> codes will be ignored in +the sorting operation.</li> +<li><strong>ascending</strong> (<em>bool</em><em>, </em><em>default False</em>) – By default frequencies are sorted in descending order. Specify +<code class="docutils literal"><span class="pre">True</span></code> to sort ascending.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.sources"> +<code class="descname">sources</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.sources" title="Permalink to this definition">¶</a></dt> +<dd><p>Get the <code class="docutils literal"><span class="pre">_meta['columns']</span></code> elements for the passed array mask name.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>name</strong> (<em>str</em>) – The mask variable name keyed in <code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>sources</strong> – The list of source elements from the array definition.</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">list</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.split"> +<code class="descname">split</code><span class="sig-paren">(</span><em>save=False</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.split" title="Permalink to this definition">¶</a></dt> +<dd><p>Return the <code class="docutils literal"><span class="pre">meta</span></code> and <code class="docutils literal"><span class="pre">data</span></code> components of the DataSet instance.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>save</strong> (<em>bool</em><em>, </em><em>default False</em>) – If True, the <code class="docutils literal"><span class="pre">meta</span></code> and <code class="docutils literal"><span class="pre">data</span></code> objects will be saved to disk, +using the instance’s <code class="docutils literal"><span class="pre">name</span></code> and <code class="docutils literal"><span class="pre">path</span></code> attributes to determine +the file location.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>meta, data</strong> – The meta dict and the case data DataFrame as separate objects.</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">dict, pandas.DataFrame</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="staticmethod"> +<dt id="quantipy.DataSet.start_meta"> +<em class="property">static </em><code class="descname">start_meta</code><span class="sig-paren">(</span><em>text_key='main'</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.start_meta" title="Permalink to this definition">¶</a></dt> +<dd><p>Starts a new/empty Quantipy meta document.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – The default text key to be set into the new meta document.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>meta</strong> – Quantipy meta object</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">dict</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.subset"> +<code class="descname">subset</code><span class="sig-paren">(</span><em>variables=None</em>, <em>from_set=None</em>, <em>inplace=False</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.subset" title="Permalink to this definition">¶</a></dt> +<dd><p>Create a cloned version of self with a reduced collection of variables.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>variables</strong> (<em>str</em><em> or </em><em>list of str</em><em>, </em><em>default None</em>) – A list of variable names to include in the new DataSet instance.</li> +<li><strong>from_set</strong> (<em>str</em>) – The name of an already existing set to base the new DataSet on.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>subset_ds</strong> – The new reduced version of the DataSet.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">qp.DataSet</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.take"> +<code class="descname">take</code><span class="sig-paren">(</span><em>condition</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.take" title="Permalink to this definition">¶</a></dt> +<dd><p>Create an index slicer to select rows from the DataFrame component.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>condition</strong> (<em>Quantipy logic expression</em>) – A logical condition expressed as Quantipy logic that determines +which subset of the case data rows to be kept.</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>slicer</strong> – The indices fulfilling the passed logical condition.</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">pandas.Index</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.text"> +<code class="descname">text</code><span class="sig-paren">(</span><em>name</em>, <em>shorten=True</em>, <em>text_key=None</em>, <em>axis_edit=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.text" title="Permalink to this definition">¶</a></dt> +<dd><p>Return the variables text label information.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em><em>, </em><em>default None</em>) – The variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code> or <code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</li> +<li><strong>shorten</strong> (<em>bool</em><em>, </em><em>default True</em>) – If True, <code class="docutils literal"><span class="pre">text</span></code> label meta from array items will not report +the parent mask’s <code class="docutils literal"><span class="pre">text</span></code>. Setting it to False will show the +“full” label.</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – The default text key to be set into the new meta document.</li> +<li><strong>axis_edit</strong> (<em>{'x'</em><em>, </em><em>'y'}</em><em>, </em><em>default None</em>) – If provided the text_key is taken from the x/y edits dict.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>text</strong> – The text metadata.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">str</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.to_array"> +<code class="descname">to_array</code><span class="sig-paren">(</span><em>name</em>, <em>variables</em>, <em>label</em>, <em>safe=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.to_array" title="Permalink to this definition">¶</a></dt> +<dd><p>Combines column variables with same <code class="docutils literal"><span class="pre">values</span></code> meta into an array.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – Name of new grid.</li> +<li><strong>variables</strong> (<em>list of str</em><em> or </em><em>list of dicts</em>) – Variable names that become items of the array. New item labels can +be added as dict. Example: +variables = [‘q1_1’, {‘q1_2’: ‘shop 2’}, {‘q1_3’: ‘shop 3’}]</li> +<li><strong>label</strong> (<em>str</em>) – Text label for the mask itself.</li> +<li><strong>safe</strong> (<em>bool</em><em>, </em><em>default True</em>) – If True, the method will raise a <code class="docutils literal"><span class="pre">ValueError</span></code> if the provided +variable name is already present in self. Select <code class="docutils literal"><span class="pre">False</span></code> to +forcefully overwrite an existing variable with the same name +(independent of its type).</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.to_delimited_set"> +<code class="descname">to_delimited_set</code><span class="sig-paren">(</span><em>name</em>, <em>label</em>, <em>variables</em>, <em>from_dichotomous=True</em>, <em>codes_from_name=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.to_delimited_set" title="Permalink to this definition">¶</a></dt> +<dd><p>Combines multiple single variables to new delimited set variable.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – Name of new delimited set</li> +<li><strong>label</strong> (<em>str</em>) – Label text for the new delimited set.</li> +<li><strong>variables</strong> (<em>list of str</em><em> or </em><em>list of tuples</em>) – variables that get combined into the new delimited set. If they are +dichotomous (from_dichotomous=True), the labels of the variables +are used as category texts or if tuples are included, the second +items will be used for the category texts. +If the variables are categorical (from_dichotomous=False) the values +of the variables need to be eqaul and are taken for the delimited set.</li> +<li><strong>from_dichotomous</strong> (<em>bool</em><em>, </em><em>default True</em>) – Define if the input variables are dichotomous or categorical.</li> +<li><strong>codes_from_name</strong> (<em>bool</em><em>, </em><em>default True</em>) – If from_dichotomous=True, the codes can be taken from the Variable +names, if they are in form of ‘q01_1’, ‘q01_3’, … +In this case the codes will be 1, 3, ….</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.transpose"> +<code class="descname">transpose</code><span class="sig-paren">(</span><em>name</em>, <em>new_name=None</em>, <em>ignore_items=None</em>, <em>ignore_values=None</em>, <em>copy_data=True</em>, <em>text_key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.transpose" title="Permalink to this definition">¶</a></dt> +<dd><p>Create a new array mask with transposed items / values structure.</p> +<p>This method will automatically create meta and case data additions in +the <code class="docutils literal"><span class="pre">DataSet</span></code> instance.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The originating mask variable name keyed in <code class="docutils literal"><span class="pre">meta['masks']</span></code>.</li> +<li><strong>new_name</strong> (<em>str</em><em>, </em><em>default None</em>) – The name of the new mask. If not provided explicitly, the new_name +will be constructed constructed by suffixing the original +<code class="docutils literal"><span class="pre">name</span></code> with ‘_trans’, e.g. <code class="docutils literal"><span class="pre">'Q2Array_trans</span></code>.</li> +<li><strong>ignore_items</strong> (<em>int</em><em> or </em><em>list of int</em><em>, </em><em>default None</em>) – If provided, the items listed by their order number in the +<code class="docutils literal"><span class="pre">_meta['masks'][name]['items']</span></code> object will not be part of the +transposed array. This means they will be ignored while creating +the new value codes meta.</li> +<li><strong>ignore_codes</strong> (<em>int</em><em> or </em><em>list of int</em><em>, </em><em>default None</em>) – If provided, the listed code values will not be part of the +transposed array. This means they will not be part of the new +item meta.</li> +<li><strong>text_key</strong> (<em>str</em>) – The text key to be used when generating text objects, i.e. +item and value labels.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">DataSet is modified inplace.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.unbind"> +<code class="descname">unbind</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.unbind" title="Permalink to this definition">¶</a></dt> +<dd><p>Remove mask-structure for arrays</p> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.uncode"> +<code class="descname">uncode</code><span class="sig-paren">(</span><em>target</em>, <em>mapper</em>, <em>default=None</em>, <em>intersect=None</em>, <em>inplace=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.uncode" title="Permalink to this definition">¶</a></dt> +<dd><p>Create a new or copied series from data, recoded using a mapper.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>target</strong> (<em>str</em>) – The variable name that is the target of the uncode. If it is keyed +in <code class="docutils literal"><span class="pre">_meta['masks']</span></code> the uncode is done for all mask items. +If not found in <code class="docutils literal"><span class="pre">_meta</span></code> this will fail with an error.</li> +<li><strong>mapper</strong> (<em>dict</em>) – A mapper of {key: logic} entries.</li> +<li><strong>default</strong> (<em>str</em><em>, </em><em>default None</em>) – The column name to default to in cases where unattended lists +are given in your logic, where an auto-transformation of +{key: list} to {key: {default: list}} is provided. Note that +lists in logical statements are themselves a form of shorthand +and this will ultimately be interpreted as: +{key: {default: has_any(list)}}.</li> +<li><strong>intersect</strong> (<em>logical statement</em><em>, </em><em>default None</em>) – If a logical statement is given here then it will be used as an +implied intersection of all logical conditions given in the +mapper.</li> +<li><strong>inplace</strong> (<em>bool</em><em>, </em><em>default True</em>) – If True, the <code class="docutils literal"><span class="pre">DataSet</span></code> will be modified inplace with new/updated +columns. Will return a new recoded <code class="docutils literal"><span class="pre">pandas.Series</span></code> instance if +False.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Either the <code class="docutils literal"><span class="pre">DataSet._data</span></code> is modified inplace or a new +<code class="docutils literal"><span class="pre">pandas.Series</span></code> is returned.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None or uncode_series</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.undimensionize"> +<code class="descname">undimensionize</code><span class="sig-paren">(</span><em>names=None</em>, <em>mapper_to_meta=False</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.undimensionize" title="Permalink to this definition">¶</a></dt> +<dd><p>Rename the dataset columns to remove Dimensions compatibility.</p> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.undimensionizing_mapper"> +<code class="descname">undimensionizing_mapper</code><span class="sig-paren">(</span><em>names=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.undimensionizing_mapper" title="Permalink to this definition">¶</a></dt> +<dd><p>Return a renaming dataset mapper for un-dimensionizing names.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>None</strong> – </td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>mapper</strong> – A renaming mapper in the form of a dict of {old: new} that +maps Dimensions naming conventions to non-Dimensions naming +conventions.</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">dict</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.unify_values"> +<code class="descname">unify_values</code><span class="sig-paren">(</span><em>name</em>, <em>code_map</em>, <em>slicer=None</em>, <em>exclusive=False</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.unify_values" title="Permalink to this definition">¶</a></dt> +<dd><p>Use a mapping of old to new codes to replace code values in <code class="docutils literal"><span class="pre">_data</span></code>.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Experimental! Check results carefully!</p> +</div> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">meta['columns']</span></code>.</li> +<li><strong>code_map</strong> (<em>dict</em>) – A mapping of <code class="docutils literal"><span class="pre">{old:</span> <span class="pre">new}</span></code>; <code class="docutils literal"><span class="pre">old</span></code> and <code class="docutils literal"><span class="pre">new</span></code> must be the +int-type code values from the column meta data.</li> +<li><strong>slicer</strong> (<em>Quantipy logic statement</em><em>, </em><em>default None</em>) – If provided, the values will only be unified for cases where the +condition holds.</li> +<li><strong>exclusive</strong> (<em>bool</em><em>, </em><em>default False</em>) – If True, the recoded unified value will replace whatever is already +found in the <code class="docutils literal"><span class="pre">_data</span></code> column, ignoring <code class="docutils literal"><span class="pre">delimited</span> <span class="pre">set</span></code> typed data +to which normally would get appended to.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.unroll"> +<code class="descname">unroll</code><span class="sig-paren">(</span><em>varlist</em>, <em>keep=None</em>, <em>both=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.unroll" title="Permalink to this definition">¶</a></dt> +<dd><p>Replace mask with their items, optionally excluding/keeping certain ones.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>varlist</strong> (<em>list</em>) – A list of meta <code class="docutils literal"><span class="pre">'columns'</span></code> and/or <code class="docutils literal"><span class="pre">'masks'</span></code> names.</li> +<li><strong>keep</strong> (<em>str</em><em> or </em><em>list</em><em>, </em><em>default None</em>) – The names of masks that will not be replaced with their items.</li> +<li><strong>both</strong> (<em>'all'</em><em>, </em><em>str</em><em> or </em><em>list of str</em><em>, </em><em>default None</em>) – The names of masks that will be included both as themselves and as +collections of their items.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>unrolled</strong> – The modified <code class="docutils literal"><span class="pre">varlist</span></code>.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.update"> +<code class="descname">update</code><span class="sig-paren">(</span><em>data</em>, <em>on='identity'</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.update" title="Permalink to this definition">¶</a></dt> +<dd><p>Update the <code class="docutils literal"><span class="pre">DataSet</span></code> with the case data entries found in <code class="docutils literal"><span class="pre">data</span></code>.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>data</strong> (<code class="docutils literal"><span class="pre">pandas.DataFrame</span></code>) – A dataframe that contains a subset of columns from the <code class="docutils literal"><span class="pre">DataSet</span></code> +case data component.</li> +<li><strong>on</strong> (<em>str</em><em>, </em><em>default 'identity'</em>) – The column to use as a join key.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">DataSet is modified inplace.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.validate"> +<code class="descname">validate</code><span class="sig-paren">(</span><em>spss_limits=False</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.validate" title="Permalink to this definition">¶</a></dt> +<dd><p>Identify and report inconsistencies in the <code class="docutils literal"><span class="pre">DataSet</span></code> instance.</p> +<dl class="docutils"> +<dt>name:</dt> +<dd>column/mask name and <code class="docutils literal"><span class="pre">meta[collection][var]['name']</span></code> are not identical</dd> +<dt>q_label:</dt> +<dd>text object is badly formatted or has empty text mapping</dd> +<dt>values:</dt> +<dd>categorical variable does not contain values, value text is badly +formatted or has empty text mapping</dd> +<dt>text_keys:</dt> +<dd>dataset.text_key is not included or existing text keys are not +consistent (also for parents)</dd> +<dt>source:</dt> +<dd>parents or items do not exist</dd> +<dt>codes:</dt> +<dd>codes in data component are not included in meta component</dd> +<dt>spss limit name:</dt> +<dd>length of name is greater than spss limit (64 characters) +(only shown if spss_limits=True)</dd> +<dt>spss limit q_label:</dt> +<dd>length of q_label is greater than spss limit (256 characters) +(only shown if spss_limits=True)</dd> +<dt>spss limit values:</dt> +<dd>length of any value text is greater than spss limit (120 characters) +(only shown if spss_limits=True)</dd> +</dl> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.value_texts"> +<code class="descname">value_texts</code><span class="sig-paren">(</span><em>name</em>, <em>text_key=None</em>, <em>axis_edit=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.value_texts" title="Permalink to this definition">¶</a></dt> +<dd><p>Get categorical data’s text information.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code>.</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – The text_key that should be used when taking labels from the +source meta.</li> +<li><strong>axis_edit</strong> (<em>{'x'</em><em>, </em><em>'y'}</em><em>, </em><em>default None</em>) – If provided the text_key is taken from the x/y edits dict.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>texts</strong> – The list of category texts.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.values"> +<code class="descname">values</code><span class="sig-paren">(</span><em>name</em>, <em>text_key=None</em>, <em>axis_edit=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.values" title="Permalink to this definition">¶</a></dt> +<dd><p>Get categorical data’s paired code and texts information from the meta.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>name</strong> (<em>str</em>) – The column variable name keyed in <code class="docutils literal"><span class="pre">_meta['columns']</span></code> or +<code class="docutils literal"><span class="pre">_meta['masks']</span></code>.</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – The text_key that should be used when taking labels from the +source meta.</li> +<li><strong>axis_edit</strong> (<em>{'x'</em><em>, </em><em>'y'}</em><em>, </em><em>default None</em>) – If provided the text_key is taken from the x/y edits dict.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>values</strong> – The list of the numerical category codes and their <code class="docutils literal"><span class="pre">texts</span></code> +packed as tuples.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list of tuples</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.variables"> +<code class="descname">variables</code><span class="sig-paren">(</span><em>setname='data file'</em>, <em>numeric=True</em>, <em>string=True</em>, <em>date=True</em>, <em>boolean=True</em>, <em>blacklist=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.variables" title="Permalink to this definition">¶</a></dt> +<dd><p>View all DataSet variables listed in their global order.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>setname</strong> (<em>str</em><em>, </em><em>default 'data file'</em>) – The name of the variable set to query. Defaults to the main +variable collection stored via ‘data file’.</li> +<li><strong>numeric</strong> (<em>bool</em><em>, </em><em>default True</em>) – Include <code class="docutils literal"><span class="pre">int</span></code> and <code class="docutils literal"><span class="pre">float</span></code> type variables?</li> +<li><strong>string</strong> (<em>bool</em><em>, </em><em>default True</em>) – Include <code class="docutils literal"><span class="pre">string</span></code> type variables?</li> +<li><strong>date</strong> (<em>bool</em><em>, </em><em>default True</em>) – Include <code class="docutils literal"><span class="pre">date</span></code> type variables?</li> +<li><strong>boolean</strong> (<em>bool</em><em>, </em><em>default True</em>) – Include <code class="docutils literal"><span class="pre">boolean</span></code> type variables?</li> +<li><strong>blacklist</strong> (<em>list</em><em>, </em><em>default None</em>) – A list of variables names to exclude from the variable listing.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>varlist</strong> – The list of variables registered in the queried <code class="docutils literal"><span class="pre">set</span></code>.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.vmerge"> +<code class="descname">vmerge</code><span class="sig-paren">(</span><em>dataset</em>, <em>on=None</em>, <em>left_on=None</em>, <em>right_on=None</em>, <em>row_id_name=None</em>, <em>left_id=None</em>, <em>right_id=None</em>, <em>row_ids=None</em>, <em>overwrite_text=False</em>, <em>from_set=None</em>, <em>uniquify_key=None</em>, <em>reset_index=True</em>, <em>inplace=True</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.vmerge" title="Permalink to this definition">¶</a></dt> +<dd><p>Merge Quantipy datasets together by appending rows.</p> +<p>This function merges two Quantipy datasets together, updating variables +that exist in the left dataset and appending others. New variables +will be appended in the order indicated by the ‘data file’ set if +found, otherwise they will be appended in alphanumeric order. This +merge happens vertically (row-wise).</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>dataset</strong> ((A list of multiple) <code class="docutils literal"><span class="pre">quantipy.DataSet</span></code>) – One or multiple datasets to merge into the current <code class="docutils literal"><span class="pre">DataSet</span></code>.</li> +<li><strong>on</strong> (<em>str</em><em>, </em><em>default=None</em>) – The column to use to identify unique rows in both datasets.</li> +<li><strong>left_on</strong> (<em>str</em><em>, </em><em>default=None</em>) – The column to use to identify unique in the left dataset.</li> +<li><strong>right_on</strong> (<em>str</em><em>, </em><em>default=None</em>) – The column to use to identify unique in the right dataset.</li> +<li><strong>row_id_name</strong> (<em>str</em><em>, </em><em>default=None</em>) – The named column will be filled with the ids indicated for each +dataset, as per left_id/right_id/row_ids. If meta for the named +column doesn’t already exist a new column definition will be +added and assigned a reductive-appropriate type.</li> +<li><strong>left_id</strong> (<em>str/int/float</em><em>, </em><em>default=None</em>) – Where the row_id_name column is not already populated for the +dataset_left, this value will be populated.</li> +<li><strong>right_id</strong> (<em>str/int/float</em><em>, </em><em>default=None</em>) – Where the row_id_name column is not already populated for the +dataset_right, this value will be populated.</li> +<li><strong>row_ids</strong> (<em>list of str/int/float</em><em>, </em><em>default=None</em>) – When datasets has been used, this list provides the row ids +that will be populated in the row_id_name column for each of +those datasets, respectively.</li> +<li><strong>overwrite_text</strong> (<em>bool</em><em>, </em><em>default=False</em>) – If True, text_keys in the left meta that also exist in right +meta will be overwritten instead of ignored.</li> +<li><strong>from_set</strong> (<em>str</em><em>, </em><em>default=None</em>) – Use a set defined in the right meta to control which columns are +merged from the right dataset.</li> +<li><strong>uniquify_key</strong> (<em>str</em><em>, </em><em>default None</em>) – A int-like column name found in all the passed <code class="docutils literal"><span class="pre">DataSet</span></code> objects +that will be protected from having duplicates. The original version +of the column will be kept under its name prefixed with ‘original’.</li> +<li><strong>reset_index</strong> (<em>bool</em><em>, </em><em>default=True</em>) – If True pandas.DataFrame.reindex() will be applied to the merged +dataframe.</li> +<li><strong>inplace</strong> (<em>bool</em><em>, </em><em>default True</em>) – If True, the <code class="docutils literal"><span class="pre">DataSet</span></code> will be modified inplace with new/updated +rows. Will return a new <code class="docutils literal"><span class="pre">DataSet</span></code> instance if False.</li> +<li><strong>verbose</strong> (<em>bool</em><em>, </em><em>default=True</em>) – Echo progress feedback to the output pane.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>None or new_dataset</strong> – If the merge is not applied <code class="docutils literal"><span class="pre">inplace</span></code>, a <code class="docutils literal"><span class="pre">DataSet</span></code> instance +is returned.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><code class="docutils literal"><span class="pre">quantipy.DataSet</span></code></p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.weight"> +<code class="descname">weight</code><span class="sig-paren">(</span><em>weight_scheme</em>, <em>weight_name='weight'</em>, <em>unique_key='identity'</em>, <em>subset=None</em>, <em>report=True</em>, <em>path_report=None</em>, <em>inplace=True</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.weight" title="Permalink to this definition">¶</a></dt> +<dd><p>Weight the <code class="docutils literal"><span class="pre">DataSet</span></code> according to a well-defined weight scheme.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>weight_scheme</strong> (<em>quantipy.Rim instance</em>) – A rim weights setup with defined targets. Can include multiple +weight groups and/or filters.</li> +<li><strong>weight_name</strong> (<em>str</em><em>, </em><em>default 'weight'</em>) – A name for the float variable that is added to pick up the weight +factors.</li> +<li><strong>unique_key</strong> (<em>str</em><em>, </em><em>default 'identity'.</em>) – A variable inside the <code class="docutils literal"><span class="pre">DataSet</span></code> instance that will be used to +the map individual case weights to their matching rows.</li> +<li><strong>subset</strong> (<em>Quantipy complex logic expression</em>) – A logic to filter the DataSet, weighting only the remaining subset.</li> +<li><strong>report</strong> (<em>bool</em><em>, </em><em>default True</em>) – If True, will report a summary of the weight algorithm run +and factor outcomes.</li> +<li><strong>path_report</strong> (<em>str</em><em>, </em><em>default None</em>) – A file path to save an .xlsx version of the weight report to.</li> +<li><strong>inplace</strong> (<em>bool</em><em>, </em><em>default True</em>) – If True, the weight factors are merged back into the <code class="docutils literal"><span class="pre">DataSet</span></code> +instance. Will otherwise return the <code class="docutils literal"><span class="pre">pandas.DataFrame</span></code> that +contains the weight factors, the <code class="docutils literal"><span class="pre">unique_key</span></code> and all variables +that have been used to compute the weights (filters, target +variables, etc.).</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Will either create a new column called <code class="docutils literal"><span class="pre">'weight'</span></code> in the +<code class="docutils literal"><span class="pre">DataSet</span></code> instance or return a <code class="docutils literal"><span class="pre">DataFrame</span></code> that contains +the weight factors.</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">None or <code class="docutils literal"><span class="pre">pandas.DataFrame</span></code></p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.write_dimensions"> +<code class="descname">write_dimensions</code><span class="sig-paren">(</span><em>path_mdd=None</em>, <em>path_ddf=None</em>, <em>text_key=None</em>, <em>run=True</em>, <em>clean_up=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.write_dimensions" title="Permalink to this definition">¶</a></dt> +<dd><p>Build Dimensions/SPSS Base Professional .ddf/.mdd data pairs.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">SPSS Data Collection Base Professional must be installed on +the machine. The method is creating .mrs and .dms scripts which are +executed through the software’s API.</p> +</div> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>path_mdd</strong> (<em>str</em><em>, </em><em>default None</em>) – The full path (optionally with extension <code class="docutils literal"><span class="pre">'.mdd'</span></code>, otherwise +assumed as such) for the saved the DataSet._meta component. +If not provided, the instance’s <code class="docutils literal"><span class="pre">name</span></code> and <code class="docutils literal"><span class="pre">`path</span></code> attributes +will be used to determine the file location.</li> +<li><strong>path_ddf</strong> (<em>str</em><em>, </em><em>default None</em>) – The full path (optionally with extension <code class="docutils literal"><span class="pre">'.ddf'</span></code>, otherwise +assumed as such) for the saved DataSet._data component. +If not provided, the instance’s <code class="docutils literal"><span class="pre">name</span></code> and <code class="docutils literal"><span class="pre">`path</span></code> attributes +will be used to determine the file location.</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – The desired <code class="docutils literal"><span class="pre">text_key</span></code> for all <code class="docutils literal"><span class="pre">text</span></code> label information. Uses +the <code class="docutils literal"><span class="pre">DataSet.text_key</span></code> information if not provided.</li> +<li><strong>run</strong> (<em>bool</em><em>, </em><em>default True</em>) – If True, the method will try to run the metadata creating .mrs +script and execute a DMSRun for the case data transformation in +the .dms file.</li> +<li><strong>clean_up</strong> (<em>bool</em><em>, </em><em>default True</em>) – By default, all helper files from the conversion (.dms, .mrs, +paired .csv files, etc.) will be deleted after the process has +finished.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">A .ddf/.mdd pair is saved at the provided path location.</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.write_quantipy"> +<code class="descname">write_quantipy</code><span class="sig-paren">(</span><em>path_meta=None</em>, <em>path_data=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.write_quantipy" title="Permalink to this definition">¶</a></dt> +<dd><p>Write the data and meta components to .csv/.json files.</p> +<p>The resulting files are well-defined native Quantipy source files.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>path_meta</strong> (<em>str</em><em>, </em><em>default None</em>) – The full path (optionally with extension <code class="docutils literal"><span class="pre">'.json'</span></code>, otherwise +assumed as such) for the saved the DataSet._meta component. +If not provided, the instance’s <code class="docutils literal"><span class="pre">name</span></code> and <code class="docutils literal"><span class="pre">`path</span></code> attributes +will be used to determine the file location.</li> +<li><strong>path_data</strong> (<em>str</em><em>, </em><em>default None</em>) – The full path (optionally with extension <code class="docutils literal"><span class="pre">'.csv'</span></code>, otherwise +assumed as such) for the saved DataSet._data component. +If not provided, the instance’s <code class="docutils literal"><span class="pre">name</span></code> and <code class="docutils literal"><span class="pre">`path</span></code> attributes +will be used to determine the file location.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">A .csv/.json pair is saved at the provided path location.</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +<dl class="method"> +<dt id="quantipy.DataSet.write_spss"> +<code class="descname">write_spss</code><span class="sig-paren">(</span><em>path_sav=None</em>, <em>index=True</em>, <em>text_key=None</em>, <em>mrset_tag_style='__'</em>, <em>drop_delimited=True</em>, <em>from_set=None</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.DataSet.write_spss" title="Permalink to this definition">¶</a></dt> +<dd><p>Convert the Quantipy DataSet into a SPSS .sav data file.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>path_sav</strong> (<em>str</em><em>, </em><em>default None</em>) – The full path (optionally with extension <code class="docutils literal"><span class="pre">'.json'</span></code>, otherwise +assumed as such) for the saved the DataSet._meta component. +If not provided, the instance’s <code class="docutils literal"><span class="pre">name</span></code> and <code class="docutils literal"><span class="pre">`path</span></code> attributes +will be used to determine the file location.</li> +<li><strong>index</strong> (<em>bool</em><em>, </em><em>default False</em>) – Should the index be inserted into the dataframe before the +conversion happens?</li> +<li><strong>text_key</strong> (<em>str</em><em>, </em><em>default None</em>) – The text_key that should be used when taking labels from the +source meta. If the given text_key is not found for any +particular text object, the <code class="docutils literal"><span class="pre">DataSet.text_key</span></code> will be used +instead.</li> +<li><strong>mrset_tag_style</strong> (<em>str</em><em>, </em><em>default '__'</em>) – The delimiting character/string to use when naming dichotomous +set variables. The mrset_tag_style will appear between the +name of the variable and the dichotomous variable’s value name, +as taken from the delimited set value that dichotomous +variable represents.</li> +<li><strong>drop_delimited</strong> (<em>bool</em><em>, </em><em>default True</em>) – Should Quantipy’s delimited set variables be dropped from +the export after being converted to dichotomous sets/mrsets?</li> +<li><strong>from_set</strong> (<em>str</em>) – The set name from which the export should be drawn.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">A SPSS .sav file is saved at the provided path location.</p> +</td> +</tr> +</tbody> +</table> +</dd></dl> + +</dd></dl> + +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="quantify_engine.html" class="btn btn-neutral float-right" title="quantify.engine" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="Cluster.html" class="btn btn-neutral" title="Cluster" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../_static/jquery.js"></script> + <script type="text/javascript" src="../../_static/underscore.js"></script> + <script type="text/javascript" src="../../_static/doctools.js"></script> + <script type="text/javascript" src="../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/api_ref/QuantipyViews.html b/docs/API/_build/html/sites/api_ref/QuantipyViews.html index 1e9618ed7..74a7eb22b 100644 --- a/docs/API/_build/html/sites/api_ref/QuantipyViews.html +++ b/docs/API/_build/html/sites/api_ref/QuantipyViews.html @@ -92,9 +92,18 @@ <h3>Quick search</h3> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../release_notes/00_overview.html">Release notes</a><ul> -<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Upcoming (September 2017)</a></li> -<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html#latest-31-08-2017">Latest (31/08/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Latest (01/10/2018)</a></li> <li class="toctree-l2"><a class="reference internal" href="../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> @@ -195,7 +204,7 @@ <h3>Quick search</h3> <li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> -<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> @@ -292,6 +301,7 @@ <h3>Quick search</h3> <li class="toctree-l2"><a class="reference internal" href="quantify_engine.html">quantify.engine</a></li> <li class="toctree-l2 current"><a class="current reference internal" href="#">QuantipyViews</a></li> <li class="toctree-l2"><a class="reference internal" href="Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="Stack.html">Stack</a></li> <li class="toctree-l2"><a class="reference internal" href="View.html">View</a></li> <li class="toctree-l2"><a class="reference internal" href="ViewMapper.html">ViewMapper</a></li> </ul> @@ -364,34 +374,34 @@ <h1>QuantipyViews<a class="headerlink" href="#quantipyviews" title="Permalink to <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>link</strong> (<em>Quantipy Link object.</em>) – </li> -<li><strong>name</strong> (<em>str</em>) – The shortname applied to the view.</li> -<li><strong>kwargs</strong> (<em>dict</em>) – </li> -<li><strong>arguments</strong><strong> (</strong><strong>specific</strong><strong>)</strong><strong></strong> (<em>Keyword</em>) – </li> -<li><strong>text</strong> (<em>str</em><em>, </em><em>optional</em><em>, </em><em>default None</em>) – Sets an optional label in the meta component of the view that is +<li><strong>link</strong> (<em>Quantipy Link object.</em>) – </li> +<li><strong>name</strong> (<em>str</em>) – The shortname applied to the view.</li> +<li><strong>kwargs</strong> (<em>dict</em>) – </li> +<li><strong>arguments</strong><strong> (</strong><strong>specific</strong><strong>)</strong> (<em>Keyword</em>) – </li> +<li><strong>text</strong> (<em>str</em><em>, </em><em>optional</em><em>, </em><em>default None</em>) – 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).</li> -<li><strong>metric</strong> (<em>{'props'</em><em>, </em><em>'means'}</em><em>, </em><em>default 'props'</em>) – Determines whether a proportion or means test algorithm is +<li><strong>metric</strong> (<em>{'props'</em><em>, </em><em>'means'}</em><em>, </em><em>default 'props'</em>) – Determines whether a proportion or means test algorithm is performed.</li> -<li><strong>test_total</strong> (<em>bool</em><em>, </em><em>deafult False</em>) – If True, the each View’s y-axis column will be tested against the +<li><strong>test_total</strong> (<em>bool</em><em>, </em><em>deafult False</em>) – If True, the each View’s y-axis column will be tested against the uncoditional total of its x-axis.</li> -<li><strong>mimic</strong> (<em>{'Dim'</em><em>, </em><em>'askia'}</em><em>, </em><em>default 'Dim'</em>) – It is possible to mimic the test logics used in other statistical +<li><strong>mimic</strong> (<em>{'Dim'</em><em>, </em><em>'askia'}</em><em>, </em><em>default 'Dim'</em>) – 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.</li> -<li><strong>level</strong> (<em>{'high'</em><em>, </em><em>'mid'</em><em>, </em><em>'low'}</em><em> or </em><em>float</em>) – Sets the level of significance to which the test is carried out. +<li><strong>level</strong> (<em>{'high'</em><em>, </em><em>'mid'</em><em>, </em><em>'low'}</em><em> or </em><em>float</em>) – Sets the level of significance to which the test is carried out. Given as str the levels correspond to <code class="docutils literal"><span class="pre">'high'</span></code> = 0.01, <code class="docutils literal"><span class="pre">'mid'</span></code> = 0.05 and <code class="docutils literal"><span class="pre">'low'</span></code> = 0.1. If a float is passed the specified level will be used.</li> -<li><strong>flags</strong> (<em>list of two int</em><em>, </em><em>default None</em>) – Base thresholds for Dimensions-like tests, e.g. [30, 100]. First +<li><strong>flags</strong> (<em>list of two int</em><em>, </em><em>default None</em>) – Base thresholds for Dimensions-like tests, e.g. [30, 100]. First int is minimum base for reported results, second int controls small base indication.</li> </ul> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><ul class="simple"> -<li><em>None</em> – Adds requested View to the Stack, storing it under the full +<li><em>None</em> – Adds requested View to the Stack, storing it under the full view name notation key.</li> -<li><em>.. note::</em> – Mimicking the askia software (<code class="docutils literal"><span class="pre">mimic</span></code> = <code class="docutils literal"><span class="pre">'askia'</span></code>) +<li><em>.. note::</em> – Mimicking the askia software (<code class="docutils literal"><span class="pre">mimic</span></code> = <code class="docutils literal"><span class="pre">'askia'</span></code>) restricts the values to be one of <code class="docutils literal"><span class="pre">'high'</span></code>, <code class="docutils literal"><span class="pre">'low'</span></code>, <code class="docutils literal"><span class="pre">'mid'</span></code>. Any other value passed will make the algorithm fall back to <code class="docutils literal"><span class="pre">'low'</span></code>. Mimicking Dimensions (<code class="docutils literal"><span class="pre">mimic</span></code> = @@ -416,9 +426,9 @@ <h1>QuantipyViews<a class="headerlink" href="#quantipyviews" title="Permalink to <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>link</strong> (<em>Quantipy Link object.</em>) – </li> -<li><strong>name</strong> (<em>str</em>) – The shortname applied to the view.</li> -<li><strong>kwargs</strong> (<em>dict</em>) – </li> +<li><strong>link</strong> (<em>Quantipy Link object.</em>) – </li> +<li><strong>name</strong> (<em>str</em>) – The shortname applied to the view.</li> +<li><strong>kwargs</strong> (<em>dict</em>) – </li> </ul> </td> </tr> @@ -444,16 +454,16 @@ <h1>QuantipyViews<a class="headerlink" href="#quantipyviews" title="Permalink to <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>link</strong> (<em>Quantipy Link object.</em>) – </li> -<li><strong>name</strong> (<em>str</em>) – The shortname applied to the view.</li> -<li><strong>kwargs</strong> (<em>dict</em>) – </li> -<li><strong>arguments</strong><strong> (</strong><strong>specific</strong><strong>)</strong><strong></strong> (<em>Keyword</em>) – </li> -<li><strong>text</strong> (<em>str</em><em>, </em><em>optional</em><em>, </em><em>default None</em>) – Sets an optional label suffix for the meta component of the view +<li><strong>link</strong> (<em>Quantipy Link object.</em>) – </li> +<li><strong>name</strong> (<em>str</em>) – The shortname applied to the view.</li> +<li><strong>kwargs</strong> (<em>dict</em>) – </li> +<li><strong>arguments</strong><strong> (</strong><strong>specific</strong><strong>)</strong> (<em>Keyword</em>) – </li> +<li><strong>text</strong> (<em>str</em><em>, </em><em>optional</em><em>, </em><em>default None</em>) – 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).</li> -<li><strong>stats</strong> (<em>str</em><em>, </em><em>default 'mean'</em>) – The measure to compute.</li> -<li><strong>exclude</strong> (<em>list of int</em>) – Codes that will not be considered calculating the result.</li> -<li><strong>rescale</strong> (<em>dict</em>) – <p>A mapping of {old code: new code}, e.g.:</p> +<li><strong>stats</strong> (<em>str</em><em>, </em><em>default 'mean'</em>) – The measure to compute.</li> +<li><strong>exclude</strong> (<em>list of int</em>) – Codes that will not be considered calculating the result.</li> +<li><strong>rescale</strong> (<em>dict</em>) – <p>A mapping of {old code: new code}, e.g.:</p> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="p">{</span> <span class="mi">1</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">:</span> <span class="mi">25</span><span class="p">,</span> @@ -464,7 +474,7 @@ <h1>QuantipyViews<a class="headerlink" href="#quantipyviews" title="Permalink to </pre></div> </div> </li> -<li><strong>drop</strong> (<em>bool</em>) – If <code class="docutils literal"><span class="pre">rescale</span></code> provides a new scale defintion, <code class="docutils literal"><span class="pre">drop</span></code> will remove +<li><strong>drop</strong> (<em>bool</em>) – If <code class="docutils literal"><span class="pre">rescale</span></code> provides a new scale defintion, <code class="docutils literal"><span class="pre">drop</span></code> will remove all codes that are not transformed. Acts as a shorthand for manually passing any remaining codes in <code class="docutils literal"><span class="pre">exclude</span></code>.</li> </ul> @@ -494,14 +504,14 @@ <h1>QuantipyViews<a class="headerlink" href="#quantipyviews" title="Permalink to <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>link</strong> (<em>Quantipy Link object.</em>) – </li> -<li><strong>name</strong> (<em>str</em>) – The shortname applied to the view.</li> -<li><strong>kwargs</strong> (<em>dict</em>) – </li> -<li><strong>arguments</strong><strong> (</strong><strong>specific</strong><strong>)</strong><strong></strong> (<em>Keyword</em>) – </li> -<li><strong>text</strong> (<em>str</em><em>, </em><em>optional</em><em>, </em><em>default None</em>) – Sets an optional label in the meta component of the view that is +<li><strong>link</strong> (<em>Quantipy Link object.</em>) – </li> +<li><strong>name</strong> (<em>str</em>) – The shortname applied to the view.</li> +<li><strong>kwargs</strong> (<em>dict</em>) – </li> +<li><strong>arguments</strong><strong> (</strong><strong>specific</strong><strong>)</strong> (<em>Keyword</em>) – </li> +<li><strong>text</strong> (<em>str</em><em>, </em><em>optional</em><em>, </em><em>default None</em>) – 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).</li> -<li><strong>logic</strong> (<em>list of int</em><em>, </em><em>list of dicts</em><em> or </em><em>core.tools.view.logic operation</em>) – <p>If a list is passed this instructs a simple net of the codes given +<li><strong>logic</strong> (<em>list of int</em><em>, </em><em>list of dicts</em><em> or </em><em>core.tools.view.logic operation</em>) – <p>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. @@ -517,15 +527,15 @@ <h1>QuantipyViews<a class="headerlink" href="#quantipyviews" title="Permalink to </pre></div> </div> </li> -<li><strong>calc</strong> (<em>TODO</em>) – </li> -<li><strong>calc_only</strong> (<em>TODO</em>) – </li> +<li><strong>calc</strong> (<em>TODO</em>) – </li> +<li><strong>calc_only</strong> (<em>TODO</em>) – </li> </ul> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><ul class="simple"> -<li><em>None</em> – Adds requested View to the Stack, storing it under the full +<li><em>None</em> – Adds requested View to the Stack, storing it under the full view name notation key.</li> -<li><em>.. note:: Net codes take into account if a variable is</em> – multi-coded. The net will therefore consider qualifying +<li><em>.. note:: Net codes take into account if a variable is</em> – 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.</li> </ul> @@ -591,7 +601,7 @@ <h1>QuantipyViews<a class="headerlink" href="#quantipyviews" title="Permalink to <script type="text/javascript" src="../../_static/underscore.js"></script> <script type="text/javascript" src="../../_static/doctools.js"></script> <script type="text/javascript" src="../../_static/custom.js"></script> - <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> diff --git a/docs/API/_build/html/sites/api_ref/Rim_scheme.html b/docs/API/_build/html/sites/api_ref/Rim_scheme.html index d5a35b9fc..a61efd058 100644 --- a/docs/API/_build/html/sites/api_ref/Rim_scheme.html +++ b/docs/API/_build/html/sites/api_ref/Rim_scheme.html @@ -37,7 +37,7 @@ <link rel="search" title="Search" href="../../search.html"/> <link rel="top" title="Quantipy 0.1.3 documentation" href="../../index.html"/> <link rel="up" title="API references" href="00overview.html"/> - <link rel="next" title="View" href="View.html"/> + <link rel="next" title="Stack" href="Stack.html"/> <link rel="prev" title="QuantipyViews" href="QuantipyViews.html"/> @@ -92,9 +92,18 @@ <h3>Quick search</h3> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../release_notes/00_overview.html">Release notes</a><ul> -<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Upcoming (September 2017)</a></li> -<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html#latest-31-08-2017">Latest (31/08/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Latest (01/10/2018)</a></li> <li class="toctree-l2"><a class="reference internal" href="../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> @@ -195,7 +204,7 @@ <h3>Quick search</h3> <li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> -<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> @@ -292,6 +301,7 @@ <h3>Quick search</h3> <li class="toctree-l2"><a class="reference internal" href="quantify_engine.html">quantify.engine</a></li> <li class="toctree-l2"><a class="reference internal" href="QuantipyViews.html">QuantipyViews</a></li> <li class="toctree-l2 current"><a class="current reference internal" href="#">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="Stack.html">Stack</a></li> <li class="toctree-l2"><a class="reference internal" href="View.html">View</a></li> <li class="toctree-l2"><a class="reference internal" href="ViewMapper.html">ViewMapper</a></li> </ul> @@ -359,11 +369,11 @@ <h1>Rim<a class="headerlink" href="#rim" title="Permalink to this headline">¶</ <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>name</strong> (<em>str</em>) – Name of the weight group.</li> -<li><strong>filter_def</strong> (<em>str</em><em>, </em><em>optional</em>) – An optional filter defintion given as a boolean expression in +<li><strong>name</strong> (<em>str</em>) – Name of the weight group.</li> +<li><strong>filter_def</strong> (<em>str</em><em>, </em><em>optional</em>) – An optional filter defintion given as a boolean expression in string format. Must be a valid input for the pandas DataFrame.query() method.</li> -<li><strong>targets</strong> (<em>dict</em>) – Dictionary mapping of DataFrame columns to target proportion list.</li> +<li><strong>targets</strong> (<em>dict</em>) – Dictionary mapping of DataFrame columns to target proportion list.</li> </ul> </td> </tr> @@ -382,13 +392,13 @@ <h1>Rim<a class="headerlink" href="#rim" title="Permalink to this headline">¶</ <code class="descname">group_targets</code><span class="sig-paren">(</span><em>group_targets</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Rim.group_targets" title="Permalink to this definition">¶</a></dt> <dd><p>Set inter-group target proportions.</p> <p>This will scale the weight factors per group to match the desired group -proportions and thus effectively change each group’s weighted +proportions and thus effectively change each group’s weighted total number of cases.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>group_targets</strong> (<em>dict</em>) – A dictionary mapping of group names to the desired proportions.</td> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>group_targets</strong> (<em>dict</em>) – A dictionary mapping of group names to the desired proportions.</td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td> </tr> @@ -413,8 +423,8 @@ <h1>Rim<a class="headerlink" href="#rim" title="Permalink to this headline">¶</ <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>targets</strong> (<em>dict</em><em> or </em><em>list of dict</em>) – Dictionary mapping of DataFrame columns to target proportion list.</li> -<li><strong>group_name</strong> (<em>str</em><em>, </em><em>optional</em>) – A name for the simple weight (group) created.</li> +<li><strong>targets</strong> (<em>dict</em><em> or </em><em>list of dict</em>) – Dictionary mapping of DataFrame columns to target proportion list.</li> +<li><strong>group_name</strong> (<em>str</em><em>, </em><em>optional</em>) – A name for the simple weight (group) created.</li> </ul> </td> </tr> @@ -436,7 +446,7 @@ <h1>Rim<a class="headerlink" href="#rim" title="Permalink to this headline">¶</ <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><strong>df</strong> – A summary of missing entries and (rounded) mean/mode/median of +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><strong>df</strong> – A summary of missing entries and (rounded) mean/mode/median of value codes per target variable.</td> </tr> <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">pandas.DataFrame</td> @@ -456,7 +466,7 @@ <h1>Rim<a class="headerlink" href="#rim" title="Permalink to this headline">¶</ <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> - <a href="View.html" class="btn btn-neutral float-right" title="View" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + <a href="Stack.html" class="btn btn-neutral float-right" title="Stack" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> <a href="QuantipyViews.html" class="btn btn-neutral" title="QuantipyViews" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> @@ -500,7 +510,7 @@ <h1>Rim<a class="headerlink" href="#rim" title="Permalink to this headline">¶</ <script type="text/javascript" src="../../_static/underscore.js"></script> <script type="text/javascript" src="../../_static/doctools.js"></script> <script type="text/javascript" src="../../_static/custom.js"></script> - <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> diff --git a/docs/API/_build/html/sites/api_ref/View.html b/docs/API/_build/html/sites/api_ref/View.html index 215373c15..226848b81 100644 --- a/docs/API/_build/html/sites/api_ref/View.html +++ b/docs/API/_build/html/sites/api_ref/View.html @@ -38,7 +38,7 @@ <link rel="top" title="Quantipy 0.1.3 documentation" href="../../index.html"/> <link rel="up" title="API references" href="00overview.html"/> <link rel="next" title="ViewMapper" href="ViewMapper.html"/> - <link rel="prev" title="Rim" href="Rim_scheme.html"/> + <link rel="prev" title="Stack" href="Stack.html"/> <script src="../../_static/js/modernizr.min.js"></script> @@ -92,9 +92,18 @@ <h3>Quick search</h3> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../release_notes/00_overview.html">Release notes</a><ul> -<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Upcoming (September 2017)</a></li> -<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html#latest-31-08-2017">Latest (31/08/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Latest (01/10/2018)</a></li> <li class="toctree-l2"><a class="reference internal" href="../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> @@ -195,7 +204,7 @@ <h3>Quick search</h3> <li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> -<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> @@ -292,6 +301,7 @@ <h3>Quick search</h3> <li class="toctree-l2"><a class="reference internal" href="quantify_engine.html">quantify.engine</a></li> <li class="toctree-l2"><a class="reference internal" href="QuantipyViews.html">QuantipyViews</a></li> <li class="toctree-l2"><a class="reference internal" href="Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="Stack.html">Stack</a></li> <li class="toctree-l2 current"><a class="current reference internal" href="#">View</a></li> <li class="toctree-l2"><a class="reference internal" href="ViewMapper.html">ViewMapper</a></li> </ul> @@ -352,13 +362,13 @@ <h1>View<a class="headerlink" href="#view" title="Permalink to this headline">¶ <dd><dl class="method"> <dt id="quantipy.View.get_edit_params"> <code class="descname">get_edit_params</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.View.get_edit_params" title="Permalink to this definition">¶</a></dt> -<dd><p>Provides the View’s Link edit kwargs with fallbacks to default values.</p> +<dd><p>Provides the View’s Link edit kwargs with fallbacks to default values.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><strong>edit_params</strong> – A tuple of kwargs controlling the following supported Link data -edits: logic, calc, ...</td> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><strong>edit_params</strong> – A tuple of kwargs controlling the following supported Link data +edits: logic, calc, …</td> </tr> <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">tuple</td> </tr> @@ -369,12 +379,12 @@ <h1>View<a class="headerlink" href="#view" title="Permalink to this headline">¶ <dl class="method"> <dt id="quantipy.View.get_std_params"> <code class="descname">get_std_params</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.View.get_std_params" title="Permalink to this definition">¶</a></dt> -<dd><p>Provides the View’s standard kwargs with fallbacks to default values.</p> +<dd><p>Provides the View’s standard kwargs with fallbacks to default values.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><strong>std_parameters</strong> – A tuple of the common kwargs controlling the general View method +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><strong>std_parameters</strong> – A tuple of the common kwargs controlling the general View method behaviour: axis, relation, rel_to, weights, text</td> </tr> <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">tuple</td> @@ -452,12 +462,12 @@ <h1>View<a class="headerlink" href="#view" title="Permalink to this headline">¶ <dl class="method"> <dt id="quantipy.View.meta"> <code class="descname">meta</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.View.meta" title="Permalink to this definition">¶</a></dt> -<dd><p>Get a summary on a View’s meta information.</p> +<dd><p>Get a summary on a View’s meta information.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><strong>viewmeta</strong> – A dictionary that contains global aggregation information.</td> +<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><strong>viewmeta</strong> – A dictionary that contains global aggregation information.</td> </tr> <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">dict</td> </tr> @@ -480,15 +490,15 @@ <h1>View<a class="headerlink" href="#view" title="Permalink to this headline">¶ <dl class="method"> <dt id="quantipy.View.notation"> <code class="descname">notation</code><span class="sig-paren">(</span><em>method</em>, <em>condition</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.View.notation" title="Permalink to this definition">¶</a></dt> -<dd><p>Generate the View’s Stack key notation string.</p> +<dd><p>Generate the View’s Stack key notation string.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>shortname</strong><strong>, </strong><strong>relation</strong> (<em>aggname</em><em>,</em><em></em>) – Strings for the aggregation name, the method’s shortname and the +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>shortname</strong><strong>, </strong><strong>relation</strong> (<em>aggname</em><em>,</em>) – Strings for the aggregation name, the method’s shortname and the relation component of the View notation.</td> </tr> -<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>notation</strong> – The View notation.</td> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>notation</strong> – The View notation.</td> </tr> <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td> </tr> @@ -505,14 +515,14 @@ <h1>View<a class="headerlink" href="#view" title="Permalink to this headline">¶ <dl class="method"> <dt id="quantipy.View.spec_condition"> <code class="descname">spec_condition</code><span class="sig-paren">(</span><em>link</em>, <em>conditionals=None</em>, <em>expand=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.View.spec_condition" title="Permalink to this definition">¶</a></dt> -<dd><p>Updates the View notation’s condition component based on agg. details.</p> +<dd><p>Updates the View notation’s condition component based on agg. details.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>link</strong> (<em>Link</em>) – </td> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>link</strong> (<em>Link</em>) – </td> </tr> -<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>relation_string</strong> – The relation part of the View name notation.</td> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>relation_string</strong> – The relation part of the View name notation.</td> </tr> <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">str</td> </tr> @@ -540,7 +550,7 @@ <h1>View<a class="headerlink" href="#view" title="Permalink to this headline">¶ <a href="ViewMapper.html" class="btn btn-neutral float-right" title="ViewMapper" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> - <a href="Rim_scheme.html" class="btn btn-neutral" title="Rim" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + <a href="Stack.html" class="btn btn-neutral" title="Stack" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> </div> @@ -581,7 +591,7 @@ <h1>View<a class="headerlink" href="#view" title="Permalink to this headline">¶ <script type="text/javascript" src="../../_static/underscore.js"></script> <script type="text/javascript" src="../../_static/doctools.js"></script> <script type="text/javascript" src="../../_static/custom.js"></script> - <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> diff --git a/docs/API/_build/html/sites/api_ref/ViewMapper.html b/docs/API/_build/html/sites/api_ref/ViewMapper.html index ddd24f0f5..cbebbcad6 100644 --- a/docs/API/_build/html/sites/api_ref/ViewMapper.html +++ b/docs/API/_build/html/sites/api_ref/ViewMapper.html @@ -91,9 +91,18 @@ <h3>Quick search</h3> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../release_notes/00_overview.html">Release notes</a><ul> -<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Upcoming (September 2017)</a></li> -<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html#latest-31-08-2017">Latest (31/08/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> <li class="toctree-l2"><a class="reference internal" href="../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> @@ -194,7 +203,7 @@ <h3>Quick search</h3> <li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> -<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> @@ -348,7 +357,7 @@ <h1>ViewMapper<a class="headerlink" href="#viewmapper" title="Permalink to this <dl class="class"> <dt id="quantipy.ViewMapper"> <em class="property">class </em><code class="descclassname">quantipy.</code><code class="descname">ViewMapper</code><span class="sig-paren">(</span><em>views=None</em>, <em>template=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.ViewMapper" title="Permalink to this definition">¶</a></dt> -<dd><p>Applies View computation results to Links based on the view method’s +<dd><p>Applies View computation results to Links based on the view method’s kwargs, handling the coordination and structuring side of the aggregation process.</p> <dl class="method"> @@ -360,10 +369,10 @@ <h1>ViewMapper<a class="headerlink" href="#viewmapper" title="Permalink to this <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>name</strong> (<em>str</em>) – The short name of the View.</li> -<li><strong>method</strong> (<em>view method</em>) – The view method that will be used to derivce the result</li> -<li><strong>kwargs</strong> (<em>dict</em>) – The keyword arguments needed by the view method.</li> -<li><strong>template</strong> (<em>dict</em>) – A ViewMapper template that contains information on view method and +<li><strong>name</strong> (<em>str</em>) – The short name of the View.</li> +<li><strong>method</strong> (<em>view method</em>) – The view method that will be used to derivce the result</li> +<li><strong>kwargs</strong> (<em>dict</em>) – The keyword arguments needed by the view method.</li> +<li><strong>template</strong> (<em>dict</em>) – A ViewMapper template that contains information on view method and kwargs values to iterate over.</li> </ul> </td> @@ -387,8 +396,8 @@ <h1>ViewMapper<a class="headerlink" href="#viewmapper" title="Permalink to this <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>method</strong> (<em>{'frequency'</em><em>, </em><em>'descriptives'</em><em>, </em><em>'coltests'}</em>) – The baseline view method to be used.</li> -<li><strong>iterators</strong> (<em>dict</em>) – A dictionary mapping of view method kwargs to lists of values.</li> +<li><strong>method</strong> (<em>{'frequency'</em><em>, </em><em>'descriptives'</em><em>, </em><em>'coltests'}</em>) – The baseline view method to be used.</li> +<li><strong>iterators</strong> (<em>dict</em>) – A dictionary mapping of view method kwargs to lists of values.</li> </ul> </td> </tr> @@ -411,8 +420,8 @@ <h1>ViewMapper<a class="headerlink" href="#viewmapper" title="Permalink to this <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>views</strong> (<em>list of str</em>) – The selection of View names to keep.</li> -<li><strong>strict_selection</strong> (<em>bool</em><em>, </em><em>default True</em>) – TODO</li> +<li><strong>views</strong> (<em>list of str</em>) – The selection of View names to keep.</li> +<li><strong>strict_selection</strong> (<em>bool</em><em>, </em><em>default True</em>) – TODO</li> </ul> </td> </tr> @@ -479,7 +488,7 @@ <h1>ViewMapper<a class="headerlink" href="#viewmapper" title="Permalink to this <script type="text/javascript" src="../../_static/underscore.js"></script> <script type="text/javascript" src="../../_static/doctools.js"></script> <script type="text/javascript" src="../../_static/custom.js"></script> - <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> diff --git a/docs/API/_build/html/sites/api_ref/quantify_engine.html b/docs/API/_build/html/sites/api_ref/quantify_engine.html index 400248b0c..fa88687ea 100644 --- a/docs/API/_build/html/sites/api_ref/quantify_engine.html +++ b/docs/API/_build/html/sites/api_ref/quantify_engine.html @@ -92,9 +92,18 @@ <h3>Quick search</h3> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../release_notes/00_overview.html">Release notes</a><ul> -<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Upcoming (September 2017)</a></li> -<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html#latest-31-08-2017">Latest (31/08/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Latest (01/10/2018)</a></li> <li class="toctree-l2"><a class="reference internal" href="../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> @@ -195,7 +204,7 @@ <h3>Quick search</h3> <li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> -<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> @@ -292,6 +301,7 @@ <h3>Quick search</h3> <li class="toctree-l2 current"><a class="current reference internal" href="#">quantify.engine</a></li> <li class="toctree-l2"><a class="reference internal" href="QuantipyViews.html">QuantipyViews</a></li> <li class="toctree-l2"><a class="reference internal" href="Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="Stack.html">Stack</a></li> <li class="toctree-l2"><a class="reference internal" href="View.html">View</a></li> <li class="toctree-l2"><a class="reference internal" href="ViewMapper.html">ViewMapper</a></li> </ul> @@ -350,7 +360,7 @@ <h1>quantify.engine<a class="headerlink" href="#quantify-engine" title="Permalin <dt id="quantipy.Quantity"> <em class="property">class </em><code class="descclassname">quantipy.</code><code class="descname">Quantity</code><span class="sig-paren">(</span><em>link</em>, <em>weight=None</em>, <em>base_all=False</em>, <em>ignore_flags=False</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Quantity" title="Permalink to this definition">¶</a></dt> <dd><p>The Quantity object is the main Quantipy aggregation engine.</p> -<p>Consists of a link’s data matrix representation and sectional defintion +<p>Consists of a link’s data matrix representation and sectional defintion of weight vector (wv), x-codes section (xsect) and y-codes section (ysect). The instance methods handle creation, retrieval and manipulation of the data input matrices and section definitions as well as the majority @@ -363,26 +373,28 @@ <h1>quantify.engine<a class="headerlink" href="#quantify-engine" title="Permalin <dl class="method"> <dt id="quantipy.Quantity.count"> -<code class="descname">count</code><span class="sig-paren">(</span><em>axis=None</em>, <em>raw_sum=False</em>, <em>cum_sum=False</em>, <em>margin=True</em>, <em>as_df=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Quantity.count" title="Permalink to this definition">¶</a></dt> +<code class="descname">count</code><span class="sig-paren">(</span><em>axis=None</em>, <em>raw_sum=False</em>, <em>cum_sum=False</em>, <em>effective=False</em>, <em>margin=True</em>, <em>as_df=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Quantity.count" title="Permalink to this definition">¶</a></dt> <dd><p>Count entries over all cells or per axis margin.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>axis</strong> (<em>{None</em><em>, </em><em>'x'</em><em>, </em><em>'y'}</em><em>, </em><em>deafult None</em>) – When axis is None, the frequency of all cells from the uni- or +<li><strong>axis</strong> (<em>{None</em><em>, </em><em>'x'</em><em>, </em><em>'y'}</em><em>, </em><em>deafult None</em>) – When axis is None, the frequency of all cells from the uni- or multivariate distribution is presented. If the axis is specified -to be either ‘x’ or ‘y’ the margin per axis becomes the resulting +to be either ‘x’ or ‘y’ the margin per axis becomes the resulting aggregation.</li> -<li><strong>raw_sum</strong> (<em>bool</em><em>, </em><em>default False</em>) – If True will perform a simple summation over the cells given the +<li><strong>raw_sum</strong> (<em>bool</em><em>, </em><em>default False</em>) – If True will perform a simple summation over the cells given the axis parameter. This ignores net counting of qualifying answers in favour of summing over all answers given when considering margins.</li> -<li><strong>cum_sum</strong> (<em>bool</em><em>, </em><em>default False</em>) – If True a cumulative sum of the elements along the given axis is +<li><strong>cum_sum</strong> (<em>bool</em><em>, </em><em>default False</em>) – If True a cumulative sum of the elements along the given axis is returned.</li> -<li><strong>margin</strong> (<em>bool</em><em>, </em><em>deafult True</em>) – Controls whether the margins of the aggregation result are shown. +<li><strong>effective</strong> (<em>bool</em><em>, </em><em>default False</em>) – If True, compute effective counts instead of traditional (weighted) +counts.</li> +<li><strong>margin</strong> (<em>bool</em><em>, </em><em>deafult True</em>) – Controls whether the margins of the aggregation result are shown. This also applies to margin aggregations themselves, since they contain a margin in (form of the total number of cases) as well.</li> -<li><strong>as_df</strong> (<em>bool</em><em>, </em><em>default True</em>) – Controls whether the aggregation is transformed into a Quantipy- +<li><strong>as_df</strong> (<em>bool</em><em>, </em><em>default True</em>) – Controls whether the aggregation is transformed into a Quantipy- multiindexed (following the Question/Values convention) pandas.DataFrame or will be left in its numpy.array format.</li> </ul> @@ -402,7 +414,7 @@ <h1>quantify.engine<a class="headerlink" href="#quantify-engine" title="Permalin <dl class="method"> <dt id="quantipy.Quantity.exclude"> <code class="descname">exclude</code><span class="sig-paren">(</span><em>codes</em>, <em>axis='x'</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Quantity.exclude" title="Permalink to this definition">¶</a></dt> -<dd><p>Wrapper for _missingfy(...keep_codes=False, ..., keep_base=False, ...) +<dd><p>Wrapper for _missingfy(…keep_codes=False, …, keep_base=False, …) Excludes specified codes from aggregation.</p> </dd></dl> @@ -421,18 +433,18 @@ <h1>quantify.engine<a class="headerlink" href="#quantify-engine" title="Permalin <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>groups</strong> (<em>list</em><em>, </em><em>dict of lists</em><em> or </em><em>logic expression</em>) – <p>The group/net code defintion(s) in form of...</p> +<li><strong>groups</strong> (<em>list</em><em>, </em><em>dict of lists</em><em> or </em><em>logic expression</em>) – <p>The group/net code defintion(s) in form of…</p> <ul> <li>a simple list: <code class="docutils literal"><span class="pre">[1,</span> <span class="pre">2,</span> <span class="pre">3]</span></code></li> <li>a dict of list: <code class="docutils literal"><span class="pre">{'grp</span> <span class="pre">A':</span> <span class="pre">[1,</span> <span class="pre">2,</span> <span class="pre">3],</span> <span class="pre">'grp</span> <span class="pre">B':</span> <span class="pre">[4,</span> <span class="pre">5,</span> <span class="pre">6]}</span></code></li> <li>a logical expression: <code class="docutils literal"><span class="pre">not_any([1,</span> <span class="pre">2])</span></code></li> </ul> </li> -<li><strong>axis</strong> ({<code class="docutils literal"><span class="pre">'x'</span></code>, <code class="docutils literal"><span class="pre">'y'</span></code>}, default <code class="docutils literal"><span class="pre">'x'</span></code>) – The axis to group codes on.</li> -<li><strong>expand</strong> ({None, <code class="docutils literal"><span class="pre">'before'</span></code>, <code class="docutils literal"><span class="pre">'after'</span></code>}, default <code class="docutils literal"><span class="pre">None</span></code>) – If <code class="docutils literal"><span class="pre">'before'</span></code>, the codes that are grouped will be kept and placed +<li><strong>axis</strong> ({<code class="docutils literal"><span class="pre">'x'</span></code>, <code class="docutils literal"><span class="pre">'y'</span></code>}, default <code class="docutils literal"><span class="pre">'x'</span></code>) – The axis to group codes on.</li> +<li><strong>expand</strong> ({None, <code class="docutils literal"><span class="pre">'before'</span></code>, <code class="docutils literal"><span class="pre">'after'</span></code>}, default <code class="docutils literal"><span class="pre">None</span></code>) – If <code class="docutils literal"><span class="pre">'before'</span></code>, the codes that are grouped will be kept and placed before the grouped aggregation; vice versa for <code class="docutils literal"><span class="pre">'after'</span></code>. Ignored on logical expressions found in <code class="docutils literal"><span class="pre">groups</span></code>.</li> -<li><strong>complete</strong> (<em>bool</em><em>, </em><em>default False</em>) – If True, codes that define the Link on the given <code class="docutils literal"><span class="pre">axis</span></code> but are +<li><strong>complete</strong> (<em>bool</em><em>, </em><em>default False</em>) – If True, codes that define the Link on the given <code class="docutils literal"><span class="pre">axis</span></code> but are not present in the <code class="docutils literal"><span class="pre">groups</span></code> defintion(s) will be placed in their natural position within the aggregation, respecting the value of <code class="docutils literal"><span class="pre">expand</span></code>.</li> @@ -452,7 +464,7 @@ <h1>quantify.engine<a class="headerlink" href="#quantify-engine" title="Permalin <dl class="method"> <dt id="quantipy.Quantity.limit"> <code class="descname">limit</code><span class="sig-paren">(</span><em>codes</em>, <em>axis='x'</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Quantity.limit" title="Permalink to this definition">¶</a></dt> -<dd><p>Wrapper for _missingfy(...keep_codes=True, ..., keep_base=True, ...) +<dd><p>Wrapper for _missingfy(…keep_codes=True, …, keep_base=True, …) Restrict the data matrix entires to contain the specified codes only.</p> </dd></dl> @@ -464,7 +476,7 @@ <h1>quantify.engine<a class="headerlink" href="#quantify-engine" title="Permalin <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>on</strong> (<em>{'y'</em><em>, </em><em>'x'}</em><em>, </em><em>default 'y'</em>) – Defines the base to normalize the result on. <code class="docutils literal"><span class="pre">'y'</span></code> will +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>on</strong> (<em>{'y'</em><em>, </em><em>'x'}</em><em>, </em><em>default 'y'</em>) – Defines the base to normalize the result on. <code class="docutils literal"><span class="pre">'y'</span></code> will produce column percentages, <code class="docutils literal"><span class="pre">'x'</span></code> will produce row percentages.</td> </tr> @@ -484,14 +496,14 @@ <h1>quantify.engine<a class="headerlink" href="#quantify-engine" title="Permalin <dl class="method"> <dt id="quantipy.Quantity.rescale"> <code class="descname">rescale</code><span class="sig-paren">(</span><em>scaling</em>, <em>drop=False</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Quantity.rescale" title="Permalink to this definition">¶</a></dt> -<dd><p>Modify the object’s <code class="docutils literal"><span class="pre">xdef</span></code> property reflecting new value defintions.</p> +<dd><p>Modify the object’s <code class="docutils literal"><span class="pre">xdef</span></code> property reflecting new value defintions.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>scaling</strong> (<em>dict</em>) – Mapping of old_code: new_code, given as of type int or float.</li> -<li><strong>drop</strong> (<em>bool</em><em>, </em><em>default False</em>) – If True, codes not included in the scaling dict will be excluded.</li> +<li><strong>scaling</strong> (<em>dict</em>) – Mapping of old_code: new_code, given as of type int or float.</li> +<li><strong>drop</strong> (<em>bool</em><em>, </em><em>default False</em>) – If True, codes not included in the scaling dict will be excluded.</li> </ul> </td> </tr> @@ -514,14 +526,14 @@ <h1>quantify.engine<a class="headerlink" href="#quantify-engine" title="Permalin <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>stat</strong> (<em>{'summary'</em><em>, </em><em>'mean'</em><em>, </em><em>'median'</em><em>, </em><em>'var'</em><em>, </em><em>'stddev'</em><em>, </em><em>'sem'</em><em>, </em><em>varcoeff'</em><em>,</em><em></em>) – ‘min’, ‘lower_q’, ‘upper_q’, ‘max’}, default ‘summary’ +<li><strong>stat</strong> (<em>{'summary'</em><em>, </em><em>'mean'</em><em>, </em><em>'median'</em><em>, </em><em>'var'</em><em>, </em><em>'stddev'</em><em>, </em><em>'sem'</em><em>, </em><em>varcoeff'</em><em>,</em>) – ‘min’, ‘lower_q’, ‘upper_q’, ‘max’}, default ‘summary’ The measure to calculate. Defaults to a summary output of the most important sample statistics.</li> -<li><strong>axis</strong> (<em>{'x'</em><em>, </em><em>'y'}</em><em>, </em><em>default 'x'</em>) – The axis which is reduced in the aggregation, e.g. column vs. row +<li><strong>axis</strong> (<em>{'x'</em><em>, </em><em>'y'}</em><em>, </em><em>default 'x'</em>) – The axis which is reduced in the aggregation, e.g. column vs. row means.</li> -<li><strong>margin</strong> (<em>bool</em><em>, </em><em>default True</em>) – Controls whether statistic(s) of the marginal distribution are +<li><strong>margin</strong> (<em>bool</em><em>, </em><em>default True</em>) – Controls whether statistic(s) of the marginal distribution are shown.</li> -<li><strong>as_df</strong> (<em>bool</em><em>, </em><em>default True</em>) – Controls whether the aggregation is transformed into a Quantipy- +<li><strong>as_df</strong> (<em>bool</em><em>, </em><em>default True</em>) – Controls whether the aggregation is transformed into a Quantipy- multiindexed (following the Question/Values convention) pandas.DataFrame or will be left in its numpy.array format.</li> </ul> @@ -541,20 +553,20 @@ <h1>quantify.engine<a class="headerlink" href="#quantify-engine" title="Permalin <dl class="method"> <dt id="quantipy.Quantity.swap"> <code class="descname">swap</code><span class="sig-paren">(</span><em>var</em>, <em>axis='x'</em>, <em>update_axis_def=True</em>, <em>inplace=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Quantity.swap" title="Permalink to this definition">¶</a></dt> -<dd><p>Change the Quantity’s x- or y-axis keeping filter and weight setup.</p> +<dd><p>Change the Quantity’s x- or y-axis keeping filter and weight setup.</p> <p>All edits and aggregation results will be removed during the swap.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>var</strong> (<em>str</em>) – New variable’s name used in axis swap.</li> -<li><strong>axis</strong> ({‘x’, ‘y’}, default <code class="docutils literal"><span class="pre">'x'</span></code>) – The axis to swap.</li> -<li><strong>update_axis_def</strong> (<em>bool</em><em>, </em><em>default False</em>) – If self is of type <code class="docutils literal"><span class="pre">'array'</span></code>, the name and item definitions +<li><strong>var</strong> (<em>str</em>) – New variable’s name used in axis swap.</li> +<li><strong>axis</strong> ({‘x’, ‘y’}, default <code class="docutils literal"><span class="pre">'x'</span></code>) – The axis to swap.</li> +<li><strong>update_axis_def</strong> (<em>bool</em><em>, </em><em>default False</em>) – If self is of type <code class="docutils literal"><span class="pre">'array'</span></code>, the name and item definitions (that are e.g. used in the <code class="docutils literal"><span class="pre">to_df()</span></code> method) can be updated to -reflect the swapped axis variable or kept to show the original’s +reflect the swapped axis variable or kept to show the original’s ones.</li> -<li><strong>inplace</strong> (<em>bool</em><em>, </em><em>default True</em>) – Whether to modify the Quantity inplace or return a new instance.</li> +<li><strong>inplace</strong> (<em>bool</em><em>, </em><em>default True</em>) – Whether to modify the Quantity inplace or return a new instance.</li> </ul> </td> </tr> @@ -594,7 +606,7 @@ <h1>quantify.engine<a class="headerlink" href="#quantify-engine" title="Permalin <dd><p>Compute the standard error (se) estimate of the tested metric.</p> <p>The calculation of the se is defined by the parameters of the setup. The main difference is the handling of variances. <strong>unpooled</strong> -implicitly assumes variance inhomogenity between the column pairing’s +implicitly assumes variance inhomogenity between the column pairing’s samples. <strong>pooled</strong> treats variances effectively as equal.</p> </dd></dl> @@ -614,7 +626,7 @@ <h1>quantify.engine<a class="headerlink" href="#quantify-engine" title="Permalin <dt id="quantipy.Test.run"> <code class="descname">run</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Test.run" title="Permalink to this definition">¶</a></dt> <dd><p>Performs the testing algorithm and creates an output pd.DataFrame.</p> -<p>The output is indexed according to Quantipy’s Questions->Values +<p>The output is indexed according to Quantipy’s Questions->Values convention. Significant results between columns are presented as lists of integer y-axis codes where the column with the higher value is holding the codes of the columns with the lower values. NaN is @@ -626,7 +638,7 @@ <h1>quantify.engine<a class="headerlink" href="#quantify-engine" title="Permalin <dt id="quantipy.Test.set_params"> <code class="descname">set_params</code><span class="sig-paren">(</span><em>test_total=False</em>, <em>level='mid'</em>, <em>mimic='Dim'</em>, <em>testtype='pooled'</em>, <em>use_ebase=True</em>, <em>ovlp_correc=True</em>, <em>cwi_filter=False</em>, <em>flag_bases=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Test.set_params" title="Permalink to this definition">¶</a></dt> <dd><p>Sets the test algorithm parameters and defines the type of test.</p> -<p>This method sets the test’s global parameters and derives the +<p>This method sets the test’s global parameters and derives the necessary measures for the computation of the test statistic. The default values correspond to the SPSS Dimensions Column Tests algorithms that control for bias introduced by weighting and @@ -640,21 +652,21 @@ <h1>quantify.engine<a class="headerlink" href="#quantify-engine" title="Permalin <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>test_total</strong> (<em>bool</em><em>, </em><em>default False</em>) – If set to True, the test algorithms will also include an existent +<li><strong>test_total</strong> (<em>bool</em><em>, </em><em>default False</em>) – If set to True, the test algorithms will also include an existent total (@-) version of the original link and test against the unconditial data distribution.</li> -<li><strong>level</strong> (<em>str</em><em> or </em><em>float</em><em>, </em><em>default 'mid'</em>) – The level of significance given either as per ‘low’ = 0.1, -‘mid’ = 0.05, ‘high’ = 0.01 or as specific float, e.g. 0.15.</li> -<li><strong>mimic</strong> (<em>{'askia'</em><em>, </em><em>'Dim'} default='Dim'</em>) – Will instruct the mimicking of a software specific test.</li> -<li><strong>testtype</strong> (<em>str</em><em>, </em><em>default 'pooled'</em>) – Global definition of the tests.</li> -<li><strong>use_ebase</strong> (<em>bool</em><em>, </em><em>default True</em>) – If True, will use the effective sample sizes instead of the +<li><strong>level</strong> (<em>str</em><em> or </em><em>float</em><em>, </em><em>default 'mid'</em>) – The level of significance given either as per ‘low’ = 0.1, +‘mid’ = 0.05, ‘high’ = 0.01 or as specific float, e.g. 0.15.</li> +<li><strong>mimic</strong> (<em>{'askia'</em><em>, </em><em>'Dim'} default='Dim'</em>) – Will instruct the mimicking of a software specific test.</li> +<li><strong>testtype</strong> (<em>str</em><em>, </em><em>default 'pooled'</em>) – Global definition of the tests.</li> +<li><strong>use_ebase</strong> (<em>bool</em><em>, </em><em>default True</em>) – If True, will use the effective sample sizes instead of the the simple weighted ones when testing a weighted aggregation.</li> -<li><strong>ovlp_correc</strong> (<em>bool</em><em>, </em><em>default True</em>) – If True, will consider and correct for respondent overlap when +<li><strong>ovlp_correc</strong> (<em>bool</em><em>, </em><em>default True</em>) – If True, will consider and correct for respondent overlap when testing between multi-coded column pairs.</li> -<li><strong>cwi_filter</strong> (<em>bool</em><em>, </em><em>default False</em>) – If True, will check an incoming count aggregation for cells that +<li><strong>cwi_filter</strong> (<em>bool</em><em>, </em><em>default False</em>) – If True, will check an incoming count aggregation for cells that fall below a treshhold comparison aggregation that assumes counts to be independent.</li> -<li><strong>flag_bases</strong> (<em>list of two int</em><em>, </em><em>default None</em>) – If provided, the output dataframe will replace results that have +<li><strong>flag_bases</strong> (<em>list of two int</em><em>, </em><em>default None</em>) – If provided, the output dataframe will replace results that have been calculated on (eff.) bases below the first int with <code class="docutils literal"><span class="pre">'**'</span></code> and mark results in columns with bases below the second int with <code class="docutils literal"><span class="pre">'*'</span></code></li> @@ -726,7 +738,7 @@ <h1>quantify.engine<a class="headerlink" href="#quantify-engine" title="Permalin <script type="text/javascript" src="../../_static/underscore.js"></script> <script type="text/javascript" src="../../_static/doctools.js"></script> <script type="text/javascript" src="../../_static/custom.js"></script> - <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> diff --git a/docs/API/_build/html/sites/api_ref/stack.html b/docs/API/_build/html/sites/api_ref/stack.html index bb72939b6..4fc379476 100644 --- a/docs/API/_build/html/sites/api_ref/stack.html +++ b/docs/API/_build/html/sites/api_ref/stack.html @@ -35,7 +35,10 @@ <link rel="index" title="Index" href="../../genindex.html"/> <link rel="search" title="Search" href="../../search.html"/> - <link rel="top" title="Quantipy 0.1.3 documentation" href="../../index.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../index.html"/> + <link rel="up" title="API references" href="00overview.html"/> + <link rel="next" title="View" href="View.html"/> + <link rel="prev" title="Rim" href="Rim_scheme.html"/> <script src="../../_static/js/modernizr.min.js"></script> @@ -87,11 +90,20 @@ <h3>Quick search</h3> - <ul> + <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="../release_notes/00_overview.html">Release notes</a><ul> -<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Latest (15/09/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Latest (01/10/2018)</a></li> <li class="toctree-l2"><a class="reference internal" href="../release_notes/02_archive.html">Archived release notes</a><ul> -<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#latest-31-08-2017">Latest (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> <li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> @@ -192,7 +204,7 @@ <h3>Quick search</h3> <li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> -<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> <li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> @@ -282,13 +294,14 @@ <h3>Quick search</h3> </li> </ul> </li> -<li class="toctree-l1"><a class="reference internal" href="00overview.html">API references</a><ul> +<li class="toctree-l1 current"><a class="reference internal" href="00overview.html">API references</a><ul class="current"> <li class="toctree-l2"><a class="reference internal" href="Chain.html">Chain</a></li> <li class="toctree-l2"><a class="reference internal" href="Cluster.html">Cluster</a></li> <li class="toctree-l2"><a class="reference internal" href="DataSet.html">DataSet</a></li> <li class="toctree-l2"><a class="reference internal" href="quantify_engine.html">quantify.engine</a></li> <li class="toctree-l2"><a class="reference internal" href="QuantipyViews.html">QuantipyViews</a></li> <li class="toctree-l2"><a class="reference internal" href="Rim_scheme.html">Rim</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Stack</a></li> <li class="toctree-l2"><a class="reference internal" href="View.html">View</a></li> <li class="toctree-l2"><a class="reference internal" href="ViewMapper.html">ViewMapper</a></li> </ul> @@ -323,11 +336,13 @@ <h3>Quick search</h3> <ul class="wy-breadcrumbs"> <li><a href="../../index.html">Docs</a> »</li> + <li><a href="00overview.html">API references</a> »</li> + <li>Stack</li> <li class="wy-breadcrumbs-aside"> - <a href="../../_sources/sites/api_ref/stack.rst.txt" rel="nofollow"> View page source</a> + <a href="../../_sources/sites/api_ref/Stack.rst.txt" rel="nofollow"> View page source</a> </li> @@ -363,9 +378,9 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>data_key</strong> (<em>str</em>) – The reference name for a data source connected to the Stack.</li> -<li><strong>data</strong> (<em>pandas.DataFrame</em>) – The input (case) data source.</li> -<li><strong>meta</strong> (<em>dict</em><em> or </em><em>OrderedDict</em>) – A quantipy compatible metadata source that describes the case data.</li> +<li><strong>data_key</strong> (<em>str</em>) – The reference name for a data source connected to the Stack.</li> +<li><strong>data</strong> (<em>pandas.DataFrame</em>) – The input (case) data source.</li> +<li><strong>meta</strong> (<em>dict</em><em> or </em><em>OrderedDict</em>) – A quantipy compatible metadata source that describes the case data.</li> </ul> </td> </tr> @@ -395,14 +410,14 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> </td> </tr> <tr class="field-even field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>data_keys</strong> (<em>str</em><em>, </em><em>optional</em>) – The data_key to be added to. If none is given, the method will try +<li><strong>data_keys</strong> (<em>str</em><em>, </em><em>optional</em>) – The data_key to be added to. If none is given, the method will try to add to all data_keys found in the Stack.</li> -<li><strong>filters</strong> (<em>list of str describing filter defintions</em><em>, </em><a class="reference internal" href="QuantipyViews.html#quantipy.QuantipyViews.default" title="quantipy.QuantipyViews.default"><em>default</em></a><em> [</em><em>'no_filter'</em><em>]</em><em></em>) – The string must be a valid input for the +<li><strong>filters</strong> (<em>list of str describing filter defintions</em><em>, </em><a class="reference internal" href="QuantipyViews.html#quantipy.QuantipyViews.default" title="quantipy.QuantipyViews.default"><em>default</em></a><em> [</em><em>'no_filter'</em><em>]</em>) – The string must be a valid input for the pandas.DataFrame.query() method.</li> -<li><strong>y</strong> (<em>x</em><em>,</em><em></em>) – The x and y variables to constrcut Links from.</li> -<li><strong>views</strong> (<em>list of view method names.</em>) – Can be any of Quantipy’s preset Views or the names of created +<li><strong>y</strong> (<em>x</em><em>,</em>) – The x and y variables to constrcut Links from.</li> +<li><strong>views</strong> (<em>list of view method names.</em>) – Can be any of Quantipy’s preset Views or the names of created view method specifications.</li> -<li><strong>weights</strong> (<em>list</em><em>, </em><em>optional</em>) – The names of weight variables to consider in the data aggregation +<li><strong>weights</strong> (<em>list</em><em>, </em><em>optional</em>) – The names of weight variables to consider in the data aggregation process. Weight variables must be of type <code class="docutils literal"><span class="pre">float</span></code>.</li> </ul> </td> @@ -419,15 +434,15 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> <dl class="method"> <dt id="quantipy.Stack.add_nets"> -<code class="descname">add_nets</code><span class="sig-paren">(</span><em>on_vars</em>, <em>net_map</em>, <em>expand=None</em>, <em>calc=None</em>, <em>text_prefix='Net:'</em>, <em>checking_cluster=None</em>, <em>_batches='all'</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Stack.add_nets" title="Permalink to this definition">¶</a></dt> +<code class="descname">add_nets</code><span class="sig-paren">(</span><em>on_vars</em>, <em>net_map</em>, <em>expand=None</em>, <em>calc=None</em>, <em>text_prefix='Net:'</em>, <em>checking_cluster=None</em>, <em>_batches='all'</em>, <em>recode='auto'</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Stack.add_nets" title="Permalink to this definition">¶</a></dt> <dd><p>Add a net-like view to a specified collection of x keys of the stack.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>on_vars</strong> (<em>list</em>) – The list of x variables to add the view to.</li> -<li><strong>net_map</strong> (<em>list of dicts</em>) – <p>The listed dicts must map the net/band text label to lists of +<li><strong>on_vars</strong> (<em>list</em>) – The list of x variables to add the view to.</li> +<li><strong>net_map</strong> (<em>list of dicts</em>) – <p>The listed dicts must map the net/band text label to lists of categorical answer codes to group together, e.g.:</p> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">[{</span><span class="s1">'Top3'</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]},</span> <span class="gp">... </span> <span class="p">{</span><span class="s1">'Bottom3'</span><span class="p">:</span> <span class="p">[</span><span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">]}]</span> @@ -441,11 +456,11 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> </pre></div> </div> </li> -<li><strong>expand</strong> (<em>{'before'</em><em>, </em><em>'after'}</em><em>, </em><em>default None</em>) – If provided, the view will list the net-defining codes after or before -the computed net groups (i.e. “overcode” nets).</li> -<li><strong>calc</strong> (<em>dict</em><em>, </em><em>default None</em>) – <p>A dictionary that is attaching a text label to a calculation expression +<li><strong>expand</strong> (<em>{'before'</em><em>, </em><em>'after'}</em><em>, </em><em>default None</em>) – If provided, the view will list the net-defining codes after or before +the computed net groups (i.e. “overcode” nets).</li> +<li><strong>calc</strong> (<em>dict</em><em>, </em><em>default None</em>) – <p>A dictionary that is attaching a text label to a calculation expression using the the net definitions. The nets are referenced as per -‘net_1’, ‘net_2’, ‘net_3’, ... . +‘net_1’, ‘net_2’, ‘net_3’, … . Supported calculation expressions are add, sub, div, mul. Example:</p> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">{</span><span class="s1">'calc'</span><span class="p">:</span> <span class="p">(</span><span class="s1">'net_1'</span><span class="p">,</span> <span class="n">add</span><span class="p">,</span> <span class="s1">'net_2'</span><span class="p">),</span> <span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="s1">'UK CALC LAB'</span><span class="p">,</span> <span class="gp">... </span> <span class="s1">'da-DK'</span><span class="p">:</span> <span class="s1">'DA CALC LAB'</span><span class="p">,</span> @@ -453,12 +468,19 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> </pre></div> </div> </li> -<li><strong>text_prefix</strong> (<em>str</em><em>, </em><em>default 'Net:'</em>) – By default each code grouping/net will have its <code class="docutils literal"><span class="pre">text</span></code> label prefixed -with ‘Net: ‘. Toggle by passing None (or an empty str, ‘’).</li> -<li><strong>checking_cluster</strong> (<a class="reference internal" href="Cluster.html#quantipy.Cluster" title="quantipy.Cluster"><em>quantipy.Cluster</em></a><em>, </em><em>default None</em>) – When provided, an automated checking aggregation will be added to the +<li><strong>text_prefix</strong> (<em>str</em><em>, </em><em>default 'Net:'</em>) – By default each code grouping/net will have its <code class="docutils literal"><span class="pre">text</span></code> label prefixed +with ‘Net: ‘. Toggle by passing None (or an empty str, ‘’).</li> +<li><strong>checking_cluster</strong> (<a class="reference internal" href="Cluster.html#quantipy.Cluster" title="quantipy.Cluster"><em>quantipy.Cluster</em></a><em>, </em><em>default None</em>) – When provided, an automated checking aggregation will be added to the <code class="docutils literal"><span class="pre">Cluster</span></code> instance.</li> -<li><strong>_batches</strong> (<em>str</em><em> or </em><em>list of str</em>) – Only for <code class="docutils literal"><span class="pre">qp.Links</span></code> that are defined in this <code class="docutils literal"><span class="pre">qp.Batch</span></code> +<li><strong>_batches</strong> (<em>str</em><em> or </em><em>list of str</em>) – Only for <code class="docutils literal"><span class="pre">qp.Links</span></code> that are defined in this <code class="docutils literal"><span class="pre">qp.Batch</span></code> instances views are added.</li> +<li><strong>recode</strong> ({‘extend_codes’, ‘drop_codes’, ‘collect_codes’, <a class="reference external" href="mailto:'collect_codes%40cat_name">‘collect_codes<span>@</span>cat_name</a>’},) – default ‘auto’ +Adds variable with nets as codes to DataSet/Stack. If ‘extend_codes’, +codes are extended with nets. If ‘drop_codes’, new variable only +contains nets as codes. If ‘collect_codes’ or <a class="reference external" href="mailto:'collect_codes%40cat_name">‘collect_codes<span>@</span>cat_name</a>’ +the variable contains nets and another category that summarises all +codes which are not included in any net. If no cat_name is provided, +‘Other’ is taken as default</li> </ul> </td> </tr> @@ -474,31 +496,34 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> <dl class="method"> <dt id="quantipy.Stack.add_stats"> -<code class="descname">add_stats</code><span class="sig-paren">(</span><em>on_vars, stats=['mean'], other_source=None, rescale=None, drop=True, exclude=None, factor_labels=True, custom_text=None, checking_cluster=None, _batches='all', verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Stack.add_stats" title="Permalink to this definition">¶</a></dt> +<code class="descname">add_stats</code><span class="sig-paren">(</span><em>on_vars, stats=['mean'], other_source=None, rescale=None, drop=True, exclude=None, factor_labels=True, custom_text=None, checking_cluster=None, _batches='all', recode=False, verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Stack.add_stats" title="Permalink to this definition">¶</a></dt> <dd><p>Add a descriptives view to a specified collection of xks of the stack.</p> -<p>Valid descriptives views: {‘mean’, ‘stddev’, ‘min’, ‘max’, ‘median’, ‘sem’}</p> +<p>Valid descriptives views: {‘mean’, ‘stddev’, ‘min’, ‘max’, ‘median’, ‘sem’}</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>on_vars</strong> (<em>list</em>) – The list of x variables to add the view to.</li> -<li><strong>stats</strong> (list of str, default <code class="docutils literal"><span class="pre">['mean']</span></code>) – The metrics to compute and add as a view.</li> -<li><strong>other_source</strong> (<em>str</em>) – If provided the Link’s x-axis variable will be swapped with the +<li><strong>on_vars</strong> (<em>list</em>) – The list of x variables to add the view to.</li> +<li><strong>stats</strong> (list of str, default <code class="docutils literal"><span class="pre">['mean']</span></code>) – The metrics to compute and add as a view.</li> +<li><strong>other_source</strong> (<em>str</em>) – If provided the Link’s x-axis variable will be swapped with the (numerical) variable provided. This can be used to attach statistics of a different variable to a Link definition.</li> -<li><strong>rescale</strong> (<em>dict</em>) – A dict that maps old to new codes, e.g. {1: 5, 2: 4, 3: 3, 4: 2, 5: 1}</li> -<li><strong>drop</strong> (<em>bool</em><em>, </em><em>default True</em>) – If <code class="docutils literal"><span class="pre">rescale</span></code> is provided all codes that are not mapped will be +<li><strong>rescale</strong> (<em>dict</em>) – A dict that maps old to new codes, e.g. {1: 5, 2: 4, 3: 3, 4: 2, 5: 1}</li> +<li><strong>drop</strong> (<em>bool</em><em>, </em><em>default True</em>) – If <code class="docutils literal"><span class="pre">rescale</span></code> is provided all codes that are not mapped will be ignored in the computation.</li> -<li><strong>exclude</strong> (<em>list</em>) – Codes/values to ignore in the computation.</li> -<li><strong>factor_lables</strong> (<em>bool</em><em>, </em><em>default True</em>) – If True, will write the (rescaled) factor values next to the -category text label.</li> -<li><strong>custom_text</strong> (<em>str</em><em>, </em><em>default None</em>) – A custom string affix to put at the end of the requested statistics’ +<li><strong>exclude</strong> (<em>list</em>) – Codes/values to ignore in the computation.</li> +<li><strong>factor_labels</strong> (<em>bool / str</em><em>, </em><em>default True</em>) – Writes the (rescaled) factor values next to the category text label. +If True, square-brackets are used. If ‘()’, normal brackets are used.</li> +<li><strong>custom_text</strong> (<em>str</em><em>, </em><em>default None</em>) – A custom string affix to put at the end of the requested statistics’ names.</li> -<li><strong>checking_cluster</strong> (<a class="reference internal" href="Cluster.html#quantipy.Cluster" title="quantipy.Cluster"><em>quantipy.Cluster</em></a><em>, </em><em>default None</em>) – When provided, an automated checking aggregation will be added to the +<li><strong>checking_cluster</strong> (<a class="reference internal" href="Cluster.html#quantipy.Cluster" title="quantipy.Cluster"><em>quantipy.Cluster</em></a><em>, </em><em>default None</em>) – When provided, an automated checking aggregation will be added to the <code class="docutils literal"><span class="pre">Cluster</span></code> instance.</li> -<li><strong>_batches</strong> (<em>str</em><em> or </em><em>list of str</em>) – Only for <code class="docutils literal"><span class="pre">qp.Links</span></code> that are defined in this <code class="docutils literal"><span class="pre">qp.Batch</span></code> +<li><strong>_batches</strong> (<em>str</em><em> or </em><em>list of str</em>) – Only for <code class="docutils literal"><span class="pre">qp.Links</span></code> that are defined in this <code class="docutils literal"><span class="pre">qp.Batch</span></code> instances views are added.</li> +<li><strong>recode</strong> (<em>bool</em><em>, </em><em>default False</em>) – Create a new variable that contains only the values +which are needed for the stat computation. The values and the included +data will be rescaled.</li> </ul> </td> </tr> @@ -521,7 +546,7 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>_batches</strong> (<em>str</em><em> or </em><em>list of str</em>) – Only for <code class="docutils literal"><span class="pre">qp.Links</span></code> that are defined in this <code class="docutils literal"><span class="pre">qp.Batch</span></code> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>_batches</strong> (<em>str</em><em> or </em><em>list of str</em>) – Only for <code class="docutils literal"><span class="pre">qp.Links</span></code> that are defined in this <code class="docutils literal"><span class="pre">qp.Batch</span></code> instances views are added.</td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td> @@ -534,22 +559,25 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> <dl class="method"> <dt id="quantipy.Stack.aggregate"> -<code class="descname">aggregate</code><span class="sig-paren">(</span><em>views</em>, <em>unweighted_base=True</em>, <em>categorize=[]</em>, <em>batches='all'</em>, <em>xs=None</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Stack.aggregate" title="Permalink to this definition">¶</a></dt> +<code class="descname">aggregate</code><span class="sig-paren">(</span><em>views</em>, <em>unweighted_base=True</em>, <em>categorize=[]</em>, <em>batches='all'</em>, <em>xs=None</em>, <em>bases={}</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Stack.aggregate" title="Permalink to this definition">¶</a></dt> <dd><p>Add views to all defined <code class="docutils literal"><span class="pre">qp.Link</span></code> in <code class="docutils literal"><span class="pre">qp.Stack</span></code>.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>views</strong> (<em>str</em><em> or </em><em>list of str</em><em> or </em><em>qp.ViewMapper</em>) – <code class="docutils literal"><span class="pre">views</span></code> that are added.</li> -<li><strong>unweighted_base</strong> (<em>bool</em><em>, </em><em>default True</em>) – If True, unweighted ‘cbase’ is added to all non-arrays.</li> -<li><strong>categorize</strong> (<em>str</em><em> or </em><em>list of str</em>) – Determines how numerical data is handled: If provided, the +<li><strong>views</strong> (<em>str</em><em> or </em><em>list of str</em><em> or </em><em>qp.ViewMapper</em>) – <code class="docutils literal"><span class="pre">views</span></code> that are added.</li> +<li><strong>unweighted_base</strong> (<em>bool</em><em>, </em><em>default True</em>) – If True, unweighted ‘cbase’ is added to all non-arrays. +This parameter will be deprecated in future, please use bases +instead.</li> +<li><strong>categorize</strong> (<em>str</em><em> or </em><em>list of str</em>) – Determines how numerical data is handled: If provided, the variables will get counts and percentage aggregations (<code class="docutils literal"><span class="pre">'counts'</span></code>, <code class="docutils literal"><span class="pre">'c%'</span></code>) alongside the <code class="docutils literal"><span class="pre">'cbase'</span></code> view. If False, only <code class="docutils literal"><span class="pre">'cbase'</span></code> views are generated for non-categorical types.</li> -<li><strong>batches</strong> (<em>str/ list of str</em><em>, </em><em>default 'all'</em>) – Name(s) of <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance(s) that are used to aggregate the +<li><strong>batches</strong> (<em>str/ list of str</em><em>, </em><em>default 'all'</em>) – Name(s) of <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance(s) that are used to aggregate the <code class="docutils literal"><span class="pre">qp.Stack</span></code>.</li> -<li><strong>xs</strong> (<em>list of str</em>) – Names of variable, for which views are added.</li> +<li><strong>xs</strong> (<em>list of str</em>) – Names of variable, for which views are added.</li> +<li><strong>bases</strong> (<em>dict</em>) – Defines which bases should be aggregated, weighted or unweighted.</li> </ul> </td> </tr> @@ -563,6 +591,28 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> </table> </dd></dl> +<dl class="method"> +<dt id="quantipy.Stack.apply_meta_edits"> +<code class="descname">apply_meta_edits</code><span class="sig-paren">(</span><em>batch_name</em>, <em>data_key</em>, <em>filter_key=None</em>, <em>freeze=False</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Stack.apply_meta_edits" title="Permalink to this definition">¶</a></dt> +<dd><p>Take over meta_edits from Batch definitions.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> +<li><strong>batch_name</strong> (<em>str</em>) – Name of the Batch whose meta_edits are taken.</li> +<li><strong>data_key</strong> (<em>str</em>) – Accessing this metadata: <code class="docutils literal"><span class="pre">self[data_key].meta</span></code> +Batch definitions are takes from here and this metadata is modified.</li> +<li><strong>filter_key</strong> (<em>str</em><em>, </em><em>default None</em>) – Currently not implemented! +Accessing this metadata: <code class="docutils literal"><span class="pre">self[data_key][filter_key].meta</span></code> +Batch definitions are takes from here and this metadata is modified.</li> +</ul> +</td> +</tr> +</tbody> +</table> +</dd></dl> + <dl class="method"> <dt id="quantipy.Stack.cumulative_sum"> <code class="descname">cumulative_sum</code><span class="sig-paren">(</span><em>on_vars</em>, <em>_batches='all'</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Stack.cumulative_sum" title="Permalink to this definition">¶</a></dt> @@ -572,8 +622,8 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>on_vars</strong> (<em>list</em>) – The list of x variables to add the view to.</li> -<li><strong>_batches</strong> (<em>str</em><em> or </em><em>list of str</em>) – Only for <code class="docutils literal"><span class="pre">qp.Links</span></code> that are defined in this <code class="docutils literal"><span class="pre">qp.Batch</span></code> +<li><strong>on_vars</strong> (<em>list</em>) – The list of x variables to add the view to.</li> +<li><strong>_batches</strong> (<em>str</em><em> or </em><em>list of str</em>) – Only for <code class="docutils literal"><span class="pre">qp.Links</span></code> that are defined in this <code class="docutils literal"><span class="pre">qp.Batch</span></code> instances views are added.</li> </ul> </td> @@ -597,16 +647,16 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>columns</strong> (<em>index</em><em>,</em><em></em>) – optional +<li><strong>columns</strong> (<em>index</em><em>,</em>) – optional Controls the output representation by structuring a pivot-style table according to the index and column values.</li> -<li><strong>query</strong> (<em>str</em>) – A query string that is valid for the pandas.DataFrame.query() method.</li> -<li><strong>split_view_names</strong> (<em>bool</em><em>, </em><em>default False</em>) – If True, will create an output of unique view name notations split +<li><strong>query</strong> (<em>str</em>) – A query string that is valid for the pandas.DataFrame.query() method.</li> +<li><strong>split_view_names</strong> (<em>bool</em><em>, </em><em>default False</em>) – If True, will create an output of unique view name notations split up into their components.</li> </ul> </td> </tr> -<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>description</strong> – DataFrame summing the Stack’s structure in terms of Links and Views.</p> +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>description</strong> – DataFrame summing the Stack’s structure in terms of Links and Views.</p> </td> </tr> <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">pandas.DataFrame</p> @@ -616,6 +666,25 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> </table> </dd></dl> +<dl class="method"> +<dt id="quantipy.Stack.freeze_master_meta"> +<code class="descname">freeze_master_meta</code><span class="sig-paren">(</span><em>data_key</em>, <em>filter_key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Stack.freeze_master_meta" title="Permalink to this definition">¶</a></dt> +<dd><p>Save <code class="docutils literal"><span class="pre">.meta</span></code> in <code class="docutils literal"><span class="pre">.master_meta</span></code> for a defined data_key.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> +<li><strong>data_key</strong> (<em>str</em>) – Using: <code class="docutils literal"><span class="pre">self[data_key]</span></code></li> +<li><strong>filter_key</strong> (<em>str</em><em>, </em><em>default None</em>) – Currently not implemented! +Using: <code class="docutils literal"><span class="pre">self[data_key][filter_key]</span></code></li> +</ul> +</td> +</tr> +</tbody> +</table> +</dd></dl> + <dl class="staticmethod"> <dt id="quantipy.Stack.from_sav"> <em class="property">static </em><code class="descname">from_sav</code><span class="sig-paren">(</span><em>data_key</em>, <em>filename</em>, <em>name=None</em>, <em>path=None</em>, <em>ioLocale='en_US.UTF-8'</em>, <em>ioUtf8=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Stack.from_sav" title="Permalink to this definition">¶</a></dt> @@ -625,17 +694,17 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>data_key</strong> (<em>str</em>) – The data_key for the data and meta in the sav file.</li> -<li><strong>filename</strong> (<em>str</em>) – The name to the sav file.</li> -<li><strong>name</strong> (<em>str</em>) – A name for the sav (stored in the meta).</li> -<li><strong>path</strong> (<em>str</em>) – The path to the sav file.</li> -<li><strong>ioLocale</strong> (<em>str</em>) – The locale used in during the sav processing.</li> -<li><strong>ioUtf8</strong> (<em>bool</em>) – Boolean that indicates the mode in which text communicated to or +<li><strong>data_key</strong> (<em>str</em>) – The data_key for the data and meta in the sav file.</li> +<li><strong>filename</strong> (<em>str</em>) – The name to the sav file.</li> +<li><strong>name</strong> (<em>str</em>) – A name for the sav (stored in the meta).</li> +<li><strong>path</strong> (<em>str</em>) – The path to the sav file.</li> +<li><strong>ioLocale</strong> (<em>str</em>) – The locale used in during the sav processing.</li> +<li><strong>ioUtf8</strong> (<em>bool</em>) – Boolean that indicates the mode in which text communicated to or from the I/O module will be.</li> </ul> </td> </tr> -<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>stack</strong> – A stack instance that has a data_key with data and metadata +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>stack</strong> – A stack instance that has a data_key with data and metadata to run aggregations.</p> </td> </tr> @@ -655,10 +724,10 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>path_stack</strong> (<em>str</em>) – The full path to the .stack file that should be created, including +<li><strong>path_stack</strong> (<em>str</em>) – The full path to the .stack file that should be created, including the extension.</li> -<li><strong>compression</strong> (<em>{'gzip'}</em><em>, </em><em>default 'gzip'</em>) – The compression type that has been used saving the file.</li> -<li><strong>load_cache</strong> (<em>bool</em><em>, </em><em>default False</em>) – Loads MatrixCache into the Stack a .cache file is found.</li> +<li><strong>compression</strong> (<em>{'gzip'}</em><em>, </em><em>default 'gzip'</em>) – The compression type that has been used saving the file.</li> +<li><strong>load_cache</strong> (<em>bool</em><em>, </em><em>default False</em>) – Loads MatrixCache into the Stack a .cache file is found.</li> </ul> </td> </tr> @@ -672,6 +741,12 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> </table> </dd></dl> +<dl class="staticmethod"> +<dt id="quantipy.Stack.recode_from_net_def"> +<em class="property">static </em><code class="descname">recode_from_net_def</code><span class="sig-paren">(</span><em>dataset</em>, <em>on_vars</em>, <em>net_map</em>, <em>expand</em>, <em>recode='auto'</em>, <em>text_prefix='Net:'</em>, <em>verbose=True</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Stack.recode_from_net_def" title="Permalink to this definition">¶</a></dt> +<dd><p>Create variables from net definitions.</p> +</dd></dl> + <dl class="method"> <dt id="quantipy.Stack.reduce"> <code class="descname">reduce</code><span class="sig-paren">(</span><em>data_keys=None</em>, <em>filters=None</em>, <em>x=None</em>, <em>y=None</em>, <em>variables=None</em>, <em>views=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Stack.reduce" title="Permalink to this definition">¶</a></dt> @@ -680,7 +755,7 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>filters</strong><strong>, </strong><strong>x</strong><strong>, </strong><strong>y</strong><strong>, </strong><strong>views</strong> (<em>data_keys</em><em>,</em><em></em>) – </td> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>filters</strong><strong>, </strong><strong>x</strong><strong>, </strong><strong>y</strong><strong>, </strong><strong>views</strong> (<em>data_keys</em><em>,</em>) – </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td> </tr> @@ -693,7 +768,7 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> <dl class="method"> <dt id="quantipy.Stack.refresh"> <code class="descname">refresh</code><span class="sig-paren">(</span><em>data_key</em>, <em>new_data_key=''</em>, <em>new_weight=None</em>, <em>new_data=None</em>, <em>new_meta=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Stack.refresh" title="Permalink to this definition">¶</a></dt> -<dd><p>Re-run all or a portion of Stack’s aggregations for a given data key.</p> +<dd><p>Re-run all or a portion of Stack’s aggregations for a given data key.</p> <p>refresh() can be used to re-weight the data using a new case data weight variable or to re-run all aggregations based on a changed source data version (e.g. after cleaning the file/ dropping cases) or a @@ -709,13 +784,13 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>data_key</strong> (<em>str</em>) – The Links’ data key to be modified.</li> -<li><strong>new_data_key</strong> (<em>str</em><em>, </em><em>default ''</em>) – Controls if the existing data key’s files and aggregations will be +<li><strong>data_key</strong> (<em>str</em>) – The Links’ data key to be modified.</li> +<li><strong>new_data_key</strong> (<em>str</em><em>, </em><em>default ''</em>) – Controls if the existing data key’s files and aggregations will be overwritten or stored via a new data key.</li> -<li><strong>new_weight</strong> (<em>str</em>) – The name of a new weight variable used to re-aggregate the Links.</li> -<li><strong>new_data</strong> (<em>pandas.DataFrame</em>) – The case data source. If None is given, the +<li><strong>new_weight</strong> (<em>str</em>) – The name of a new weight variable used to re-aggregate the Links.</li> +<li><strong>new_data</strong> (<em>pandas.DataFrame</em>) – The case data source. If None is given, the original case data found for the data key will be used.</li> -<li><strong>new_meta</strong> (<em>quantipy meta document</em>) – A meta data source associated with the case data. If None is given, +<li><strong>new_meta</strong> (<em>quantipy meta document</em>) – A meta data source associated with the case data. If None is given, the original meta definition found for the data key will be used.</li> </ul> </td> @@ -738,7 +813,7 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> -<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data_keys</strong> (<em>str</em><em> or </em><em>list of str</em>) – The data keys to remove.</td> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>data_keys</strong> (<em>str</em><em> or </em><em>list of str</em>) – The data keys to remove.</td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"></td> </tr> @@ -748,6 +823,26 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> </table> </dd></dl> +<dl class="method"> +<dt id="quantipy.Stack.restore_meta"> +<code class="descname">restore_meta</code><span class="sig-paren">(</span><em>data_key</em>, <em>filter_key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Stack.restore_meta" title="Permalink to this definition">¶</a></dt> +<dd><p>Restore the <code class="docutils literal"><span class="pre">.master_meta</span></code> for a defined data_key if it exists.</p> +<p>Undo self.apply_meta_edits()</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> +<li><strong>data_key</strong> (<em>str</em>) – Accessing this metadata: <code class="docutils literal"><span class="pre">self[data_key].meta</span></code></li> +<li><strong>filter_key</strong> (<em>str</em><em>, </em><em>default None</em>) – Currently not implemented! +Accessing this metadata: <code class="docutils literal"><span class="pre">self[data_key][filter_key].meta</span></code></li> +</ul> +</td> +</tr> +</tbody> +</table> +</dd></dl> + <dl class="method"> <dt id="quantipy.Stack.save"> <code class="descname">save</code><span class="sig-paren">(</span><em>path_stack</em>, <em>compression='gzip'</em>, <em>store_cache=True</em>, <em>decode_str=False</em>, <em>dataset=False</em>, <em>describe=False</em><span class="sig-paren">)</span><a class="headerlink" href="#quantipy.Stack.save" title="Permalink to this definition">¶</a></dt> @@ -757,15 +852,15 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>path_stack</strong> (<em>str</em>) – The full path to the .stack file that should be created, including +<li><strong>path_stack</strong> (<em>str</em>) – The full path to the .stack file that should be created, including the extension.</li> -<li><strong>compression</strong> (<em>{'gzip'}</em><em>, </em><em>default 'gzip'</em>) – The intended compression type.</li> -<li><strong>store_cache</strong> (<em>bool</em><em>, </em><em>default True</em>) – Stores the MatrixCache in a file in the same location.</li> -<li><strong>decode_str</strong> (<em>bool</em><em>, </em><em>default=True</em>) – If True the unicoder function will be used to decode all str +<li><strong>compression</strong> (<em>{'gzip'}</em><em>, </em><em>default 'gzip'</em>) – The intended compression type.</li> +<li><strong>store_cache</strong> (<em>bool</em><em>, </em><em>default True</em>) – Stores the MatrixCache in a file in the same location.</li> +<li><strong>decode_str</strong> (<em>bool</em><em>, </em><em>default=True</em>) – If True the unicoder function will be used to decode all str objects found anywhere in the meta document/s.</li> -<li><strong>dataset</strong> (<em>bool</em><em>, </em><em>default=False</em>) – If True a json/csv will be saved parallel to the saved stack +<li><strong>dataset</strong> (<em>bool</em><em>, </em><em>default=False</em>) – If True a json/csv will be saved parallel to the saved stack for each data key in the stack.</li> -<li><strong>describe</strong> (<em>bool</em><em>, </em><em>default=False</em>) – If True the result of stack.describe().to_excel() will be +<li><strong>describe</strong> (<em>bool</em><em>, </em><em>default=False</em>) – If True the result of stack.describe().to_excel() will be saved parallel to the saved stack.</li> </ul> </td> @@ -789,13 +884,13 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> -<li><strong>data_key</strong> (<em>str</em>) – The reference name of a case data source hold by the Stack instance.</li> -<li><strong>only_type</strong> (<em>{'int'</em><em>, </em><em>'float'</em><em>, </em><em>'single'</em><em>, </em><em>'delimited set'</em><em>, </em><em>'string'</em><em>,</em><em></em>) – ‘date’, time’, ‘array’}, optional +<li><strong>data_key</strong> (<em>str</em>) – The reference name of a case data source hold by the Stack instance.</li> +<li><strong>only_type</strong> (<em>{'int'</em><em>, </em><em>'float'</em><em>, </em><em>'single'</em><em>, </em><em>'delimited set'</em><em>, </em><em>'string'</em><em>,</em>) – ‘date’, time’, ‘array’}, optional Will restrict the output to the given data type.</li> </ul> </td> </tr> -<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>types</strong> – A summary of variable names mapped to their data types, in form of +<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>types</strong> – A summary of variable names mapped to their data types, in form of {type_name: [variable names]} or a list of variable names confirming only_type.</p> </td> @@ -816,6 +911,15 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> </div> <footer> + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="View.html" class="btn btn-neutral float-right" title="View" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="Rim_scheme.html" class="btn btn-neutral" title="Rim" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + <hr/> @@ -853,7 +957,7 @@ <h1>Stack<a class="headerlink" href="#stack" title="Permalink to this headline"> <script type="text/javascript" src="../../_static/underscore.js"></script> <script type="text/javascript" src="../../_static/doctools.js"></script> <script type="text/javascript" src="../../_static/custom.js"></script> - <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> diff --git a/docs/API/_build/html/sites/lib_doc/batch/00_overview.html b/docs/API/_build/html/sites/lib_doc/batch/00_overview.html new file mode 100644 index 000000000..18493daba --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/batch/00_overview.html @@ -0,0 +1,461 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Batch — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="next" title="Creating/ Loading a qp.Batch instance" href="01_create_load.html"/> + <link rel="prev" title="Custom data recoding" href="../dataprocessing/07_custom_recoding.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="current reference internal" href="#"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><code class="docutils literal"><span class="pre">Batch</span></code></li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/batch/00_overview.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="section" id="batch"> +<h1><code class="docutils literal"><span class="pre">Batch</span></code><a class="headerlink" href="#batch" title="Permalink to this headline">¶</a></h1> +<p><code class="docutils literal"><span class="pre">qp.Batch</span></code> is a subclass of <code class="docutils literal"><span class="pre">qp.DataSet</span></code> and is a container for +structuring a <code class="docutils literal"><span class="pre">qp.Link</span></code> collection’s specifications.</p> +<p><code class="docutils literal"><span class="pre">qp.Batch</span></code> is not only a subclass of <code class="docutils literal"><span class="pre">qp.DataSet</span></code>, it also takes a +DataSet instance as input argument, inheriting a few of its attributes, e.g. +<code class="docutils literal"><span class="pre">_meta</span></code>, <code class="docutils literal"><span class="pre">_data</span></code>, <code class="docutils literal"><span class="pre">valid_tks</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code>. +All other <code class="docutils literal"><span class="pre">Batch</span></code> attributes are used as construction plans for populating a +<code class="docutils literal"><span class="pre">qp.Stack</span></code>, these get stored in the belonging <code class="docutils literal"><span class="pre">DataSet</span></code> meta component in +<code class="docutils literal"><span class="pre">_meta['sets']['batches'][batchname]</span></code>.</p> +<p>In general, it does not matter in which order <code class="docutils literal"><span class="pre">Batch</span></code> attributes are set by +methods, the class ensures that all attributes are kept consistent.</p> +<p>All next sections are working with the following <code class="docutils literal"><span class="pre">qp.DataSet</span></code> instance:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">quantipy</span> <span class="k">as</span> <span class="nn">qp</span> + +<span class="n">dataset</span> <span class="o">=</span> <span class="n">qp</span><span class="o">.</span><span class="n">DataSet</span><span class="p">(</span><span class="s1">'Example Data (A)'</span><span class="p">)</span> +<span class="n">dataset</span><span class="o">.</span><span class="n">read_quantipy</span><span class="p">(</span><span class="s1">'Example Data (A).json'</span><span class="p">,</span> <span class="s1">'Example Data (A).csv'</span><span class="p">)</span> +</pre></div> +</div> +<p>The json and csv files you can find in <code class="docutils literal"><span class="pre">quantipy/tests</span></code>.</p> +<div class="toctree-wrapper compound"> +<ul> +<li class="toctree-l1"><a class="reference internal" href="01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l1"><a class="reference internal" href="02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l2"><a class="reference internal" href="02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="01_create_load.html" class="btn btn-neutral float-right" title="Creating/ Loading a qp.Batch instance" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="../dataprocessing/07_custom_recoding.html" class="btn btn-neutral" title="Custom data recoding" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/batch/01_create_load.html b/docs/API/_build/html/sites/lib_doc/batch/01_create_load.html new file mode 100644 index 000000000..4d0180279 --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/batch/01_create_load.html @@ -0,0 +1,449 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Creating/ Loading a qp.Batch instance — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="Batch" href="00_overview.html"/> + <link rel="next" title="Adding variables to a qp.Batch instance" href="02_variables.html"/> + <link rel="prev" title="Batch" href="00_overview.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul class="current"> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a> »</li> + + <li>Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/batch/01_create_load.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="creating-loading-a-qp-batch-instance"> +<h1>Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance<a class="headerlink" href="#creating-loading-a-qp-batch-instance" title="Permalink to this headline">¶</a></h1> +<p>As mentioned, a <code class="docutils literal"><span class="pre">Batch</span></code> instance has a close connection to its belonging +<code class="docutils literal"><span class="pre">DataSet</span></code> instance and we can easily create a new <code class="docutils literal"><span class="pre">Batch</span></code> from a <code class="docutils literal"><span class="pre">DataSet</span></code> +as per:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">batch1</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">add_batch</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">'batch1'</span><span class="p">)</span> +<span class="n">batch2</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">add_batch</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">'batch2'</span><span class="p">,</span> <span class="n">ci</span><span class="o">=</span><span class="p">[</span><span class="s1">'c'</span><span class="p">],</span> <span class="n">weights</span><span class="o">=</span><span class="s1">'weight'</span><span class="p">)</span> +</pre></div> +</div> +<p>It is also possible to load an already existing instance out of the meta +stored in <code class="docutils literal"><span class="pre">dataset._meta['sets']['batches']</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">batch</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">get_batch</span><span class="p">(</span><span class="s1">'batch1'</span><span class="p">)</span> +</pre></div> +</div> +<p>Both methods, <code class="docutils literal"><span class="pre">.add_batch()</span></code> and <code class="docutils literal"><span class="pre">.get_batch()</span></code>, are an easier way to +use the <code class="docutils literal"><span class="pre">__init__()</span></code> method of <code class="docutils literal"><span class="pre">qp.Batch</span></code>.</p> +<p>An other way to get a new <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance is to copy an existing one, in +that case all added open ends are removed from the new instance:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">copy_batch</span> <span class="o">=</span> <span class="n">batch</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="s1">'copy_of_batch1'</span><span class="p">)</span> +</pre></div> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="02_variables.html" class="btn btn-neutral float-right" title="Adding variables to a qp.Batch instance" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="00_overview.html" class="btn btn-neutral" title="Batch" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/batch/02_variables.html b/docs/API/_build/html/sites/lib_doc/batch/02_variables.html new file mode 100644 index 000000000..1bea15429 --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/batch/02_variables.html @@ -0,0 +1,535 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Adding variables to a qp.Batch instance — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="Batch" href="00_overview.html"/> + <link rel="next" title="Set properties of a qp.Batch" href="03_properties.html"/> + <link rel="prev" title="Creating/ Loading a qp.Batch instance" href="01_create_load.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a> »</li> + + <li>Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/batch/02_variables.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="adding-variables-to-a-qp-batch-instance"> +<h1>Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance<a class="headerlink" href="#adding-variables-to-a-qp-batch-instance" title="Permalink to this headline">¶</a></h1> +<div class="section" id="x-keys-and-y-keys"> +<h2>x-keys and y-keys<a class="headerlink" href="#x-keys-and-y-keys" title="Permalink to this headline">¶</a></h2> +<p>The included variables in a <code class="docutils literal"><span class="pre">Batch</span></code> constitute the main structure for the +<code class="docutils literal"><span class="pre">qp.Stack</span></code> construction plan. Variables can be added as x-keys or y-keys, for +arrays all belonging items are automatically added and the <code class="docutils literal"><span class="pre">qp.Stack</span></code> gets +populated with all cross-tabulations of these keys:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">add_x</span><span class="p">([</span><span class="s1">'q1'</span><span class="p">,</span> <span class="s1">'q2'</span><span class="p">,</span> <span class="s1">'q6'</span><span class="p">])</span> +<span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">add_y</span><span class="p">([</span><span class="s1">'gender'</span><span class="p">,</span> <span class="s1">'q1'</span><span class="p">])</span> +<span class="go">Array summaries setup: Creating ['q6'].</span> +</pre></div> +</div> +<p>x-specific y-keys can be produced by manipulating the main y-keys, this edit +can be extending or replacing the existing keys:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">extend_y</span><span class="p">([</span><span class="s1">'locality'</span><span class="p">,</span> <span class="s1">'ethnicity'</span><span class="p">],</span> <span class="n">on</span><span class="o">=</span><span class="p">[</span><span class="s1">'q1'</span><span class="p">])</span> +<span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">replace_y</span><span class="p">([</span><span class="s1">'locality'</span><span class="p">,</span> <span class="s1">'ethnicity'</span><span class="p">],</span> <span class="n">on</span><span class="o">=</span><span class="p">[</span><span class="s1">'q2'</span><span class="p">])</span> +</pre></div> +</div> +<p>With these settings the construction plan looks like that:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">print</span> <span class="n">batch</span><span class="o">.</span><span class="n">x_y_map</span> +<span class="go">OrderedDict([('q1', ['@', 'gender', 'q1', 'locality', 'ethnicity']),</span> +<span class="go"> ('q2', ['locality', 'ethnicity']),</span> +<span class="go"> ('q6', ['@']),</span> +<span class="go"> (u'q6_1', ['@', 'gender', 'q1']),</span> +<span class="go"> (u'q6_2', ['@', 'gender', 'q1']),</span> +<span class="go"> (u'q6_3', ['@', 'gender', 'q1'])])</span> +</pre></div> +</div> +</div> +<div class="section" id="arrays"> +<h2>Arrays<a class="headerlink" href="#arrays" title="Permalink to this headline">¶</a></h2> +<p>A special case exists if the added variables contain arrays. As default for all +arrays in x-keys array summaries are created (array as x-key and <code class="docutils literal"><span class="pre">'@'</span></code>-referenced total as +y-key), see the output below (<code class="docutils literal"><span class="pre">Array</span> <span class="pre">summaries</span> <span class="pre">setup:</span> <span class="pre">Creating</span> <span class="pre">['q6'].</span></code>). +If array summaries are requested only for a selection of variables or for none, +use <code class="docutils literal"><span class="pre">.make_summaries()</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">make_summaries</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span> +<span class="go">Array summaries setup: Creating no summaries!</span> +</pre></div> +</div> +<p>Arrays can also be transposed (<code class="docutils literal"><span class="pre">'@'</span></code>-referenced total as x-key and array name +as y-key). If they are not in the batch summary list before, they are +automatically added and depending on the <code class="docutils literal"><span class="pre">replace</span></code> parameter only the +transposed or both types of summaries are added to the <code class="docutils literal"><span class="pre">qp.Stack</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">transpose_array</span><span class="p">(</span><span class="s1">'q6'</span><span class="p">,</span> <span class="n">replace</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +<span class="go">Array summaries setup: Creating ['q6'].</span> +</pre></div> +</div> +<p>The construction plan now shows that both summary types are included:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">print</span> <span class="n">batch</span><span class="o">.</span><span class="n">x_y_map</span> +<span class="go">OrderedDict([('q1', ['@', 'gender', 'q1', 'locality', 'ethnicity']),</span> +<span class="go"> ('q2', ['locality', 'ethnicity']),</span> +<span class="go"> ('q6', ['@']),</span> +<span class="go"> ('@', ['q6']),</span> +<span class="go"> (u'q6_1', ['@', 'gender', 'q1']),</span> +<span class="go"> (u'q6_2', ['@', 'gender', 'q1']),</span> +<span class="go"> (u'q6_3', ['@', 'gender', 'q1'])])</span> +</pre></div> +</div> +</div> +<div class="section" id="verbatims-open-ends"> +<h2>Verbatims/ open ends<a class="headerlink" href="#verbatims-open-ends" title="Permalink to this headline">¶</a></h2> +<p>Another special case are verbatims. They will not be aggregated in a <code class="docutils literal"><span class="pre">qp.Stack</span></code>, +but they have to be defined in a <code class="docutils literal"><span class="pre">qp.Batch</span></code> to add them later to a <code class="docutils literal"><span class="pre">qp.Cluster</span></code>.</p> +<p>There are two different ways to add verbatims: Either all to one <code class="docutils literal"><span class="pre">qp.Cluster</span></code> +key or each gets its own key. But both options can be done with the same method.</p> +<p>For splitting the verbatims, set <code class="docutils literal"><span class="pre">split=True</span></code> and insert as many titles as +included verbatims/ open ends:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">add_open_ends</span><span class="p">([</span><span class="s1">'q8a'</span><span class="p">,</span> <span class="s1">'q9a'</span><span class="p">],</span> <span class="n">break_by</span><span class="o">=</span><span class="p">[</span><span class="s1">'record_number'</span><span class="p">,</span> <span class="s1">'age'</span><span class="p">],</span> +<span class="go"> split=True, title=['oe_q8', 'oe_q9'])</span> +</pre></div> +</div> +<p>For collecting all verbatims in one Cluster key, set <code class="docutils literal"><span class="pre">split=False</span></code> and add +only one <code class="docutils literal"><span class="pre">title</span></code> or use the default parameters:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">add_open_ends</span><span class="p">([</span><span class="s1">'q8a'</span><span class="p">,</span> <span class="s1">'q9a'</span><span class="p">],</span> <span class="n">break_by</span><span class="o">=</span><span class="p">[</span><span class="s1">'record_number'</span><span class="p">,</span> <span class="s1">'age'</span><span class="p">])</span> +</pre></div> +</div> +</div> +<div class="section" id="special-aggregations"> +<h2>Special aggregations<a class="headerlink" href="#special-aggregations" title="Permalink to this headline">¶</a></h2> +<p>It is possible to add some special aggregations to a <code class="docutils literal"><span class="pre">qp.Batch</span></code>, that are +not stored in the main construction plan <code class="docutils literal"><span class="pre">.x_y_map</span></code>. One option is to give a +name for a Cluster key in which all y-keys are cross-tabulated against each +other:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">add_y_on_y</span><span class="p">(</span><span class="s1">'y-keys'</span><span class="p">)</span> +</pre></div> +</div> +<p>Another possibility is to add a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance to an other instance. +The added Batch loses all information about verbatims and <code class="docutils literal"><span class="pre">.y_on_y</span></code>, that +means only the main construction plan in <code class="docutils literal"><span class="pre">.x_y_map</span></code> gets adopted. Each of +the two batches is aggregated discretely in the <code class="docutils literal"><span class="pre">qp.Stack</span></code>, but the added +instance gets included into the <code class="docutils literal"><span class="pre">qp.Cluster</span></code> of the first <code class="docutils literal"><span class="pre">qp.Batch</span></code> in +a key named by its instance name.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch1</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">get_batch</span><span class="p">(</span><span class="s1">'batch1'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">batch2</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">get_batch</span><span class="p">(</span><span class="s1">'batch2'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">batch2</span><span class="o">.</span><span class="n">add_x</span><span class="p">(</span><span class="s1">'q2b'</span><span class="p">)</span> +<span class="go">Array summaries setup: Creating no summaries!</span> +<span class="gp">>>> </span><span class="n">batch2</span><span class="o">.</span><span class="n">add_y</span><span class="p">(</span><span class="s1">'gender'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">batch2</span><span class="o">.</span><span class="n">as_addition</span><span class="p">(</span><span class="s1">'batch1'</span><span class="p">)</span> +<span class="go">Batch 'batch2' specified as addition to Batch 'batch1'. Any open end summaries and 'y_on_y' agg. have been removed!</span> +</pre></div> +</div> +<p>The connection between the two <code class="docutils literal"><span class="pre">qp.Batch</span></code> instances you can see in <code class="docutils literal"><span class="pre">.additional</span></code> +for the added instance and in <code class="docutils literal"><span class="pre">._meta['sets']['batches']['batchname']['additions']</span></code> +for the first instance.</p> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="03_properties.html" class="btn btn-neutral float-right" title="Set properties of a qp.Batch" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="01_create_load.html" class="btn btn-neutral" title="Creating/ Loading a qp.Batch instance" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/batch/03_properties.html b/docs/API/_build/html/sites/lib_doc/batch/03_properties.html new file mode 100644 index 000000000..6bbd2f014 --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/batch/03_properties.html @@ -0,0 +1,476 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Set properties of a qp.Batch — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="Batch" href="00_overview.html"/> + <link rel="next" title="Inherited qp.DataSet methods" href="04_subclass.html"/> + <link rel="prev" title="Adding variables to a qp.Batch instance" href="02_variables.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a> »</li> + + <li>Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/batch/03_properties.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="set-properties-of-a-qp-batch"> +<h1>Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code><a class="headerlink" href="#set-properties-of-a-qp-batch" title="Permalink to this headline">¶</a></h1> +<p>The section before explained how the main construction plan (<code class="docutils literal"><span class="pre">batch.x_y_map</span></code>) +is built, that describes which x-keys and y-keys are used to add <code class="docutils literal"><span class="pre">qp.Link</span></code>s +to a <code class="docutils literal"><span class="pre">qp.Stack</span></code>. Now you will get to know how the missing information for the +<code class="docutils literal"><span class="pre">Link</span></code>s are defined and which specific views get extracted for the +<code class="docutils literal"><span class="pre">qp.Cluster</span></code> by adding some property options the <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance.</p> +<div class="section" id="filter-weights-and-significance-testing"> +<h2>Filter, weights and significance testing<a class="headerlink" href="#filter-weights-and-significance-testing" title="Permalink to this headline">¶</a></h2> +<p><code class="docutils literal"><span class="pre">qp.Link</span></code>s can be added to a <code class="docutils literal"><span class="pre">qp.Stack</span></code> data_key-level by defining its x +and y-keys, which is already done in <code class="docutils literal"><span class="pre">.x_y_map</span></code>, and setting a filter. +This property can be edited in a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance with the +following methods:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">add_filter</span><span class="p">(</span><span class="s1">'men only'</span><span class="p">,</span> <span class="p">{</span><span class="s1">'gender'</span><span class="p">:</span> <span class="mi">1</span><span class="p">})</span> +<span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">extend_filter</span><span class="p">({</span><span class="s1">'q1'</span><span class="p">:</span> <span class="p">{</span><span class="s1">'age'</span><span class="p">:</span> <span class="p">[</span><span class="mi">20</span><span class="p">,</span> <span class="mi">21</span><span class="p">,</span> <span class="mi">22</span><span class="p">,</span> <span class="mi">23</span><span class="p">,</span> <span class="mi">24</span><span class="p">,</span> <span class="mi">25</span><span class="p">]}})</span> +</pre></div> +</div> +<p>Filters can be added globally or for a selection of x-keys only. Out of the +global filter, <code class="docutils literal"><span class="pre">.sample_size</span></code> is automatically calculated for each <code class="docutils literal"><span class="pre">qp.Batch</span></code> +defintion.</p> +<p>Now all information are collected in the <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance and the <code class="docutils literal"><span class="pre">Stack</span></code> +can be populated with <code class="docutils literal"><span class="pre">Link</span></code>s in form of <code class="docutils literal"><span class="pre">stack[data_key][filter_key][x_key][y_key]</span></code>.</p> +<p>For each <code class="docutils literal"><span class="pre">Link</span></code> <code class="docutils literal"><span class="pre">qp.View</span></code>s can be added, these views depend on a weight +definition, which is also defined in the <code class="docutils literal"><span class="pre">qp.Batch</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">set_weights</span><span class="p">([</span><span class="s1">'weight_a'</span><span class="p">])</span> +</pre></div> +</div> +<p>Significance tests are a special <code class="docutils literal"><span class="pre">View</span></code>; the sig. levels which they are +calculated on can be added to the <code class="docutils literal"><span class="pre">qp.Batch</span></code> like this:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">set_sigtests</span><span class="p">(</span><span class="n">levels</span><span class="o">=</span><span class="p">[</span><span class="mf">0.05</span><span class="p">])</span> +</pre></div> +</div> +</div> +<div class="section" id="cell-items-and-language"> +<h2>Cell items and language<a class="headerlink" href="#cell-items-and-language" title="Permalink to this headline">¶</a></h2> +<p>As <code class="docutils literal"><span class="pre">qp.Stack</span></code> is a container for a large amount of aggregations, it will +accommodate various <code class="docutils literal"><span class="pre">qp.View</span></code>s. The <code class="docutils literal"><span class="pre">qp.Batch</span></code> property <code class="docutils literal"><span class="pre">.cell_items</span></code> is +used to define which specfic <code class="docutils literal"><span class="pre">Views</span></code> will be taken to create a <code class="docutils literal"><span class="pre">qp.Cluster</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">set_cell_items</span><span class="p">([</span><span class="s1">'c'</span><span class="p">,</span> <span class="s1">'p'</span><span class="p">])</span> +</pre></div> +</div> +<p>The property <code class="docutils literal"><span class="pre">.language</span></code> allows the user to define which <code class="docutils literal"><span class="pre">text</span></code> labels from +the meta data should be used for the extracted <code class="docutils literal"><span class="pre">Views</span></code> by entering a valid +text key:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">set_language</span><span class="p">(</span><span class="s1">'en-GB'</span><span class="p">)</span> +</pre></div> +</div> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="04_subclass.html" class="btn btn-neutral float-right" title="Inherited qp.DataSet methods" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="02_variables.html" class="btn btn-neutral" title="Adding variables to a qp.Batch instance" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/batch/04_subclass.html b/docs/API/_build/html/sites/lib_doc/batch/04_subclass.html new file mode 100644 index 000000000..76bdcd716 --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/batch/04_subclass.html @@ -0,0 +1,447 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Inherited qp.DataSet methods — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="Batch" href="00_overview.html"/> + <link rel="next" title="Analysis & aggregation" href="../engine/00_overview.html"/> + <link rel="prev" title="Set properties of a qp.Batch" href="03_properties.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a> »</li> + + <li>Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/batch/04_subclass.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="inherited-qp-dataset-methods"> +<h1>Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods<a class="headerlink" href="#inherited-qp-dataset-methods" title="Permalink to this headline">¶</a></h1> +<p>Being a <code class="docutils literal"><span class="pre">qp.DataSet</span></code> subclasss, <code class="docutils literal"><span class="pre">qp.Batch</span></code> inherits some of its methods. +The important ones are these which allow the manipulation of the meta component. +That means meta-edits can be applied globally (run methods on <code class="docutils literal"><span class="pre">qp.DataSet</span></code>) or +<code class="docutils literal"><span class="pre">Batch</span></code>-specific (run methods on <code class="docutils literal"><span class="pre">qp.Batch</span></code>). Batch meta-edits +always overwrite global meta-edits and while building a <code class="docutils literal"><span class="pre">qp.Cluster</span></code> from a +<code class="docutils literal"><span class="pre">qp.Batch</span></code>, the modified meta information is taken from <code class="docutils literal"><span class="pre">.meta_edits</span></code>.</p> +<p>The following methods can be used to create meta-edits for a <code class="docutils literal"><span class="pre">qp.Batch</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">hiding</span><span class="p">(</span><span class="s1">'q1'</span><span class="p">,</span> <span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">axis</span><span class="o">=</span><span class="s1">'y'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">sorting</span><span class="p">(</span><span class="s1">'q2'</span><span class="p">,</span> <span class="n">fix</span><span class="o">=</span><span class="p">[</span><span class="mi">97</span><span class="p">,</span> <span class="mi">98</span><span class="p">])</span> +<span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">slicing</span><span class="p">(</span><span class="s1">'q1'</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">],</span> <span class="n">axis</span><span class="o">=</span><span class="s1">'x'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">set_variable_text</span><span class="p">(</span><span class="s1">'gender'</span><span class="p">,</span> <span class="s1">'Gender???'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">set_value_texts</span><span class="p">(</span><span class="s1">'gender'</span><span class="p">,</span> <span class="p">{</span><span class="mi">1</span><span class="p">:</span> <span class="s1">'Men'</span><span class="p">,</span> <span class="mi">2</span><span class="p">:</span> <span class="s1">'Women'</span><span class="p">})</span> +<span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">set_property</span><span class="p">(</span><span class="s1">'q1'</span><span class="p">,</span> <span class="s1">'base_text'</span><span class="p">,</span> <span class="s1">'This var has a second filter.'</span><span class="p">)</span> +</pre></div> +</div> +<p>Some methods are not allowed to be used for a <code class="docutils literal"><span class="pre">Batch</span></code>. These will raise a +<code class="docutils literal"><span class="pre">NotImplementedError</span></code> to prevent inconsistent case and meta data states.</p> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="../engine/00_overview.html" class="btn btn-neutral float-right" title="Analysis & aggregation" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="03_properties.html" class="btn btn-neutral" title="Set properties of a qp.Batch" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/builds/00_overview.html b/docs/API/_build/html/sites/lib_doc/builds/00_overview.html new file mode 100644 index 000000000..dacb53634 --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/builds/00_overview.html @@ -0,0 +1,438 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Builds — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="next" title="Combining results" href="01_chains.html"/> + <link rel="prev" title="View aggregation" href="../engine/04_agg_methods.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="current reference internal" href="#">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li>Builds</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/builds/00_overview.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="section" id="builds"> +<h1>Builds<a class="headerlink" href="#builds" title="Permalink to this headline">¶</a></h1> +<div class="toctree-wrapper compound"> +<ul> +<li class="toctree-l1"><a class="reference internal" href="01_chains.html">Combining results</a><ul> +<li class="toctree-l2"><a class="reference internal" href="01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l2"><a class="reference internal" href="01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="01_chains.html" class="btn btn-neutral float-right" title="Combining results" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="../engine/04_agg_methods.html" class="btn btn-neutral" title="View aggregation" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/builds/01_chains.html b/docs/API/_build/html/sites/lib_doc/builds/01_chains.html new file mode 100644 index 000000000..3b0e525ff --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/builds/01_chains.html @@ -0,0 +1,442 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Combining results — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="Builds" href="00_overview.html"/> + <link rel="next" title="API references" href="../../api_ref/00overview.html"/> + <link rel="prev" title="Builds" href="00_overview.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html">Builds</a><ul class="current"> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html">Builds</a> »</li> + + <li>Combining results</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/builds/01_chains.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="combining-results"> +<h1>Combining results<a class="headerlink" href="#combining-results" title="Permalink to this headline">¶</a></h1> +<div class="section" id="organizing-view-aggregations"> +<h2>Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations<a class="headerlink" href="#organizing-view-aggregations" title="Permalink to this headline">¶</a></h2> +</div> +<div class="section" id="creating-chain-aggregations"> +<h2>Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations<a class="headerlink" href="#creating-chain-aggregations" title="Permalink to this headline">¶</a></h2> +<div class="section" id="what-is-a-chain"> +<h3>What is a <code class="docutils literal"><span class="pre">Chain</span></code>?<a class="headerlink" href="#what-is-a-chain" title="Permalink to this headline">¶</a></h3> +</div> +<div class="section" id="customizing-results"> +<h3>Customizing results<a class="headerlink" href="#customizing-results" title="Permalink to this headline">¶</a></h3> +</div> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="../../api_ref/00overview.html" class="btn btn-neutral float-right" title="API references" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="00_overview.html" class="btn btn-neutral" title="Builds" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/dataprocessing/00_overview.html b/docs/API/_build/html/sites/lib_doc/dataprocessing/00_overview.html new file mode 100644 index 000000000..2f8c59a3f --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/dataprocessing/00_overview.html @@ -0,0 +1,529 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Data processing — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="next" title="DataSet components" href="01_components.html"/> + <link rel="prev" title="Derotation" href="../../release_notes/how_to_snippets/derotate.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Latest (01/10/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="current reference internal" href="#">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Stack.html">Stack</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li>Data processing</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/dataprocessing/00_overview.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="section" id="data-processing"> +<h1>Data processing<a class="headerlink" href="#data-processing" title="Permalink to this headline">¶</a></h1> +<div class="toctree-wrapper compound"> +<ul> +<li class="toctree-l1"><a class="reference internal" href="01_components.html">DataSet components</a><ul> +<li class="toctree-l2"><a class="reference internal" href="01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l2"><a class="reference internal" href="01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l2"><a class="reference internal" href="01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l2"><a class="reference internal" href="01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l2"><a class="reference internal" href="01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="02_io.html">I/O</a><ul> +<li class="toctree-l2"><a class="reference internal" href="02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#decipher">Decipher</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="02a_management.html">DataSet management</a><ul> +<li class="toctree-l2"><a class="reference internal" href="02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l2"><a class="reference internal" href="02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l2"><a class="reference internal" href="02a_management.html#merging">Merging</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l2"><a class="reference internal" href="03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l2"><a class="reference internal" href="03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l2"><a class="reference internal" href="03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l2"><a class="reference internal" href="03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="04_editing.html">Editing metadata</a><ul> +<li class="toctree-l2"><a class="reference internal" href="04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l2"><a class="reference internal" href="04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l2"><a class="reference internal" href="04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l2"><a class="reference internal" href="04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l2"><a class="reference internal" href="04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l2"><a class="reference internal" href="04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l2"><a class="reference internal" href="05_transforming.html#copying">Copying</a></li> +<li class="toctree-l2"><a class="reference internal" href="05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l2"><a class="reference internal" href="05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l2"><a class="reference internal" href="05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l2"><a class="reference internal" href="06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l2"><a class="reference internal" href="06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l2"><a class="reference internal" href="07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="01_components.html" class="btn btn-neutral float-right" title="DataSet components" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="../../release_notes/how_to_snippets/derotate.html" class="btn btn-neutral" title="Derotation" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/dataprocessing/01_components.html b/docs/API/_build/html/sites/lib_doc/dataprocessing/01_components.html new file mode 100644 index 000000000..ee082ed24 --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/dataprocessing/01_components.html @@ -0,0 +1,606 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>DataSet components — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="Data processing" href="00_overview.html"/> + <link rel="next" title="I/O" href="02_io.html"/> + <link rel="prev" title="Data processing" href="00_overview.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Latest (01/10/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html">Data processing</a><ul class="current"> +<li class="toctree-l2 current"><a class="current reference internal" href="#">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Stack.html">Stack</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html">Data processing</a> »</li> + + <li>DataSet components</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/dataprocessing/01_components.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="dataset-components"> +<h1>DataSet components<a class="headerlink" href="#dataset-components" title="Permalink to this headline">¶</a></h1> +<div class="section" id="case-and-meta-data"> +<h2>Case and meta data<a class="headerlink" href="#case-and-meta-data" title="Permalink to this headline">¶</a></h2> +<p><code class="docutils literal"><span class="pre">Quantipy</span></code> builds upon the <code class="docutils literal"><span class="pre">pandas</span></code> library to feature the <code class="docutils literal"><span class="pre">DataFrame</span></code> +and <code class="docutils literal"><span class="pre">Series</span></code> objects in the case data component of its <code class="docutils literal"><span class="pre">DataSet</span></code> object. +Additionally, each <code class="docutils literal"><span class="pre">DataSet</span></code> offers a metadata component to describe the +data columns and provide additional information on the characteristics of the +underlying structure. The metadata document is implemented as a nested <code class="docutils literal"><span class="pre">dict</span></code> +and provides the following <code class="docutils literal"><span class="pre">keys</span></code> on its first level:</p> +<table border="1" class="docutils"> +<colgroup> +<col width="17%" /> +<col width="83%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">element</th> +<th class="head">contains</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td><code class="docutils literal"><span class="pre">'type'</span></code></td> +<td>case data type</td> +</tr> +<tr class="row-odd"><td><code class="docutils literal"><span class="pre">'info'</span></code></td> +<td>info on the source data</td> +</tr> +<tr class="row-even"><td><code class="docutils literal"><span class="pre">'lib'</span></code></td> +<td>shared use references</td> +</tr> +<tr class="row-odd"><td><code class="docutils literal"><span class="pre">'columns'</span></code></td> +<td>info on <code class="docutils literal"><span class="pre">DataFrame</span></code> columns (Quantipy types, labels, etc.)</td> +</tr> +<tr class="row-even"><td><code class="docutils literal"><span class="pre">'sets'</span></code></td> +<td>ordered groups of variables pointing to other parts of the meta</td> +</tr> +<tr class="row-odd"><td><code class="docutils literal"><span class="pre">'masks'</span></code></td> +<td>complex variable type definitions (arrays, dichotomous, etc.)</td> +</tr> +</tbody> +</table> +</div> +<div class="section" id="columns-and-masks-objects"> +<h2><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects<a class="headerlink" href="#columns-and-masks-objects" title="Permalink to this headline">¶</a></h2> +<p>There are two variable collections inside a <code class="docutils literal"><span class="pre">Quantipy</span></code> metadata document: +<code class="docutils literal"><span class="pre">'columns'</span></code> is storing the meta for each accompanying <code class="docutils literal"><span class="pre">pandas.DataFrame</span></code> +column object, while <code class="docutils literal"><span class="pre">'masks'</span></code> are building upon the regular <code class="docutils literal"><span class="pre">'columns'</span></code> +metadata but additionally employ special meta instructions to define +complex data types. An example is the the <code class="docutils literal"><span class="pre">'array'</span></code> type that (in MR speak) maps +multiple “question” variables to one “answer” object.</p> +<p>“Simple”” data definitons that are supported by <code class="docutils literal"><span class="pre">Quantipy</span></code> can either be numeric +<code class="docutils literal"><span class="pre">'float'</span></code> and <code class="docutils literal"><span class="pre">'int'</span></code> types, categorical <code class="docutils literal"><span class="pre">'single'</span></code> and <code class="docutils literal"><span class="pre">'delimited</span> <span class="pre">set'</span></code> +variables or of type <code class="docutils literal"><span class="pre">'string'</span></code>, <code class="docutils literal"><span class="pre">'date'</span></code> and <code class="docutils literal"><span class="pre">'time'</span></code>.</p> +</div> +<div class="section" id="languages-text-and-text-key-mappings"> +<h2>Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings<a class="headerlink" href="#languages-text-and-text-key-mappings" title="Permalink to this headline">¶</a></h2> +<p>Throughout <code class="docutils literal"><span class="pre">Quantipy</span></code> metadata all label information, e.g. variable question +texts and category descriptions, are stored in <code class="docutils literal"><span class="pre">text</span></code> objects that are mapping +different language (or context) versions of a label to a specific <code class="docutils literal"><span class="pre">text_key</span></code>. +That way the metadata can support multi-language and multi-purpose (for example +detailed/extensive vs. short question texts) label information in a digestable +format that is easy to query:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">meta</span><span class="p">[</span><span class="s1">'columns'</span><span class="p">][</span><span class="s1">'q1'</span><span class="p">][</span><span class="s1">'text'</span><span class="p">]</span> +<span class="go">{'de-DE': 'Das ist ein langes deutsches Label',</span> +<span class="go"> u'en-GB': u'What is your main fitness activity?',</span> +<span class="go"> 'x edits': {'de-DE': 'German build label', 'en-GB': 'English build label'}}</span> +</pre></div> +</div> +<p>Valid <code class="docutils literal"><span class="pre">text_key</span></code> settings are:</p> +<table border="1" class="docutils"> +<colgroup> +<col width="18%" /> +<col width="82%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head"><code class="docutils literal"><span class="pre">text_key</span></code></th> +<th class="head">Language / context</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td><code class="docutils literal"><span class="pre">'en-GB'</span></code></td> +<td>English</td> +</tr> +<tr class="row-odd"><td><code class="docutils literal"><span class="pre">'de-DE'</span></code></td> +<td>German</td> +</tr> +<tr class="row-even"><td><code class="docutils literal"><span class="pre">'fr-FR'</span></code></td> +<td>French</td> +</tr> +<tr class="row-odd"><td><code class="docutils literal"><span class="pre">'da-DK'</span></code></td> +<td>Danish</td> +</tr> +<tr class="row-even"><td><code class="docutils literal"><span class="pre">'sv-SV'</span></code></td> +<td>Swedish</td> +</tr> +<tr class="row-odd"><td><code class="docutils literal"><span class="pre">'nb-NO'</span></code></td> +<td>Norwegian</td> +</tr> +<tr class="row-even"><td><code class="docutils literal"><span class="pre">'fi-FI'</span></code></td> +<td>Finnish</td> +</tr> +<tr class="row-odd"><td><code class="docutils literal"><span class="pre">'x</span> <span class="pre">edits'</span></code></td> +<td>Build label edit for x-axis</td> +</tr> +<tr class="row-even"><td><code class="docutils literal"><span class="pre">'y</span> <span class="pre">edits'</span></code></td> +<td>Build label edit for y-axis</td> +</tr> +</tbody> +</table> +</div> +<div class="section" id="categorical-values-object"> +<h2>Categorical <code class="docutils literal"><span class="pre">values</span></code> object<a class="headerlink" href="#categorical-values-object" title="Permalink to this headline">¶</a></h2> +<p><code class="docutils literal"><span class="pre">single</span></code> and <code class="docutils literal"><span class="pre">delimited</span> <span class="pre">set</span></code> variables restrict the possible case data +entries to a list of <code class="docutils literal"><span class="pre">values</span></code> that consist of numeric answer codes and their +<code class="docutils literal"><span class="pre">text</span></code> labels, defining distinct categories:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">meta</span><span class="p">[</span><span class="s1">'columns'</span><span class="p">][</span><span class="s1">'q1'</span><span class="p">][</span><span class="s1">'values'</span><span class="p">]</span> +<span class="go">[{'value': 1,</span> +<span class="go"> 'text': {'en-GB': 'Dog'}</span> +<span class="go"> },</span> +<span class="go"> {'value': 2,</span> +<span class="go"> 'text': {'en-GB': 'Cat'}</span> +<span class="go"> },</span> +<span class="go"> {'value': 3,</span> +<span class="go"> 'text': {'en-GB': 'Bird'}</span> +<span class="go"> },</span> +<span class="go"> {'value': -9,</span> +<span class="go"> 'text': {'en-GB': 'Not an animal'}</span> +<span class="go"> }]</span> +</pre></div> +</div> +</div> +<div class="section" id="the-array-type"> +<h2>The <code class="docutils literal"><span class="pre">array</span></code> type<a class="headerlink" href="#the-array-type" title="Permalink to this headline">¶</a></h2> +<p>Turning to the <code class="docutils literal"><span class="pre">masks</span></code> collection of the metadata, <code class="docutils literal"><span class="pre">array</span></code> variables +group together a collection of variables that share a common response options +scheme, i.e. different statements (usually referencing a broader topic) that +are answered using the same scale. In the <code class="docutils literal"><span class="pre">Quantipy</span></code> metadata document, an +<code class="docutils literal"><span class="pre">array</span></code> variable has a <code class="docutils literal"><span class="pre">subtype</span></code> that describes the type of the +constructing source variables listed in the <code class="docutils literal"><span class="pre">items</span></code> object. In contrast to simple variable types, any +categorical <code class="docutils literal"><span class="pre">values</span></code> metadata is stored inside the shared information collection +<code class="docutils literal"><span class="pre">lib</span></code>, for access from both the <code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> representation of +<code class="docutils literal"><span class="pre">array</span></code> elements:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">meta</span><span class="p">[</span><span class="s1">'masks'</span><span class="p">][</span><span class="s1">'q5'</span><span class="p">]</span> +<span class="go">{u'items': [{u'source': u'columns@q5_1', u'text': {u'en-GB': u'Surfing'}},</span> +<span class="go"> {u'source': u'columns@q5_2', u'text': {u'en-GB': u'Snowboarding'}},</span> +<span class="go"> {u'source': u'columns@q5_3', u'text': {u'en-GB': u'Kite boarding'}},</span> +<span class="go"> {u'source': u'columns@q5_4', u'text': {u'en-GB': u'Parachuting'}},</span> +<span class="go"> {u'source': u'columns@q5_5', u'text': {u'en-GB': u'Cave diving'}},</span> +<span class="go"> {u'source': u'columns@q5_6', u'text': {u'en-GB': u'Windsurfing'}}],</span> +<span class="go"> u'name': u'q5',</span> +<span class="go"> u'subtype': u'single',</span> +<span class="go"> u'text': {u'en-GB': u'How likely are you to do each of the following in the next year?'},</span> +<span class="go"> u'type': u'array',</span> +<span class="go"> u'values': 'lib@values@q5'}</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">meta</span><span class="p">[</span><span class="s1">'lib'</span><span class="p">][</span><span class="s1">'values'</span><span class="p">][</span><span class="s1">'q5'</span><span class="p">]</span> +<span class="go">[{u'text': {u'en-GB': u'I would refuse if asked'}, u'value': 1},</span> +<span class="go"> {u'text': {u'en-GB': u'Very unlikely'}, u'value': 2},</span> +<span class="go"> {u'text': {u'en-GB': u"Probably wouldn't"}, u'value': 3},</span> +<span class="go"> {u'text': {u'en-GB': u'Probably would if asked'}, u'value': 4},</span> +<span class="go"> {u'text': {u'en-GB': u'Very likely'}, u'value': 5},</span> +<span class="go"> {u'text': {u'en-GB': u"I'm already planning to"}, u'value': 97},</span> +<span class="go"> {u'text': {u'en-GB': u"Don't know"}, u'value': 98}]</span> +</pre></div> +</div> +<p>Exploring the <code class="docutils literal"><span class="pre">columns</span></code> meta of an array item shows the same <code class="docutils literal"><span class="pre">values</span></code> reference pointer and informs about its <code class="docutils literal"><span class="pre">parent</span></code> meta structure, i.e. the +array’s <code class="docutils literal"><span class="pre">masks</span></code> defintion:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">meta</span><span class="p">[</span><span class="s1">'columns'</span><span class="p">][</span><span class="s1">'q5_1'</span><span class="p">]</span> +<span class="go">{u'name': u'q5_1',</span> +<span class="go"> u'parent': {u'masks@q5': {u'type': u'array'}},</span> +<span class="go"> u'text': {u'en-GB': u'How likely are you to do each of the following in the next year? - Surfing'},</span> +<span class="go"> u'type': u'single',</span> +<span class="go"> u'values': u'lib@values@q5'}</span> +</pre></div> +</div> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="02_io.html" class="btn btn-neutral float-right" title="I/O" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="00_overview.html" class="btn btn-neutral" title="Data processing" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/dataprocessing/02_io.html b/docs/API/_build/html/sites/lib_doc/dataprocessing/02_io.html new file mode 100644 index 000000000..e0459efe1 --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/dataprocessing/02_io.html @@ -0,0 +1,657 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>I/O — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="Data processing" href="00_overview.html"/> + <link rel="next" title="DataSet management" href="02a_management.html"/> + <link rel="prev" title="DataSet components" href="01_components.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Latest (01/10/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html">Data processing</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Stack.html">Stack</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html">Data processing</a> »</li> + + <li>I/O</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/dataprocessing/02_io.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="i-o"> +<h1>I/O<a class="headerlink" href="#i-o" title="Permalink to this headline">¶</a></h1> +<div class="section" id="starting-from-native-components"> +<h2>Starting from native components<a class="headerlink" href="#starting-from-native-components" title="Permalink to this headline">¶</a></h2> +<div class="section" id="using-a-standalone-pd-dataframe"> +<h3>Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code><a class="headerlink" href="#using-a-standalone-pd-dataframe" title="Permalink to this headline">¶</a></h3> +<p><code class="docutils literal"><span class="pre">Quantipy</span></code> can create a meta document from a inferring its variable types from +the <code class="docutils literal"><span class="pre">dtypes</span></code> of a <code class="docutils literal"><span class="pre">pd.DataFrame</span></code>. In that process, <code class="docutils literal"><span class="pre">ìnt</span></code>, <code class="docutils literal"><span class="pre">float</span></code> and +<code class="docutils literal"><span class="pre">string</span></code> data types are created inside the meta component of the <code class="docutils literal"><span class="pre">DataSet</span></code>. +In this basic form, <code class="docutils literal"><span class="pre">text</span></code> label information is missing. For a example, given +a <code class="docutils literal"><span class="pre">pd.DataFrame</span></code> as per:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">casedata</span> <span class="o">=</span> <span class="p">[[</span><span class="mi">1000</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mf">1.2</span><span class="p">,</span> <span class="s1">'text1'</span><span class="p">],</span> +<span class="gp">... </span> <span class="p">[</span><span class="mi">1001</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mf">3.4</span><span class="p">,</span> <span class="s1">'jjda'</span><span class="p">],</span> +<span class="gp">... </span> <span class="p">[</span><span class="mi">1002</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">NaN</span><span class="p">,</span> <span class="s1">'what?'</span><span class="p">],</span> +<span class="gp">... </span> <span class="p">[</span><span class="mi">1003</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mf">7.81</span><span class="p">,</span> <span class="s1">'---'</span> <span class="p">],</span> +<span class="gp">... </span> <span class="p">[</span><span class="mi">1004</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mf">3.0</span><span class="p">,</span> <span class="s1">'hello world!'</span><span class="p">]]</span> +<span class="gp">>>> </span><span class="n">df</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">(</span><span class="n">casedata</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="p">[</span><span class="s1">'identity'</span><span class="p">,</span> <span class="s1">'q1'</span><span class="p">,</span> <span class="s1">'q2'</span><span class="p">,</span> <span class="s1">'q3'</span><span class="p">])</span> +<span class="gp">>>> </span><span class="n">df</span> +<span class="go"> identity q1 q2 q3</span> +<span class="go">0 1000 10 1.20 text1</span> +<span class="go">1 1001 4 3.40 jjda</span> +<span class="go">2 1002 8 NaN what?</span> +<span class="go">3 1003 8 7.81 ---</span> +<span class="go">4 1004 5 3.00 hello world!</span> +</pre></div> +</div> +<p>… the conversion is adding matching metadata to the <code class="docutils literal"><span class="pre">DataSet</span></code> instance:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span> <span class="o">=</span> <span class="n">qp</span><span class="o">.</span><span class="n">DataSet</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">'example'</span><span class="p">,</span> <span class="n">dimensions_comp</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">from_components</span><span class="p">(</span><span class="n">df</span><span class="p">)</span> +<span class="go">Inferring meta data from pd.DataFrame.columns (4)...</span> +<span class="go">identity: dtype: int64 - converted: int</span> +<span class="go">q1: dtype: int64 - converted: int</span> +<span class="go">q2: dtype: float64 - converted: float</span> +<span class="go">q3: dtype: object - converted: string</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">meta</span><span class="p">()[</span><span class="s1">'columns'</span><span class="p">][</span><span class="s1">'q2'</span><span class="p">]</span> +<span class="go">{'text': {'en-GB': ''}, 'type': 'float', 'name': 'q2', 'parent': {}, 'properties': {'created': True}}</span> +</pre></div> +</div> +</div> +<div class="section" id="csv-json-pairs"> +<h3><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs<a class="headerlink" href="#csv-json-pairs" title="Permalink to this headline">¶</a></h3> +<p>We can easily read in <code class="docutils literal"><span class="pre">Quantipy</span></code> native data with the <code class="docutils literal"><span class="pre">read_quantipy()</span></code> +method and providing the paths to both the <code class="docutils literal"><span class="pre">.csv</span></code> and <code class="docutils literal"><span class="pre">.json</span></code> file (file +extensions are handled automatically), e.g.:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">folder</span> <span class="o">=</span> <span class="s1">'./Data/'</span> +<span class="gp">>>> </span><span class="n">file_name</span> <span class="o">=</span> <span class="s1">'Example Data (A)'</span> +<span class="gp">>>> </span><span class="n">path_csv</span> <span class="o">=</span> <span class="n">path_json</span> <span class="o">=</span> <span class="n">folder</span> <span class="o">+</span> <span class="n">file_name</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span> <span class="o">=</span> <span class="n">qp</span><span class="o">.</span><span class="n">DataSet</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">'example'</span><span class="p">,</span> <span class="n">dimensions_comp</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">read_quantipy</span><span class="p">(</span><span class="n">path_json</span><span class="p">,</span> <span class="n">path_csv</span><span class="p">)</span> +<span class="go">DataSet: ./Data/example</span> +<span class="go">rows: 8255 - columns: 76</span> +<span class="go">Dimensions compatibility mode: False</span> +</pre></div> +</div> +<p>We can that access the case and metadata components:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">data</span><span class="p">()[</span><span class="s1">'q4'</span><span class="p">]</span><span class="o">.</span><span class="n">head</span><span class="p">()</span> +<span class="go">0 1</span> +<span class="go">1 2</span> +<span class="go">2 2</span> +<span class="go">3 1</span> +<span class="go">4 1</span> +<span class="go">Name: q4, dtype: int64</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">meta</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">meta</span><span class="p">()[</span><span class="s1">'columns'</span><span class="p">][</span><span class="s1">'q4'</span><span class="p">]</span> +<span class="gp">>>> </span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">meta</span><span class="p">)</span> +<span class="go">{</span> +<span class="go"> "values": [</span> +<span class="go"> {</span> +<span class="go"> "text": {</span> +<span class="go"> "en-GB": "Yes"</span> +<span class="go"> },</span> +<span class="go"> "value": 1</span> +<span class="go"> },</span> +<span class="go"> {</span> +<span class="go"> "text": {</span> +<span class="go"> "en-GB": "No"</span> +<span class="go"> },</span> +<span class="go"> "value": 2</span> +<span class="go"> }</span> +<span class="go"> ],</span> +<span class="go"> "text": {</span> +<span class="go"> "en-GB": "Do you ever participate in sports activities with people in your household?"</span> +<span class="go"> },</span> +<span class="go"> "type": "single",</span> +<span class="go"> "name": "q4",</span> +<span class="go"> "parent": {}</span> +<span class="go">}</span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="third-party-conversions"> +<h2>Third party conversions<a class="headerlink" href="#third-party-conversions" title="Permalink to this headline">¶</a></h2> +<div class="section" id="supported-conversions"> +<h3>Supported conversions<a class="headerlink" href="#supported-conversions" title="Permalink to this headline">¶</a></h3> +<p>In adddition to providing plain <code class="docutils literal"><span class="pre">.csv</span></code>/<code class="docutils literal"><span class="pre">.json</span></code> data (pairs), source files +can be read into Quantipy using a number of I/O functions to deal with +standard file formats encountered in the market research industry:</p> +<table border="1" class="docutils"> +<colgroup> +<col width="25%" /> +<col width="25%" /> +<col width="25%" /> +<col width="25%" /> +</colgroup> +<thead valign="bottom"> +<tr class="row-odd"><th class="head">Software</th> +<th class="head">Format</th> +<th class="head">Read</th> +<th class="head">Write</th> +</tr> +</thead> +<tbody valign="top"> +<tr class="row-even"><td>SPSS +Statistics</td> +<td>.sav</td> +<td>Yes</td> +<td>Yes</td> +</tr> +<tr class="row-odd"><td>SPSS +Dimensions</td> +<td>.dff/.mdd</td> +<td>Yes</td> +<td>Yes</td> +</tr> +<tr class="row-even"><td>Decipher</td> +<td>tab-delimited +.json/ .txt</td> +<td>Yes</td> +<td>No</td> +</tr> +<tr class="row-odd"><td>Ascribe</td> +<td>tab-delimited +.xml/ .txt</td> +<td>Yes</td> +<td>No</td> +</tr> +</tbody> +</table> +<p>The following functions are designed to convert the different file formats’ +structures into inputs understood by Quantipy.</p> +</div> +<div class="section" id="spss-statistics"> +<h3>SPSS Statistics<a class="headerlink" href="#spss-statistics" title="Permalink to this headline">¶</a></h3> +<p><strong>Reading:</strong></p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">quantipy.core.tools.dp.io</span> <span class="k">import</span> <span class="n">read_spss</span> +<span class="gp">>>> </span><span class="n">meta</span><span class="p">,</span> <span class="n">data</span> <span class="o">=</span> <span class="n">read_spss</span><span class="p">(</span><span class="n">path_sav</span><span class="p">)</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">On a Windows machine you MUST use <code class="docutils literal"><span class="pre">ioLocale=None</span></code> when reading +from SPSS. This means if you are using a Windows machine your base +example for reading from SPSS is +<code class="docutils literal"><span class="pre">meta,</span> <span class="pre">data</span> <span class="pre">=</span> <span class="pre">read_spss(path_sav,</span> <span class="pre">ioLocale=None)</span></code>.</p> +</div> +<p>When reading from SPSS you have the opportunity to specify a custom +dichotomous values map, that will be used to convert all dichotomous +sets into Quantipy delimited sets, using the <code class="docutils literal"><span class="pre">dichot</span></code> argument.</p> +<p>The entire read operation will use the same map on all dichotomous +sets so they must be applied uniformly throughout the SAV file. The +default map that will be used if none is provided will be +<code class="docutils literal"><span class="pre">{'yes':</span> <span class="pre">1,</span> <span class="pre">'no':</span> <span class="pre">0}</span></code>.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">meta</span><span class="p">,</span> <span class="n">data</span> <span class="o">=</span> <span class="n">read_spss</span><span class="p">(</span><span class="n">path_sav</span><span class="p">,</span> <span class="n">dichot</span><span class="o">=</span><span class="p">{</span><span class="s1">'yes'</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s1">'no'</span><span class="p">:</span> <span class="mi">2</span><span class="p">})</span> +</pre></div> +</div> +<p>SPSS dates will be converted to pandas dates by default but +if this results in conversion issues or failures you can read +the dates in as Quantipy strings to deal with them later, using the +<code class="docutils literal"><span class="pre">dates_as_strings</span></code> argument.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">meta</span><span class="p">,</span> <span class="n">data</span> <span class="o">=</span> <span class="n">read_spss</span><span class="p">(</span><span class="n">path_sav</span><span class="p">,</span> <span class="n">dates_as_strings</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</pre></div> +</div> +<p><strong>Writing:</strong></p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">quantipy.core.tools.dp.io</span> <span class="k">import</span> <span class="n">write_spss</span> +<span class="gp">>>> </span><span class="n">write_spss</span><span class="p">(</span><span class="n">path_sav</span><span class="p">,</span> <span class="n">meta</span><span class="p">,</span> <span class="n">data</span><span class="p">)</span> +</pre></div> +</div> +<p>By default SPSS files will be generated from the <code class="docutils literal"><span class="pre">'data</span> <span class="pre">file'</span></code> +set found in <code class="docutils literal"><span class="pre">meta['sets']</span></code>, but a custom set can be named instead +using the <code class="docutils literal"><span class="pre">from_set</span></code> argument.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">write_spss</span><span class="p">(</span><span class="n">path_sav_analysis</span><span class="p">,</span> <span class="n">meta</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">from_set</span><span class="o">=</span><span class="s1">'sav-export'</span><span class="p">)</span> +</pre></div> +</div> +<p>The custom set must be well-formed:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="s2">"sets"</span> <span class="p">:</span> <span class="p">{</span> +<span class="gp">... </span> <span class="s2">"sav-export"</span><span class="p">:</span> <span class="p">{</span> +<span class="gp">... </span> <span class="s2">"items"</span><span class="p">:</span> <span class="p">[</span> +<span class="gp">... </span> <span class="s2">"columns@Q1"</span><span class="p">,</span> +<span class="gp">... </span> <span class="s2">"columns@Q2"</span><span class="p">,</span> +<span class="gp">... </span> <span class="s2">"columns@Q3"</span><span class="p">,</span> +<span class="gp">... </span> <span class="o">...</span> +<span class="gp">... </span> <span class="p">]</span> +<span class="gp">... </span> <span class="p">}</span> +<span class="gp">... </span><span class="p">}</span> +</pre></div> +</div> +</div> +<div class="section" id="dimensions"> +<h3>Dimensions<a class="headerlink" href="#dimensions" title="Permalink to this headline">¶</a></h3> +<p><strong>Reading:</strong></p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">quantipy.core.tools.dp.io</span> <span class="k">import</span> <span class="n">read_dimensions</span> +<span class="gp">>>> </span><span class="n">meta</span><span class="p">,</span> <span class="n">data</span> <span class="o">=</span> <span class="n">read_dimensions</span><span class="p">(</span><span class="n">path_mdd</span><span class="p">,</span> <span class="n">path_ddf</span><span class="p">)</span> +</pre></div> +</div> +</div> +<div class="section" id="decipher"> +<h3>Decipher<a class="headerlink" href="#decipher" title="Permalink to this headline">¶</a></h3> +<p><strong>Reading:</strong></p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">quantipy.core.tools.dp.io</span> <span class="k">import</span> <span class="n">read_decipher</span> +<span class="gp">>>> </span><span class="n">meta</span><span class="p">,</span> <span class="n">data</span> <span class="o">=</span> <span class="n">read_decipher</span><span class="p">(</span><span class="n">path_json</span><span class="p">,</span> <span class="n">path_txt</span><span class="p">)</span> +</pre></div> +</div> +</div> +<div class="section" id="ascribe"> +<h3>Ascribe<a class="headerlink" href="#ascribe" title="Permalink to this headline">¶</a></h3> +<p><strong>Reading:</strong></p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">quantipy.core.tools.dp.io</span> <span class="k">import</span> <span class="n">read_ascribe</span> +<span class="gp">>>> </span><span class="n">meta</span><span class="p">,</span> <span class="n">data</span> <span class="o">=</span> <span class="n">read_ascribe</span><span class="p">(</span><span class="n">path_xml</span><span class="p">,</span> <span class="n">path_txt</span><span class="p">)</span> +</pre></div> +</div> +</div> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="02a_management.html" class="btn btn-neutral float-right" title="DataSet management" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="01_components.html" class="btn btn-neutral" title="DataSet components" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/dataprocessing/02a_management.html b/docs/API/_build/html/sites/lib_doc/dataprocessing/02a_management.html new file mode 100644 index 000000000..d80c3ae84 --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/dataprocessing/02a_management.html @@ -0,0 +1,533 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>DataSet management — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="Data processing" href="00_overview.html"/> + <link rel="next" title="Inspecting variables" href="03_inspection.html"/> + <link rel="prev" title="I/O" href="02_io.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Latest (01/10/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html">Data processing</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Stack.html">Stack</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html">Data processing</a> »</li> + + <li>DataSet management</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/dataprocessing/02a_management.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="dataset-management"> +<h1>DataSet management<a class="headerlink" href="#dataset-management" title="Permalink to this headline">¶</a></h1> +<div class="section" id="setting-the-variable-order"> +<h2>Setting the variable order<a class="headerlink" href="#setting-the-variable-order" title="Permalink to this headline">¶</a></h2> +<p>The global variable order of a <code class="docutils literal"><span class="pre">DataSet</span></code> is dictated by the content of the +<code class="docutils literal"><span class="pre">meta['sets']['data</span> <span class="pre">file']['items']</span></code> list and reflected in the structure of +the case data component’s <code class="docutils literal"><span class="pre">pd.DataFrame.columns</span></code>. There are two ways to set +a new order using the <code class="docutils literal"><span class="pre">order(new_order=None,</span> <span class="pre">reposition=None)</span></code> method:</p> +<p><strong>Define a full order</strong></p> +<p>Using this apporach requires that all <code class="docutils literal"><span class="pre">DataSet</span></code> variable names are passed +via the <code class="docutils literal"><span class="pre">new_order</span></code> parameter. Providing only a subset of the variables will +raise a <code class="docutils literal"><span class="pre">ValueError</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">order</span><span class="p">([</span><span class="s1">'q1'</span><span class="p">,</span> <span class="s1">'q8'</span><span class="p">])</span> +<span class="go">ValueError: 'new_order' must contain all DataSet variables.</span> +</pre></div> +</div> +<p>Text…</p> +<p><strong>Change positions relatively</strong></p> +<p>Often only a few changes to the natural order of the <code class="docutils literal"><span class="pre">DataSet</span></code> are necessary, +e.g. derived variables should be moved alongside their originating ones or specific +sets of variables (demographics, etc.) should be grouped together. We can achieve +this using the <code class="docutils literal"><span class="pre">reposition</span></code> parameter as follows:</p> +<p>Text…</p> +</div> +<div class="section" id="cloning-filtering-and-subsetting"> +<h2>Cloning, filtering and subsetting<a class="headerlink" href="#cloning-filtering-and-subsetting" title="Permalink to this headline">¶</a></h2> +<p>Sometimes you want to cut the data into sections defined by either case/respondent conditions (e.g. a survey wave) or a collection of variables (e.g. +a specific part of the questionnaire). To not permanently change an existing +<code class="docutils literal"><span class="pre">DataSet</span></code> by accident, draw a copy of it first:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">copy_ds</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">clone</span><span class="p">()</span> +</pre></div> +</div> +<p>Then you can use <code class="docutils literal"><span class="pre">filter()</span></code> to restrict cases (rows) or <code class="docutils literal"><span class="pre">subset()</span></code> to keep +only a selected range of variables (columns). Both methods can be used inplace +but will return a new object by default.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">keep</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'Wave'</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">]}</span> +<span class="gp">>>> </span><span class="n">copy_ds</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">alias</span><span class="o">=</span><span class="s1">'first wave'</span><span class="p">,</span> <span class="n">condition</span><span class="o">=</span><span class="n">keep</span><span class="p">,</span> <span class="n">inplace</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">copy_ds</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">shape</span> +<span class="go">(1621, 76)</span> +</pre></div> +</div> +<p>After the filter has been applied, the <code class="docutils literal"><span class="pre">DataSet</span></code> is only showing cases that contain the value 1 in the <code class="docutils literal"><span class="pre">'Wave'</span></code> variable. The filter alias (a short name +to describe the arbitrarily complex filter <code class="docutils literal"><span class="pre">condition</span></code>) is attached to the +instance:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">copy_ds</span><span class="o">.</span><span class="n">filtered</span> +<span class="go">only first wave</span> +</pre></div> +</div> +<p>We are now further reducing the <code class="docutils literal"><span class="pre">DataSet</span></code> by dropping all variables except the three <code class="docutils literal"><span class="pre">array</span></code> variables <code class="docutils literal"><span class="pre">'q5'</span></code>, <code class="docutils literal"><span class="pre">'q6'</span></code>, and <code class="docutils literal"><span class="pre">'q7'</span></code> using <code class="docutils literal"><span class="pre">subset()</span></code>.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">reduced_ds</span> <span class="o">=</span> <span class="n">copy_ds</span><span class="o">.</span><span class="n">subset</span><span class="p">(</span><span class="n">variables</span><span class="o">=</span><span class="p">[</span><span class="s1">'q5'</span><span class="p">,</span> <span class="s1">'q6'</span><span class="p">,</span> <span class="s1">'q7'</span><span class="p">])</span> +</pre></div> +</div> +<p>We can see that only the requested variables (<code class="docutils literal"><span class="pre">masks</span></code> defintitions and the +constructing <code class="docutils literal"><span class="pre">array</span></code> items) remain in <code class="docutils literal"><span class="pre">reduced_ds</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">reduced_ds</span><span class="o">.</span><span class="n">by_type</span><span class="p">()</span> +<span class="go">size: 1621 single delimited set array int float string date time N/A</span> +<span class="go">0 q5_1 q5</span> +<span class="go">1 q5_2 q7</span> +<span class="go">2 q5_3 q6</span> +<span class="go">3 q5_4</span> +<span class="go">4 q5_5</span> +<span class="go">5 q5_6</span> +<span class="go">6 q6_1</span> +<span class="go">7 q6_2</span> +<span class="go">8 q6_3</span> +<span class="go">9 q7_1</span> +<span class="go">10 q7_2</span> +<span class="go">11 q7_3</span> +<span class="go">12 q7_4</span> +<span class="go">13 q7_5</span> +<span class="go">14 q7_6</span> +</pre></div> +</div> +</div> +<div class="section" id="merging"> +<h2>Merging<a class="headerlink" href="#merging" title="Permalink to this headline">¶</a></h2> +<p>Intro text… As opposed to reducing an existing file…</p> +<div class="section" id="vertical-cases-rows-merging"> +<h3>Vertical (cases/rows) merging<a class="headerlink" href="#vertical-cases-rows-merging" title="Permalink to this headline">¶</a></h3> +<p>Text</p> +</div> +<div class="section" id="horizontal-variables-columns-merging"> +<h3>Horizontal (variables/columns) merging<a class="headerlink" href="#horizontal-variables-columns-merging" title="Permalink to this headline">¶</a></h3> +<p>Text</p> +</div> +</div> +<div class="section" id="savepoints-and-state-rollback"> +<h2>Savepoints and state rollback<a class="headerlink" href="#savepoints-and-state-rollback" title="Permalink to this headline">¶</a></h2> +<p>When working with big <code class="docutils literal"><span class="pre">DataSet</span></code>s and needing to perform a lot of data +preparation (deriving large amounts of new variables, lots of meta editing, +complex cleaning, …) it can be beneficial to quickly store a snapshot of a +clean and consistent state of the <code class="docutils literal"><span class="pre">DataSet</span></code>. This is most useful when working +in interactive sessions like <strong>IPython</strong> or <strong>Jupyter notebooks</strong> and might +prevent you from reloading files from disk or waiting for previous processes +to finish.</p> +<p>Savepoints are stored via <code class="docutils literal"><span class="pre">save()</span></code> and can be restored via <code class="docutils literal"><span class="pre">revert()</span></code>.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Savepoints only exists in memory and are not written to disk. Only one +savepoint can exist, so repeated <code class="docutils literal"><span class="pre">save()</span></code> calls will overwrite any previous +versions of the <code class="docutils literal"><span class="pre">DataSet</span></code>. To permanently save your data, please use one +of the <code class="docutils literal"><span class="pre">write</span></code> methods, e.g. <code class="docutils literal"><span class="pre">write_quantipy()</span></code>.</p> +</div> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="03_inspection.html" class="btn btn-neutral float-right" title="Inspecting variables" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="02_io.html" class="btn btn-neutral" title="I/O" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/dataprocessing/03_inspection.html b/docs/API/_build/html/sites/lib_doc/dataprocessing/03_inspection.html new file mode 100644 index 000000000..a8e6ce9f3 --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/dataprocessing/03_inspection.html @@ -0,0 +1,776 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Inspecting variables — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="Data processing" href="00_overview.html"/> + <link rel="next" title="Editing metadata" href="04_editing.html"/> + <link rel="prev" title="DataSet management" href="02a_management.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Latest (01/10/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html">Data processing</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Stack.html">Stack</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html">Data processing</a> »</li> + + <li>Inspecting variables</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/dataprocessing/03_inspection.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="inspecting-variables"> +<h1>Inspecting variables<a class="headerlink" href="#inspecting-variables" title="Permalink to this headline">¶</a></h1> +<div class="section" id="querying-and-slicing-case-data"> +<h2>Querying and slicing case data<a class="headerlink" href="#querying-and-slicing-case-data" title="Permalink to this headline">¶</a></h2> +<p>A <code class="docutils literal"><span class="pre">qp.DataSet</span></code> is mimicking <code class="docutils literal"><span class="pre">pandas</span></code>-like item access, i.e. passing a variable +name into the <code class="docutils literal"><span class="pre">[]</span></code>-accessor will return a <code class="docutils literal"><span class="pre">pandas.DataFrame</span></code> view of the +case data component. That means that we can chain any <code class="docutils literal"><span class="pre">pandas.DataFrame</span></code> method to +the query:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="p">[</span><span class="s1">'q9'</span><span class="p">]</span><span class="o">.</span><span class="n">head</span><span class="p">()</span> +<span class="go"> q9</span> +<span class="go">0 99;</span> +<span class="go">1 1;4;</span> +<span class="go">2 98;</span> +<span class="go">3 1;4;</span> +<span class="go">4 99;</span> +</pre></div> +</div> +<p>There is the same support for selecting multiple variables at once:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="p">[[</span><span class="s1">'q9'</span><span class="p">,</span> <span class="s1">'gender'</span><span class="p">]]</span><span class="o">.</span><span class="n">head</span><span class="p">()</span> +<span class="go"> q9 gender</span> +<span class="go">0 99; 1</span> +<span class="go">1 1;4; 2</span> +<span class="go">2 98; 1</span> +<span class="go">3 1;4; 1</span> +<span class="go">4 99; 1</span> +</pre></div> +</div> +<p>To integrate <code class="docutils literal"><span class="pre">array</span></code> (<code class="docutils literal"><span class="pre">masks</span></code>) variables into this behaviour, passing an +<code class="docutils literal"><span class="pre">array</span></code> name will automatically call its item list:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="p">[</span><span class="s1">'q6'</span><span class="p">]</span><span class="o">.</span><span class="n">head</span><span class="p">()</span> +<span class="go"> q6_1 q6_2 q6_3</span> +<span class="go">0 1 1 1</span> +<span class="go">1 1 NaN 1</span> +<span class="go">2 1 NaN 2</span> +<span class="go">3 2 NaN 2</span> +<span class="go">4 2 10 10</span> +</pre></div> +</div> +<p>This can be combined with the <code class="docutils literal"><span class="pre">list</span></code>-based selection as well:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="p">[[</span><span class="s1">'q6'</span><span class="p">,</span> <span class="s1">'q9'</span><span class="p">,</span> <span class="s1">'gender'</span><span class="p">]]</span><span class="o">.</span><span class="n">head</span><span class="p">()</span> +<span class="go"> q6_1 q6_2 q6_3 q9 gender</span> +<span class="go">0 1 1 1 99; 1</span> +<span class="go">1 1 NaN 1 1;4; 2</span> +<span class="go">2 1 NaN 2 98; 1</span> +<span class="go">3 2 NaN 2 1;4; 1</span> +<span class="go">4 2 10 10 99; 1</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">DataSet</span></code> case data supports row-slicing based on complex logical conditions +to inspect subsets of the data. We can use the <code class="docutils literal"><span class="pre">take()</span></code> with a <code class="docutils literal"><span class="pre">Quantipy</span></code> +logic operation naturally for this:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">condition</span> <span class="o">=</span> <span class="n">intersection</span><span class="p">(</span> +<span class="gp">... </span> <span class="p">[{</span><span class="s1">'gender'</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'religion'</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q9'</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">]}])</span> +<span class="gp">>>> </span><span class="n">take</span> <span class="o">=</span> <span class="n">ds</span><span class="o">.</span><span class="n">take</span><span class="p">(</span><span class="n">condition</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="p">[</span><span class="n">take</span><span class="p">,</span> <span class="p">[</span><span class="s1">'gender'</span><span class="p">,</span> <span class="s1">'religion'</span><span class="p">,</span> <span class="s1">'q9'</span><span class="p">]]</span><span class="o">.</span><span class="n">head</span><span class="p">()</span> +<span class="go"> gender religion q9</span> +<span class="go">52 1 3 1;2;4;</span> +<span class="go">357 1 3 1;3;4;</span> +<span class="go">671 1 3 1;3;4;</span> +<span class="go">783 1 3 2;3;4;</span> +<span class="go">802 1 3 4;</span> +</pre></div> +</div> +<div class="admonition seealso"> +<p class="first admonition-title">See also</p> +<p class="last">Please find an overview of <code class="docutils literal"><span class="pre">Quantipy</span></code> logical operators and data slicing +and masking in the <a class="reference internal" href="06_logics.html"><span class="doc">docs about complex logical conditions</span></a>!</p> +</div> +</div> +<div class="section" id="variable-and-value-existence"> +<h2>Variable and value existence<a class="headerlink" href="#variable-and-value-existence" title="Permalink to this headline">¶</a></h2> +<p>any, all, code_count, is_nan, var_exists, codes_in_data, is_like_numeric +variables</p> +<hr class="docutils" /> +<p>We can use <code class="docutils literal"><span class="pre">variables()</span></code> and <code class="docutils literal"><span class="pre">var_exists()</span></code> to generally test the membership +of variables inside <code class="docutils literal"><span class="pre">DataSet</span></code>. The former is showing the list of all variables +registered inside the <code class="docutils literal"><span class="pre">'data</span> <span class="pre">file'</span></code> <code class="docutils literal"><span class="pre">set</span></code>, the latter is checking if a variable’s +<code class="docutils literal"><span class="pre">name</span></code> is found in either the <code class="docutils literal"><span class="pre">'columns'</span></code> or <code class="docutils literal"><span class="pre">'masks'</span></code> collection. For +our example data, the variables are:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">variables</span><span class="p">()</span> +</pre></div> +</div> +<p>So a test for the <code class="docutils literal"><span class="pre">array</span></code> <code class="docutils literal"><span class="pre">'q5'</span></code> should be positive:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">var_exists</span><span class="p">(</span><span class="s1">'q5'</span><span class="p">)</span> +<span class="go">True</span> +</pre></div> +</div> +<p>In addition to <code class="docutils literal"><span class="pre">Quantipy</span></code>’s complex logic operators, the <code class="docutils literal"><span class="pre">DataSet</span></code> class +offers some quick case data operations for code existence tests. To return a +<code class="docutils literal"><span class="pre">pandas.Series</span></code> of all empty rows inside a variable use <code class="docutils literal"><span class="pre">is_nan()</span></code> as per:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">is_nan</span><span class="p">(</span><span class="s1">'q8'</span><span class="p">)</span><span class="o">.</span><span class="n">head</span><span class="p">()</span> +<span class="go">0 True</span> +<span class="go">1 True</span> +<span class="go">2 True</span> +<span class="go">3 True</span> +<span class="go">4 True</span> +<span class="go">Name: q8, dtype: bool</span> +</pre></div> +</div> +<p>Which we can also use to quickly check the number of missing cases…</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">is_nan</span><span class="p">(</span><span class="s1">'q8'</span><span class="p">)</span><span class="o">.</span><span class="n">value_counts</span><span class="p">()</span> +<span class="go">True 5888</span> +<span class="go">False 2367</span> +<span class="go">Name: q8, dtype: int64</span> +</pre></div> +</div> +<p>… as well as use the result as slicer for the <code class="docutils literal"><span class="pre">DataSet</span></code> case data component, +e.g. to show the non-empty rows:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">slicer</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">is_nan</span><span class="p">(</span><span class="s1">'q8'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="p">[</span><span class="o">~</span><span class="n">slicer</span><span class="p">,</span> <span class="s1">'q8'</span><span class="p">]</span><span class="o">.</span><span class="n">head</span><span class="p">()</span> +<span class="go">Name: q8, dtype: int64</span> +<span class="go">7 5;</span> +<span class="go">11 5;</span> +<span class="go">13 1;4;</span> +<span class="go">14 4;5;</span> +<span class="go">23 1;4;</span> +<span class="go">Name: q8, dtype: object</span> +</pre></div> +</div> +<p>Especially useful for <code class="docutils literal"><span class="pre">delimited</span> <span class="pre">set</span></code> and <code class="docutils literal"><span class="pre">array</span></code> data, the <code class="docutils literal"><span class="pre">code_count()</span></code> +method is creating the <code class="docutils literal"><span class="pre">pandas.Series</span></code> of response values found. If applied on +an <code class="docutils literal"><span class="pre">array</span></code>, the result is expressed across all source item variables:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">code_count</span><span class="p">(</span><span class="s1">'q6'</span><span class="p">)</span><span class="o">.</span><span class="n">value_counts</span><span class="p">()</span> +<span class="go">3 5100</span> +<span class="go">2 3155</span> +<span class="go">dtype: int64</span> +</pre></div> +</div> +<p>… which means that not all cases contain answers in all three of the array’s items.</p> +<p>With some basic <code class="docutils literal"><span class="pre">pandas</span></code> we can double-check this result:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">pd</span><span class="o">.</span><span class="n">concat</span><span class="p">([</span><span class="n">dataset</span><span class="p">[</span><span class="s1">'q6'</span><span class="p">],</span> <span class="n">dataset</span><span class="o">.</span><span class="n">code_count</span><span class="p">(</span><span class="s1">'q6'</span><span class="p">)],</span> <span class="n">axis</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">head</span><span class="p">()</span> +<span class="go"> q6_1 q6_2 q6_3 0</span> +<span class="go">0 1 1.0 1 3</span> +<span class="go">1 1 NaN 1 2</span> +<span class="go">2 1 NaN 2 2</span> +<span class="go">3 2 NaN 2 2</span> +<span class="go">4 2 10.0 10 3</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">code_count()</span></code> can optionally ignore certain codes via the <code class="docutils literal"><span class="pre">count_only</span></code> and +<code class="docutils literal"><span class="pre">count_not</span></code> parameters:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">q2_count</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">code_count</span><span class="p">(</span><span class="s1">'q2'</span><span class="p">,</span> <span class="n">count_only</span><span class="o">=</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">])</span> +<span class="gp">>>> </span><span class="n">pd</span><span class="o">.</span><span class="n">concat</span><span class="p">([</span><span class="n">dataset</span><span class="p">[</span><span class="s1">'q2'</span><span class="p">],</span> <span class="n">q2_count</span><span class="p">],</span> <span class="n">axis</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">head</span><span class="p">()</span> +<span class="go"> q2 0</span> +<span class="go">0 1;2;3;5; 3</span> +<span class="go">1 3;6; 1</span> +<span class="go">2 NaN 0</span> +<span class="go">3 NaN 0</span> +<span class="go">4 NaN 0</span> +</pre></div> +</div> +<p>Similarly, the <code class="docutils literal"><span class="pre">any()</span></code> and <code class="docutils literal"><span class="pre">all()</span></code> methods yield slicers for cases obeying +the condition that at least one / all of the provided codes are found in the +response. Again, for <code class="docutils literal"><span class="pre">array</span></code> variables the conditions are extended across all +the items:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="p">[</span><span class="n">dataset</span><span class="o">.</span><span class="n">all</span><span class="p">(</span><span class="s1">'q6'</span><span class="p">,</span> <span class="mi">5</span><span class="p">),</span> <span class="s1">'q6'</span><span class="p">]</span> +<span class="go"> q6_1 q6_2 q6_3</span> +<span class="go">374 5 5.0 5</span> +<span class="go">2363 5 5.0 5</span> +<span class="go">2377 5 5.0 5</span> +<span class="go">4217 5 5.0 5</span> +<span class="go">5530 5 5.0 5</span> +<span class="go">5779 5 5.0 5</span> +<span class="go">5804 5 5.0 5</span> +<span class="go">6328 5 5.0 5</span> +<span class="go">6774 5 5.0 5</span> +<span class="go">7269 5 5.0 5</span> +<span class="go">8148 5 5.0 5</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="p">[</span><span class="n">dataset</span><span class="o">.</span><span class="n">all</span><span class="p">(</span><span class="s1">'q8'</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">96</span><span class="p">]),</span> <span class="s1">'q8'</span><span class="p">]</span> +<span class="go">845 1;2;3;4;5;96;</span> +<span class="go">6242 1;2;3;4;96;</span> +<span class="go">7321 1;2;3;4;96;</span> +<span class="go">Name: q8, dtype: object</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="p">[</span><span class="n">dataset</span><span class="o">.</span><span class="n">any</span><span class="p">(</span><span class="s1">'q8'</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">96</span><span class="p">]),</span> <span class="s1">'q8'</span><span class="p">]</span><span class="o">.</span><span class="n">head</span><span class="p">()</span> +<span class="go">13 1;4;</span> +<span class="go">14 4;5;</span> +<span class="go">23 1;4;</span> +<span class="go">24 1;3;4;</span> +<span class="go">25 1;4;</span> +<span class="go">Name: q8, dtype: object</span> +</pre></div> +</div> +</div> +<div class="section" id="variable-types"> +<h2>Variable types<a class="headerlink" href="#variable-types" title="Permalink to this headline">¶</a></h2> +<p>To get a summary of the all variables grouped by type, call <code class="docutils literal"><span class="pre">by_type()</span></code> on +the <code class="docutils literal"><span class="pre">DataSet</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">by_type</span><span class="p">()</span> +<span class="go">size: 8255 single delimited set array int float string date time N/A</span> +<span class="go">0 gender q2 q5 record_number weight q8a start_time duration</span> +<span class="go">1 locality q3 q7 unique_id weight_a q9a end_time</span> +<span class="go">2 ethnicity q8 q6 age weight_b</span> +<span class="go">3 religion q9 birth_day</span> +<span class="go">4 q1 birth_month</span> +<span class="go">5 q2b birth_year</span> +<span class="go">6 q4</span> +<span class="go">7 q5_1</span> +<span class="go">8 q5_2</span> +<span class="go">9 q5_3</span> +<span class="go">10 q5_4</span> +<span class="go">11 q5_5</span> +<span class="go">12 q5_6</span> +<span class="go">13 q6_1</span> +<span class="go">14 q6_2</span> +<span class="go">15 q6_3</span> +<span class="go">16 q7_1</span> +<span class="go">17 q7_2</span> +<span class="go">18 q7_3</span> +<span class="go">19 q7_4</span> +<span class="go">20 q7_5</span> +<span class="go">21 q7_6</span> +</pre></div> +</div> +<p>We can restrict the output to certain types by providing the desired ones in +the <code class="docutils literal"><span class="pre">types</span></code> parameter:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">by_type</span><span class="p">(</span><span class="n">types</span><span class="o">=</span><span class="s1">'delimited set'</span><span class="p">)</span> +<span class="go">size: 8255 delimited set</span> +<span class="go">0 q2</span> +<span class="go">1 q3</span> +<span class="go">2 q8</span> +<span class="go">3 q9</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">by_type</span><span class="p">(</span><span class="n">types</span><span class="o">=</span><span class="p">[</span><span class="s1">'delimited set'</span><span class="p">,</span> <span class="s1">'float'</span><span class="p">])</span> +<span class="go">size: 8255 delimited set float</span> +<span class="go">0 q2 weight</span> +<span class="go">1 q3 weight_a</span> +<span class="go">2 q8 weight_b</span> +<span class="go">3 q9 NaN</span> +</pre></div> +</div> +<p>In addition to that, <code class="docutils literal"><span class="pre">DataSet</span></code> implements the following methods +that return the corresponding variables as a <code class="docutils literal"><span class="pre">list</span></code> for easy iteration:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">DataSet</span><span class="o">.</span><span class="n">singles</span> + <span class="o">.</span><span class="n">delimied_sets</span><span class="p">()</span> + <span class="o">.</span><span class="n">ints</span><span class="p">()</span> + <span class="o">.</span><span class="n">floats</span><span class="p">()</span> + <span class="o">.</span><span class="n">dates</span><span class="p">()</span> + <span class="o">.</span><span class="n">strings</span><span class="p">()</span> + <span class="o">.</span><span class="n">masks</span><span class="p">()</span> + <span class="o">.</span><span class="n">columns</span><span class="p">()</span> + <span class="o">.</span><span class="n">sets</span><span class="p">()</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">delimited_sets</span><span class="p">()</span> +<span class="go">[u'q3', u'q2', u'q9', u'q8']</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">for</span> <span class="n">delimited_set</span> <span class="ow">in</span> <span class="n">ds</span><span class="o">.</span><span class="n">delimited_sets</span><span class="p">():</span> +<span class="gp">... </span> <span class="nb">print</span> <span class="n">delimited_set</span> +<span class="go">q3</span> +<span class="go">q2</span> +<span class="go">q9</span> +<span class="go">q8</span> +</pre></div> +</div> +</div> +<div class="section" id="slicing-dicing-metadata-objects"> +<h2>Slicing & dicing metadata objects<a class="headerlink" href="#slicing-dicing-metadata-objects" title="Permalink to this headline">¶</a></h2> +<p>Although it is possible to access a <code class="docutils literal"><span class="pre">DataSet</span></code> meta component via its <code class="docutils literal"><span class="pre">_meta</span></code> +attribute directly, the prefered way to inspect and interact with with the metadata +is to use <code class="docutils literal"><span class="pre">DataSet</span></code> methods. For instance, the easiest way to view the most +important meta on a variable is to use the <code class="docutils literal"><span class="pre">meta()</span></code> method:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'q8'</span><span class="p">)</span> +<span class="go">delimited set codes texts missing</span> +<span class="go">q8: Which of the following do you regularly skip?</span> +<span class="go">1 1 Breakfast None</span> +<span class="go">2 2 Mid-morning snacking None</span> +<span class="go">3 3 Lunch None</span> +<span class="go">4 4 Mid-afternoon snacking None</span> +<span class="go">5 5 Dinner None</span> +<span class="go">6 96 None of them None</span> +<span class="go">7 98 Don't know (it varies a lot) None</span> +</pre></div> +</div> +<p>This output is extended with the <code class="docutils literal"><span class="pre">item</span></code> metadata if an <code class="docutils literal"><span class="pre">array</span></code> is passed:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'q6'</span><span class="p">)</span> +<span class="go">single items item texts codes texts missing</span> +<span class="go">q6: How often do you take part in any of the fo...</span> +<span class="go">1 q6_1 Exercise alone 1 Once a day or more often None</span> +<span class="go">2 q6_2 Join an exercise class 2 Every few days None</span> +<span class="go">3 q6_3 Play any kind of team sport 3 Once a week None</span> +<span class="go">4 4 Once a fortnight None</span> +<span class="go">5 5 Once a month None</span> +<span class="go">6 6 Once every few months None</span> +<span class="go">7 7 Once every six months None</span> +<span class="go">8 8 Once a year None</span> +<span class="go">9 9 Less often than once a year None</span> +<span class="go">10 10 Never None</span> +</pre></div> +</div> +<p>If the variable is not categorical, <code class="docutils literal"><span class="pre">meta()</span></code> returns simply:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'weight_a'</span><span class="p">)</span> +<span class="go"> float</span> +<span class="go">weight_a: Weight (variant A) N/A</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">DataSet</span></code> also provides a lot of methods to access and return the several +meta objects of a variable to make various data processing tasks easier:</p> +<p><strong>Variable labels</strong>: <code class="xref py py-meth docutils literal"><span class="pre">quantipy.core.dataset.DataSet.text()</span></code></p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s1">'q8'</span><span class="p">,</span> <span class="n">text_key</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> +<span class="go">Which of the following do you regularly skip?</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">values</span></code> <strong>object</strong>: <code class="xref py py-meth docutils literal"><span class="pre">quantipy.core.dataset.DataSet.values()</span></code></p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">values</span><span class="p">(</span><span class="s1">'gender'</span><span class="p">,</span> <span class="n">text_key</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> +<span class="go">[(1, u'Male'), (2, u'Female')]</span> +</pre></div> +</div> +<p><strong>Category codes</strong>: <code class="xref py py-meth docutils literal"><span class="pre">quantipy.core.dataset.DataSet.codes()</span></code></p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">codes</span><span class="p">(</span><span class="s1">'gender'</span><span class="p">)</span> +<span class="go">[1, 2]</span> +</pre></div> +</div> +<p><strong>Category labels</strong>: <code class="xref py py-meth docutils literal"><span class="pre">quantipy.core.dataset.DataSet.value_texts()</span></code></p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">value_texts</span><span class="p">(</span><span class="s1">'gender'</span><span class="p">,</span> <span class="n">text_key</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> +<span class="go">[u'Male', u'Female']</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">items</span></code> <strong>object</strong>: <code class="xref py py-meth docutils literal"><span class="pre">quantipy.core.dataset.DataSet.items()</span></code></p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">items</span><span class="p">(</span><span class="s1">'q6'</span><span class="p">,</span> <span class="n">text_key</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> +<span class="go">[(u'q6_1', u'How often do you exercise alone?'),</span> +<span class="go"> (u'q6_2', u'How often do you take part in an exercise class?'),</span> +<span class="go"> (u'q6_3', u'How often do you play any kind of team sport?')]</span> +</pre></div> +</div> +<p><strong>Item</strong> <code class="docutils literal"><span class="pre">'columns'</span></code> <strong>sources</strong>: <code class="xref py py-meth docutils literal"><span class="pre">quantipy.core.dataset.DataSet.sources()</span></code></p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">sources</span><span class="p">(</span><span class="s1">'q6'</span><span class="p">)</span> +<span class="go">[u'q6_1', u'q6_2', u'q6_3']</span> +</pre></div> +</div> +<p><strong>Item labels</strong>: <code class="xref py py-meth docutils literal"><span class="pre">quantipy.core.dataset.DataSet.item_texts()</span></code></p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">item_texts</span><span class="p">(</span><span class="s1">'q6'</span><span class="p">,</span> <span class="n">text_key</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> +<span class="go">[u'How often do you exercise alone?',</span> +<span class="go"> u'How often do you take part in an exercise class?',</span> +<span class="go"> u'How often do you play any kind of team sport?']</span> +</pre></div> +</div> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="04_editing.html" class="btn btn-neutral float-right" title="Editing metadata" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="02a_management.html" class="btn btn-neutral" title="DataSet management" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/dataprocessing/04_editing.html b/docs/API/_build/html/sites/lib_doc/dataprocessing/04_editing.html new file mode 100644 index 000000000..f9af45717 --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/dataprocessing/04_editing.html @@ -0,0 +1,631 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Editing metadata — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="Data processing" href="00_overview.html"/> + <link rel="next" title="Transforming variables" href="05_transforming.html"/> + <link rel="prev" title="Inspecting variables" href="03_inspection.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html">Data processing</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html">Data processing</a> »</li> + + <li>Editing metadata</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/dataprocessing/04_editing.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="editing-metadata"> +<h1>Editing metadata<a class="headerlink" href="#editing-metadata" title="Permalink to this headline">¶</a></h1> +<div class="section" id="creating-meta-from-scratch"> +<h2>Creating meta from scratch<a class="headerlink" href="#creating-meta-from-scratch" title="Permalink to this headline">¶</a></h2> +<p>It is very easy to add new variable metadata to a <code class="docutils literal"><span class="pre">DataSet</span></code> via <code class="docutils literal"><span class="pre">add_meta()</span></code> +which let’s you create all supported variable types. Each new variable needs at +least a <code class="docutils literal"><span class="pre">name</span></code>, <code class="docutils literal"><span class="pre">qtype</span></code> and <code class="docutils literal"><span class="pre">label</span></code>. With this information a <code class="docutils literal"><span class="pre">string</span></code>, +<code class="docutils literal"><span class="pre">int</span></code>, <code class="docutils literal"><span class="pre">float</span></code> or <code class="docutils literal"><span class="pre">date</span></code> variable can be defined, e.g.:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">add_meta</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">'new_int'</span><span class="p">,</span> <span class="n">qtype</span><span class="o">=</span><span class="s1">'int'</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">'My new int variable'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'new_int'</span><span class="p">)</span> +<span class="go"> int</span> +<span class="go">new_int: My new int variable N/A</span> +</pre></div> +</div> +<p>Using the <code class="docutils literal"><span class="pre">categories</span></code> parameter we can create categorical variables of type +<code class="docutils literal"><span class="pre">single</span></code> or <code class="docutils literal"><span class="pre">delimited</span> <span class="pre">set</span></code>. We can provide the <code class="docutils literal"><span class="pre">categories</span></code> in two +different ways:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">name</span><span class="p">,</span> <span class="n">qtype</span><span class="p">,</span> <span class="n">label</span> <span class="o">=</span> <span class="s1">'new_single'</span><span class="p">,</span> <span class="s1">'single'</span><span class="p">,</span> <span class="s1">'My new single variable'</span> +</pre></div> +</div> +<p><strong>Providing a list of category labels</strong> (codes will be enumerated starting +from <code class="docutils literal"><span class="pre">1</span></code>):</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">cats</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'Category A'</span><span class="p">,</span> <span class="s1">'Category B'</span><span class="p">,</span> <span class="s1">'Category C'</span><span class="p">]</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">add_meta</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">qtype</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">categories</span><span class="o">=</span><span class="n">cats</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'new_single'</span><span class="p">)</span> +<span class="go">single codes texts missing</span> +<span class="go">new_single: My new single variable</span> +<span class="go">1 1 Category A None</span> +<span class="go">2 2 Category B None</span> +<span class="go">3 3 Category C None</span> +</pre></div> +</div> +<p><strong>Providing a list of tuples pairing codes and labels</strong>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">cats</span> <span class="o">=</span> <span class="p">[(</span><span class="mi">1</span><span class="p">,</span> <span class="s1">'Category A'</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="s1">'Category B'</span><span class="p">),</span> <span class="p">(</span><span class="mi">99</span><span class="p">,</span> <span class="s1">'Category C'</span><span class="p">)]</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">add_meta</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">qtype</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">categories</span><span class="o">=</span><span class="n">cats</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'new_single'</span><span class="p">)</span> +<span class="go">single codes texts missing</span> +<span class="go">new_single: My new single variable</span> +<span class="go">1 1 Category A None</span> +<span class="go">2 2 Category B None</span> +<span class="go">3 99 Category C None</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p><code class="docutils literal"><span class="pre">add_meta()</span></code> is preventing you from adding ill-formed or +inconsistent variable information, e.g. it is not possible to add <code class="docutils literal"><span class="pre">categories</span></code> +to an <code class="docutils literal"><span class="pre">int</span></code>…</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">add_meta</span><span class="p">(</span><span class="s1">'new_int'</span><span class="p">,</span> <span class="s1">'int'</span><span class="p">,</span> <span class="s1">'My new int variable'</span><span class="p">,</span> <span class="n">cats</span><span class="p">)</span> +<span class="go">ValueError: Numerical data of type int does not accept 'categories'.</span> +</pre></div> +</div> +<p>…and you must provide <code class="docutils literal"><span class="pre">categories</span></code> when trying to add categorical data:</p> +<div class="last highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">add_meta</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="s1">'single'</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">categories</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> +<span class="go">ValueError: Must provide 'categories' when requesting data of type single.</span> +</pre></div> +</div> +</div> +<p>Similiar to the usage of the <code class="docutils literal"><span class="pre">categories</span></code> argument, <code class="docutils literal"><span class="pre">items</span></code> is controlling +the creation of an <code class="docutils literal"><span class="pre">array</span></code>, i.e. specifying <code class="docutils literal"><span class="pre">items</span></code> is automatically +preparing the <code class="docutils literal"><span class="pre">'masks'</span></code> and <code class="docutils literal"><span class="pre">'columns'</span></code> metadata. The <code class="docutils literal"><span class="pre">qtype</span></code> argument +in this case always refers to the type of the corresponding <code class="docutils literal"><span class="pre">'columns'</span></code>.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">name</span><span class="p">,</span> <span class="n">qtype</span><span class="p">,</span> <span class="n">label</span> <span class="o">=</span> <span class="s1">'new_array'</span><span class="p">,</span> <span class="s1">'single'</span><span class="p">,</span> <span class="s1">'My new array variable'</span> +<span class="gp">>>> </span><span class="n">cats</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'Category A'</span><span class="p">,</span> <span class="s1">'Category B'</span><span class="p">,</span> <span class="s1">'Category C'</span><span class="p">]</span> +</pre></div> +</div> +<p>Again, there are two alternatives to construct the <code class="docutils literal"><span class="pre">items</span></code> object:</p> +<p><strong>Providing a list of item labels</strong> (item identifiers will be enumerated +starting from <code class="docutils literal"><span class="pre">1</span></code>):</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">items</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'Item A'</span><span class="p">,</span> <span class="s1">'Item B'</span><span class="p">,</span> <span class="s1">'Item C'</span><span class="p">,</span> <span class="s1">'Item D'</span><span class="p">]</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">add_meta</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">qtype</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">cats</span><span class="p">,</span> <span class="n">items</span><span class="o">=</span><span class="n">items</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'new_array'</span><span class="p">)</span> +<span class="go">single items item texts codes texts missing</span> +<span class="go">new_array: My new array variable</span> +<span class="go">1 new_array_1 Item A 1 Category A None</span> +<span class="go">2 new_array_2 Item B 2 Category B None</span> +<span class="go">3 new_array_3 Item C 3 Category C None</span> +<span class="go">4 new_array_4 Item D</span> +</pre></div> +</div> +<p><strong>Providing a list of tuples pairing item identifiers and labels</strong>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">items</span> <span class="o">=</span> <span class="p">[(</span><span class="mi">1</span><span class="p">,</span> <span class="s1">'Item A'</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="s1">'Item B'</span><span class="p">),</span> <span class="p">(</span><span class="mi">97</span><span class="p">,</span> <span class="s1">'Item C'</span><span class="p">),</span> <span class="p">(</span><span class="mi">98</span><span class="p">,</span> <span class="s1">'Item D'</span><span class="p">)]</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">add_meta</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">qtype</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">cats</span><span class="p">,</span> <span class="n">items</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'new_array'</span><span class="p">)</span> +<span class="go">single items item texts codes texts missing</span> +<span class="go">new_array: My new array variable</span> +<span class="go">1 new_array_1 Item A 1 Category A None</span> +<span class="go">2 new_array_2 Item B 2 Category B None</span> +<span class="go">3 new_array_97 Item C 3 Category C None</span> +<span class="go">4 new_array_98 Item D</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p>For every created variable, <code class="docutils literal"><span class="pre">add_meta()</span></code> is also adding the relevant <code class="docutils literal"><span class="pre">columns</span></code> +into the <code class="docutils literal"><span class="pre">pd.DataFrame</span></code> case data component of the <code class="docutils literal"><span class="pre">DataSet</span></code> to keep +it consistent:</p> +<div class="last highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="p">[</span><span class="s1">'new_array'</span><span class="p">]</span><span class="o">.</span><span class="n">head</span><span class="p">()</span> +<span class="go"> new_array_1 new_array_2 new_array_97 new_array_98</span> +<span class="go">0 NaN NaN NaN NaN</span> +<span class="go">1 NaN NaN NaN NaN</span> +<span class="go">2 NaN NaN NaN NaN</span> +<span class="go">3 NaN NaN NaN NaN</span> +<span class="go">4 NaN NaN NaN NaN</span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="renaming"> +<h2>Renaming<a class="headerlink" href="#renaming" title="Permalink to this headline">¶</a></h2> +<p>It is possible to attach new names to <code class="docutils literal"><span class="pre">DataSet</span></code> variables. Using the <code class="docutils literal"><span class="pre">rename()</span></code> +method will replace all former variable <code class="docutils literal"><span class="pre">keys</span></code> and other mentions inside the +metadata document and exchange the <code class="docutils literal"><span class="pre">DataFrame</span></code> column names. For <code class="docutils literal"><span class="pre">array</span></code> +variables only the <code class="docutils literal"><span class="pre">'masks'</span></code> name reference is updated by default – to rename +the corresponding <code class="docutils literal"><span class="pre">items</span></code> a dict mapping item position number to new name can +be provided.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">rename</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">'q8'</span><span class="p">,</span> <span class="n">new_name</span><span class="o">=</span><span class="s1">'q8_with_a_new_name'</span><span class="p">)</span> +</pre></div> +</div> +<p>As mentioned, renaming a <code class="docutils literal"><span class="pre">'masks'</span></code> variable will leave the items untouched:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="go">>>></span> +</pre></div> +</div> +<p>But we can simply provide their new names as per:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="go">>>></span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="go">>>></span> +</pre></div> +</div> +</div> +<div class="section" id="changing-adding-text-info"> +<h2>Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info<a class="headerlink" href="#changing-adding-text-info" title="Permalink to this headline">¶</a></h2> +<p>All <code class="docutils literal"><span class="pre">text</span></code>-related <code class="docutils literal"><span class="pre">DataSet</span></code> methods expose the <code class="docutils literal"><span class="pre">text_key</span></code> argument to +control to which language or context a label is added. For instance we can add +a German variable label to <code class="docutils literal"><span class="pre">'q8'</span></code> with <code class="docutils literal"><span class="pre">set_variable_text()</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">set_variable_text</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">'q8'</span><span class="p">,</span> <span class="n">new_text</span><span class="o">=</span><span class="s1">'Das ist ein deutsches Label'</span><span class="p">,</span> <span class="n">text_key</span><span class="o">=</span><span class="s1">'de-DE'</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s1">'q8'</span><span class="p">,</span> <span class="s1">'en-GB'</span><span class="p">)</span> +<span class="go">Which of the following do you regularly skip?</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s1">'q8'</span><span class="p">,</span> <span class="s1">'de-DE'</span><span class="p">)</span> +<span class="go">Das ist ein deutsches Label</span> +</pre></div> +</div> +<p>To change the <code class="docutils literal"><span class="pre">text</span></code> inside the <code class="docutils literal"><span class="pre">values</span></code> or <code class="docutils literal"><span class="pre">items</span></code> metadata, we can +similarly use <code class="docutils literal"><span class="pre">set_value_text</span></code> and <code class="docutils literal"><span class="pre">set_item_text()</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="go">>>></span> +</pre></div> +</div> +<p>When working with multiple language versions of the metadata, it might be required +to copy one language’s <code class="docutils literal"><span class="pre">text</span></code> meta to another one’s, for instance if there are +no fitting translations or the correct translation is missing. In such cases you +can use <code class="docutils literal"><span class="pre">force_texts()</span></code> to copy the meta of a source <code class="docutils literal"><span class="pre">text_key</span></code> (specified +in the <code class="docutils literal"><span class="pre">`copy_from</span></code> parameter) to a target <code class="docutils literal"><span class="pre">text_key</span></code> (indicated via <code class="docutils literal"><span class="pre">copy_to</span></code>).</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="go">>>></span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="go">>>></span> +</pre></div> +</div> +<p>With <code class="docutils literal"><span class="pre">clean_texts()</span></code> you also have the option to replace specific characters, +terms or formatting tags (i.e. <code class="docutils literal"><span class="pre">html</span></code>) from all <code class="docutils literal"><span class="pre">text</span></code> metadata of the +<code class="docutils literal"><span class="pre">DataSet</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="go">>>></span> +</pre></div> +</div> +</div> +<div class="section" id="extending-the-values-object"> +<h2>Extending the <code class="docutils literal"><span class="pre">values</span></code> object<a class="headerlink" href="#extending-the-values-object" title="Permalink to this headline">¶</a></h2> +<p>We can add new category defintitons to existing <code class="docutils literal"><span class="pre">values</span></code> meta with the +<code class="docutils literal"><span class="pre">extend_values()</span></code> method. As when adding full metadata for categorical +variables, new <code class="docutils literal"><span class="pre">values</span></code> can be generated by either providing only labels or +tuples of codes and labels.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="go">>>></span> +</pre></div> +</div> +<p>While the method will never allow adding duplicated numeric values for the +categories, setting <code class="docutils literal"><span class="pre">safe</span></code> to <code class="docutils literal"><span class="pre">False</span></code> will enable you to add duplicated <code class="docutils literal"><span class="pre">text</span></code> +meta, i.e. <code class="docutils literal"><span class="pre">values</span></code> could contain both +<code class="docutils literal"><span class="pre">{'text':</span> <span class="pre">{'en-GB':</span> <span class="pre">'No</span> <span class="pre">answer'},</span> <span class="pre">'value':</span> <span class="pre">98}</span></code> and +<code class="docutils literal"><span class="pre">{'text':</span> <span class="pre">{'en-GB':</span> <span class="pre">'No</span> <span class="pre">answer'},</span> <span class="pre">'value':</span> <span class="pre">99}</span></code>. By default, however, +the method will strictly prohibit any duplicates in the resulting <code class="docutils literal"><span class="pre">values</span></code>.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="go">>>></span> +</pre></div> +</div> +</div> +<div class="section" id="reordering-the-values-object"> +<h2>Reordering the <code class="docutils literal"><span class="pre">values</span></code> object<a class="headerlink" href="#reordering-the-values-object" title="Permalink to this headline">¶</a></h2> +</div> +<div class="section" id="removing-dataset-objects"> +<h2>Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects<a class="headerlink" href="#removing-dataset-objects" title="Permalink to this headline">¶</a></h2> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="05_transforming.html" class="btn btn-neutral float-right" title="Transforming variables" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="03_inspection.html" class="btn btn-neutral" title="Inspecting variables" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/dataprocessing/05_transforming.html b/docs/API/_build/html/sites/lib_doc/dataprocessing/05_transforming.html new file mode 100644 index 000000000..166727f1a --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/dataprocessing/05_transforming.html @@ -0,0 +1,843 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Transforming variables — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="Data processing" href="00_overview.html"/> + <link rel="next" title="Logic and set operaters" href="06_logics.html"/> + <link rel="prev" title="Editing metadata" href="04_editing.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html">Data processing</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html">Data processing</a> »</li> + + <li>Transforming variables</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/dataprocessing/05_transforming.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="section" id="transforming-variables"> +<h1>Transforming variables<a class="headerlink" href="#transforming-variables" title="Permalink to this headline">¶</a></h1> +<div class="toctree-wrapper compound"> +</div> +<div class="section" id="copying"> +<h2>Copying<a class="headerlink" href="#copying" title="Permalink to this headline">¶</a></h2> +<p>It’s often recommended to draw a clean copy of a variable before starting to +editing its meta or case data. With <code class="docutils literal"><span class="pre">copy()</span></code> you can add a copy to the +<code class="docutils literal"><span class="pre">DataSet</span></code> that is identical to the original in all respects but its name. By +default, the copy’s name will be suffixed with <code class="docutils literal"><span class="pre">'_rec'</span></code>, but you can apply a +custom suffix by providing it via the <code class="docutils literal"><span class="pre">suffix</span></code> argument (leaving out the +<code class="docutils literal"><span class="pre">'_'</span></code> which is added automatically):</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="s1">'q3'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="s1">'q3'</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s1">'version2'</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">delimited_sets</span> +<span class="go">[u'q3', u'q2', u'q9', u'q8', u'q3_rec', u'q3_version2']</span> +</pre></div> +</div> +<p>Querying the <code class="docutils literal"><span class="pre">DataSet</span></code>, we can see that all three version are looking identical:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="p">[[</span><span class="s1">'q3'</span><span class="p">,</span> <span class="s1">'q3_rec'</span><span class="p">,</span> <span class="s1">'q3_version2'</span><span class="p">]]</span><span class="o">.</span><span class="n">head</span><span class="p">()</span> +<span class="go"> q3 q3_rec q3_version2</span> +<span class="go">0 1;2;3; 1;2;3; 1;2;3;</span> +<span class="go">1 1;2;3; 1;2;3; 1;2;3;</span> +<span class="go">2 1;2;3; 1;2;3; 1;2;3;</span> +<span class="go">3 1;3; 1;3; 1;3;</span> +<span class="go">4 2; 2; 2;</span> +</pre></div> +</div> +<p>We can, however, prevent copying the case data and simply add an “empty” copy +of the variable by passing <code class="docutils literal"><span class="pre">copy_data=False</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="s1">'q3'</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s1">'no_data'</span><span class="p">,</span> <span class="n">copy_data</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="p">[[</span><span class="s1">'q3'</span><span class="p">,</span> <span class="s1">'q3_rec'</span><span class="p">,</span> <span class="s1">'q3_version2'</span><span class="p">,</span> <span class="s1">'q3_no_data'</span><span class="p">]]</span><span class="o">.</span><span class="n">head</span><span class="p">()</span> +<span class="go"> q3 q3_rec q3_version2 q3_no_data</span> +<span class="go">0 1;2;3; 1;2;3; 1;2;3; NaN</span> +<span class="go">1 1;2;3; 1;2;3; 1;2;3; NaN</span> +<span class="go">2 1;2;3; 1;2;3; 1;2;3; NaN</span> +<span class="go">3 1;3; 1;3; 1;3; NaN</span> +<span class="go">4 2; 2; 2; NaN</span> +</pre></div> +</div> +<p>If we wanted to only copy a subset of the case data, we could also use a +<a class="reference internal" href="06_logics.html"><span class="doc">logical slicer</span></a> and supply it in the <code class="docutils literal"><span class="pre">copy()</span></code> operation’s +<code class="docutils literal"><span class="pre">slicer</span></code> parameter:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">slicer</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'gender'</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">]}</span> +<span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="s1">'q3'</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s1">'only_men'</span><span class="p">,</span> <span class="n">copy_data</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">slicer</span><span class="o">=</span><span class="n">slicer</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="p">[[</span><span class="s1">'q3'</span><span class="p">,</span> <span class="s1">'gender'</span><span class="p">,</span> <span class="s1">'q3_only_men'</span><span class="p">]]</span><span class="o">.</span><span class="n">head</span><span class="p">()</span> +<span class="go"> q3 gender q3_only_men</span> +<span class="go">0 1;2;3; 1 1;2;3;</span> +<span class="go">1 1;2;3; 2 NaN</span> +<span class="go">2 1;2;3; 1 1;2;3;</span> +<span class="go">3 1;3; 1 1;3;</span> +<span class="go">4 2; 1 2;</span> +</pre></div> +</div> +</div> +<div class="section" id="inplace-type-conversion"> +<h2>Inplace type conversion<a class="headerlink" href="#inplace-type-conversion" title="Permalink to this headline">¶</a></h2> +<p>You can change the characteristics of existing <code class="docutils literal"><span class="pre">DataSet</span></code> variables by +converting from one <code class="docutils literal"><span class="pre">type</span></code> to another. Conversions happen <code class="docutils literal"><span class="pre">inplace</span></code>, i.e. +no copy of the variable is taken prior to the operation. Therefore, you might +want to take a <code class="docutils literal"><span class="pre">DataSet.copy()</span></code> before using the <code class="docutils literal"><span class="pre">convert(name,</span> <span class="pre">to)</span></code> +method.</p> +<p>Conversions need to modify both the <code class="docutils literal"><span class="pre">meta</span></code> and <code class="docutils literal"><span class="pre">data</span></code> component of the +<code class="docutils literal"><span class="pre">DataSet</span></code> and are limited to transformations that keep the original and new +state of a variable consistent. The following conversions are currently +supported:</p> +<table border="1" class="docutils"> +<colgroup> +<col width="23%" /> +<col width="15%" /> +<col width="21%" /> +<col width="12%" /> +<col width="14%" /> +<col width="15%" /> +</colgroup> +<tbody valign="top"> +<tr class="row-odd"><td><code class="docutils literal"><span class="pre">name</span></code> (from-<code class="docutils literal"><span class="pre">type</span></code>)</td> +<td><code class="docutils literal"><span class="pre">to='single'</span></code></td> +<td><code class="docutils literal"><span class="pre">to='delimited</span> <span class="pre">set'</span></code></td> +<td><code class="docutils literal"><span class="pre">to='int'</span></code></td> +<td><code class="docutils literal"><span class="pre">to='float'</span></code></td> +<td><code class="docutils literal"><span class="pre">to='string'</span></code></td> +</tr> +<tr class="row-even"><td><code class="docutils literal"><span class="pre">'single'</span></code></td> +<td>[X]</td> +<td>X</td> +<td>X</td> +<td>X</td> +<td>X</td> +</tr> +<tr class="row-odd"><td><code class="docutils literal"><span class="pre">'delimited</span> <span class="pre">set'</span></code></td> +<td> </td> +<td>[X]</td> +<td> </td> +<td> </td> +<td> </td> +</tr> +<tr class="row-even"><td><code class="docutils literal"><span class="pre">'int'</span></code></td> +<td>X</td> +<td> </td> +<td>[X]</td> +<td>X</td> +<td>X</td> +</tr> +<tr class="row-odd"><td><code class="docutils literal"><span class="pre">'float'</span></code></td> +<td> </td> +<td> </td> +<td> </td> +<td>[X]</td> +<td>X</td> +</tr> +<tr class="row-even"><td><code class="docutils literal"><span class="pre">'string'</span></code></td> +<td>X</td> +<td> </td> +<td>X*</td> +<td>X*</td> +<td>[X]</td> +</tr> +<tr class="row-odd"><td><code class="docutils literal"><span class="pre">'date'</span></code></td> +<td>X</td> +<td> </td> +<td> </td> +<td> </td> +<td>X</td> +</tr> +</tbody> +</table> +<p>* <em>If all values of the variable are numerical, i.e.</em> <code class="docutils literal"><span class="pre">DataSet.is_like_numeric()</span></code> <em>returns</em> <code class="docutils literal"><span class="pre">True</span></code>.</p> +<p>Each of these conversions will rebuild the variable meta data to match the <code class="docutils literal"><span class="pre">to</span></code> +type. This means, that for instance a variable that is <code class="docutils literal"><span class="pre">single</span></code> will lose +its <code class="docutils literal"><span class="pre">values</span></code> object when transforming to <code class="docutils literal"><span class="pre">int</span></code>, while the reverse operation +will create a <code class="docutils literal"><span class="pre">values</span></code> object that categorizes the unqiue numeric codes found in the +case data with their <code class="docutils literal"><span class="pre">str</span></code> representation as <code class="docutils literal"><span class="pre">text</span></code> meta. Consider the +variables <code class="docutils literal"><span class="pre">q1</span></code> (<code class="docutils literal"><span class="pre">single</span></code>) and <code class="docutils literal"><span class="pre">age</span></code> (<code class="docutils literal"><span class="pre">int</span></code>):</p> +<p><strong>From type</strong> <code class="docutils literal"><span class="pre">single</span></code> <strong>to</strong> <code class="docutils literal"><span class="pre">int</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'q1'</span><span class="p">)</span> +<span class="go">single codes texts missing</span> +<span class="go">q1: What is your main fitness activity?</span> +<span class="go">1 1 Swimming None</span> +<span class="go">2 2 Running/jogging None</span> +<span class="go">3 3 Lifting weights None</span> +<span class="go">4 4 Aerobics None</span> +<span class="go">5 5 Yoga None</span> +<span class="go">6 6 Pilates None</span> +<span class="go">7 7 Football (soccer) None</span> +<span class="go">8 8 Basketball None</span> +<span class="go">9 9 Hockey None</span> +<span class="go">10 96 Other None</span> +<span class="go">11 98 I regularly change my fitness activity None</span> +<span class="go">12 99 Not applicable - I don't exercise None</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">convert</span><span class="p">(</span><span class="s1">'q1'</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="s1">'int'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'q1'</span><span class="p">)</span> +<span class="go"> int</span> +<span class="go">q1: What is your main fitness activity? N/A</span> +</pre></div> +</div> +<p><strong>From type</strong> <code class="docutils literal"><span class="pre">int</span></code> <strong>to</strong> <code class="docutils literal"><span class="pre">single</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'age'</span><span class="p">)</span> +<span class="go"> int</span> +<span class="go">age: Age N/A</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">convert</span><span class="p">(</span><span class="s1">'age'</span><span class="p">,</span> <span class="n">to</span><span class="o">=</span><span class="s1">'single'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'age'</span><span class="p">)</span> +<span class="go">single codes texts missing</span> +<span class="go">age: Age</span> +<span class="go">1 19 19 None</span> +<span class="go">2 20 20 None</span> +<span class="go">3 21 21 None</span> +<span class="go">4 22 22 None</span> +<span class="go">5 23 23 None</span> +<span class="go">6 24 24 None</span> +<span class="go">7 25 25 None</span> +<span class="go">8 26 26 None</span> +<span class="go">9 27 27 None</span> +<span class="go">10 28 28 None</span> +<span class="go">11 29 29 None</span> +<span class="go">12 30 30 None</span> +<span class="go">13 31 31 None</span> +<span class="go">14 32 32 None</span> +<span class="go">15 33 33 None</span> +<span class="go">16 34 34 None</span> +<span class="go">17 35 35 None</span> +<span class="go">18 36 36 None</span> +<span class="go">19 37 37 None</span> +<span class="go">20 38 38 None</span> +<span class="go">21 39 39 None</span> +<span class="go">22 40 40 None</span> +<span class="go">23 41 41 None</span> +<span class="go">24 42 42 None</span> +<span class="go">25 43 43 None</span> +<span class="go">26 44 44 None</span> +<span class="go">27 45 45 None</span> +<span class="go">28 46 46 None</span> +<span class="go">29 47 47 None</span> +<span class="go">30 48 48 None</span> +<span class="go">31 49 49 None</span> +</pre></div> +</div> +</div> +<div class="section" id="banding-and-categorization"> +<h2>Banding and categorization<a class="headerlink" href="#banding-and-categorization" title="Permalink to this headline">¶</a></h2> +<p>In contrast to <code class="docutils literal"><span class="pre">convert()</span></code>, the <code class="docutils literal"><span class="pre">categorize()</span></code> method creates a new +variable of type <code class="docutils literal"><span class="pre">single</span></code>, acting as a short-hand for creating a renamed copy +and then type-transforming it. Therefore, it lets you quickly categorize +the unique values of a <code class="docutils literal"><span class="pre">text</span></code>, <code class="docutils literal"><span class="pre">int</span></code> or <code class="docutils literal"><span class="pre">date</span></code> variable, storing +<code class="docutils literal"><span class="pre">values</span></code> meta in the form of <code class="docutils literal"><span class="pre">{'text':</span> <span class="pre">{'en-GB':</span> <span class="pre">str(1)},</span> <span class="pre">'value':</span> <span class="pre">1}</span></code>.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="go">>>></span> +</pre></div> +</div> +<p>Flexible banding of numeric data is provided thorugh <code class="docutils literal"><span class="pre">DataSet.band()</span></code>: If a +variable is banded, it will standardly be added to the <code class="docutils literal"><span class="pre">DataSet</span></code> via the +original’s name suffixed with <code class="docutils literal"><span class="pre">'banded'</span></code>, e.g. <code class="docutils literal"><span class="pre">'age_banded'</span></code>, keeping +the originating variables <code class="docutils literal"><span class="pre">text</span></code> label. The <code class="docutils literal"><span class="pre">new_name</span></code> and <code class="docutils literal"><span class="pre">label</span></code> +parameters can be used to create custom variable names and labels. The banding +of the incoming data is controlled with the <code class="docutils literal"><span class="pre">bands</span></code> argument that expects a +list containing <code class="docutils literal"><span class="pre">int</span></code>, <code class="docutils literal"><span class="pre">tuples</span></code> or <code class="docutils literal"><span class="pre">dict</span></code>, where each type is used for a +different kind of group definition.</p> +<p><strong>Banding with</strong> <code class="docutils literal"><span class="pre">int</span></code> <strong>and</strong> <code class="docutils literal"><span class="pre">tuple</span></code>:</p> +<ul class="simple"> +<li>Use an <code class="docutils literal"><span class="pre">int</span></code> to make a band of only one value</li> +<li>Use a <code class="docutils literal"><span class="pre">tuple</span></code> to indicate (inclusive) group limits</li> +<li><code class="docutils literal"><span class="pre">values</span></code> <code class="docutils literal"><span class="pre">text</span></code> meta is infered</li> +<li>Example: <code class="docutils literal"><span class="pre">[0,</span> <span class="pre">(1,</span> <span class="pre">10),</span> <span class="pre">(11,</span> <span class="pre">14),</span> <span class="pre">15,</span> <span class="pre">(16,</span> <span class="pre">25)]</span></code></li> +</ul> +<p><strong>Banding with</strong> <code class="docutils literal"><span class="pre">dict</span></code>:</p> +<ul class="simple"> +<li>The dict <code class="docutils literal"><span class="pre">key</span></code> will dicate the group’s <code class="docutils literal"><span class="pre">text</span></code> label meta</li> +<li>The dict <code class="docutils literal"><span class="pre">value</span></code> can pick up an <code class="docutils literal"><span class="pre">int</span></code> / <code class="docutils literal"><span class="pre">tuple</span></code> (see above)</li> +<li>Example: <code class="docutils literal"><span class="pre">[{'A':</span> <span class="pre">0},</span> <span class="pre">{'B':</span> <span class="pre">(1,</span> <span class="pre">10)},</span> <span class="pre">{'C':</span> <span class="pre">(11,</span> <span class="pre">14)},</span> <span class="pre">{'D':</span> <span class="pre">15},</span> <span class="pre">{'E':</span> <span class="pre">(16,</span> <span class="pre">25)}]</span></code></li> +<li>Mixing allowed: <code class="docutils literal"><span class="pre">[0,</span> <span class="pre">{'A':</span> <span class="pre">(1,</span> <span class="pre">10)},</span> <span class="pre">(11,</span> <span class="pre">14),</span> <span class="pre">15,</span> <span class="pre">{'B':</span> <span class="pre">(16,</span> <span class="pre">25)}]</span></code></li> +</ul> +<p>For instance, we could band <code class="docutils literal"><span class="pre">'age'</span></code> into a new variable called <code class="docutils literal"><span class="pre">'grouped_age'</span></code> +with <code class="docutils literal"><span class="pre">bands</span></code> being:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">bands</span> <span class="o">=</span> <span class="p">[{</span><span class="s1">'Younger than 35'</span><span class="p">:</span> <span class="p">(</span><span class="mi">19</span><span class="p">,</span> <span class="mi">34</span><span class="p">)},</span> +<span class="gp">... </span> <span class="p">(</span><span class="mi">35</span><span class="p">,</span> <span class="mi">39</span><span class="p">),</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'Exactly 40'</span><span class="p">:</span> <span class="mi">40</span><span class="p">},</span> +<span class="gp">... </span> <span class="mi">41</span><span class="p">,</span> +<span class="gp">... </span> <span class="p">(</span><span class="mi">42</span><span class="p">,</span> <span class="mi">60</span><span class="p">)]</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">band</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">'age'</span><span class="p">,</span> <span class="n">bands</span><span class="o">=</span><span class="n">bands</span><span class="p">,</span> <span class="n">new_name</span><span class="o">=</span><span class="s1">'grouped_age'</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'grouped_age'</span><span class="p">)</span> +<span class="go">single codes texts missing</span> +<span class="go">grouped_age: Age</span> +<span class="go">1 1 Younger than 35 None</span> +<span class="go">2 2 35-39 None</span> +<span class="go">3 3 Exactly 40 None</span> +<span class="go">4 4 41 None</span> +<span class="go">5 5 42-60 None</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">crosstab</span><span class="p">(</span><span class="s1">'age'</span><span class="p">,</span> <span class="s1">'grouped_age'</span><span class="p">)</span> +<span class="go">Question grouped_age. Age</span> +<span class="go">Values All Younger than 35 35-39 Exactly 40 41 42-60</span> +<span class="go">Question Values</span> +<span class="go">age. Age All 8255 4308 1295 281 261 2110</span> +<span class="go"> 19 245 245 0 0 0 0</span> +<span class="go"> 20 277 277 0 0 0 0</span> +<span class="go"> 21 270 270 0 0 0 0</span> +<span class="go"> 22 323 323 0 0 0 0</span> +<span class="go"> 23 272 272 0 0 0 0</span> +<span class="go"> 24 263 263 0 0 0 0</span> +<span class="go"> 25 246 246 0 0 0 0</span> +<span class="go"> 26 252 252 0 0 0 0</span> +<span class="go"> 27 260 260 0 0 0 0</span> +<span class="go"> 28 287 287 0 0 0 0</span> +<span class="go"> 29 270 270 0 0 0 0</span> +<span class="go"> 30 271 271 0 0 0 0</span> +<span class="go"> 31 264 264 0 0 0 0</span> +<span class="go"> 32 287 287 0 0 0 0</span> +<span class="go"> 33 246 246 0 0 0 0</span> +<span class="go"> 34 275 275 0 0 0 0</span> +<span class="go"> 35 258 0 258 0 0 0</span> +<span class="go"> 36 236 0 236 0 0 0</span> +<span class="go"> 37 252 0 252 0 0 0</span> +<span class="go"> 38 291 0 291 0 0 0</span> +<span class="go"> 39 258 0 258 0 0 0</span> +<span class="go"> 40 281 0 0 281 0 0</span> +<span class="go"> 41 261 0 0 0 261 0</span> +<span class="go"> 42 290 0 0 0 0 290</span> +<span class="go"> 43 267 0 0 0 0 267</span> +<span class="go"> 44 261 0 0 0 0 261</span> +<span class="go"> 45 257 0 0 0 0 257</span> +<span class="go"> 46 259 0 0 0 0 259</span> +<span class="go"> 47 243 0 0 0 0 243</span> +<span class="go"> 48 271 0 0 0 0 271</span> +<span class="go"> 49 262 0 0 0 0 262</span> +</pre></div> +</div> +</div> +<div class="section" id="array-transformations"> +<h2>Array transformations<a class="headerlink" href="#array-transformations" title="Permalink to this headline">¶</a></h2> +<p><strong>Transposing arrays</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet</span></code> offers tools to simplify common <code class="docutils literal"><span class="pre">array</span></code> variable operations. +You can switch the structure of <code class="docutils literal"><span class="pre">items</span></code> vs. <code class="docutils literal"><span class="pre">values</span></code> by producing the one +from the other using <code class="docutils literal"><span class="pre">transpose()</span></code>. The transposition of an array will always +result in <code class="docutils literal"><span class="pre">items</span></code> that have the <code class="docutils literal"><span class="pre">delimited</span> <span class="pre">set</span></code> type in the corresponding +<code class="docutils literal"><span class="pre">'columns'</span></code> metadata. That is because the transposed array is collecting +what former items have been assignd per former value:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">transpose</span><span class="p">(</span><span class="s1">'q5'</span><span class="p">)</span> +</pre></div> +</div> +<p><em>Original</em></p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="p">[</span><span class="s1">'q5'</span><span class="p">]</span><span class="o">.</span><span class="n">head</span><span class="p">()</span> +<span class="go"> q5_1 q5_2 q5_3 q5_4 q5_5 q5_6</span> +<span class="go">0 2 2 2 2 1 2</span> +<span class="go">1 5 5 3 3 3 5</span> +<span class="go">2 5 98 5 5 1 5</span> +<span class="go">3 5 5 1 5 3 5</span> +<span class="go">4 98 98 98 98 98 98</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'q5'</span><span class="p">)</span> +<span class="go">single items item texts codes texts missing</span> +<span class="go">q5: How likely are you to do each of the follow...</span> +<span class="go">1 q5_1 Surfing 1 I would refuse if asked None</span> +<span class="go">2 q5_2 Snowboarding 2 Very unlikely None</span> +<span class="go">3 q5_3 Kite boarding 3 Probably wouldn't None</span> +<span class="go">4 q5_4 Parachuting 4 Probably would if asked None</span> +<span class="go">5 q5_5 Cave diving 5 Very likely None</span> +<span class="go">6 q5_6 Windsurfing 97 I'm already planning to None</span> +<span class="go">7 98 Don't know None</span> +</pre></div> +</div> +<p><em>Transposition</em></p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="p">[</span><span class="s1">'q5_trans'</span><span class="p">]</span><span class="o">.</span><span class="n">head</span><span class="p">()</span> +<span class="go"> q5_trans_1 q5_trans_2 q5_trans_3 q5_trans_4 q5_trans_5 q5_trans_97 q5_trans_98</span> +<span class="go">0 5; 1;2;3;4;6; NaN NaN NaN NaN NaN</span> +<span class="go">1 NaN NaN 3;4;5; NaN 1;2;6; NaN NaN</span> +<span class="go">2 5; NaN NaN NaN 1;3;4;6; NaN 2;</span> +<span class="go">3 3; NaN 5; NaN 1;2;4;6; NaN NaN</span> +<span class="go">4 NaN NaN NaN NaN NaN NaN 1;2;3;4;5;6;</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'q5_trans'</span><span class="p">)</span> +<span class="go">delimited set items item texts codes texts missing</span> +<span class="go">q5_trans: How likely are you to do each of the ...</span> +<span class="go">1 q5_trans_1 I would refuse if asked 1 Surfing None</span> +<span class="go">2 q5_trans_2 Very unlikely 2 Snowboarding None</span> +<span class="go">3 q5_trans_3 Probably wouldn't 3 Kite boarding None</span> +<span class="go">4 q5_trans_4 Probably would if asked 4 Parachuting None</span> +<span class="go">5 q5_trans_5 Very likely 5 Cave diving None</span> +<span class="go">6 q5_trans_97 I'm already planning to 6 Windsurfing None</span> +<span class="go">7 q5_trans_98 Don't know</span> +</pre></div> +</div> +<p>The method’s <code class="docutils literal"><span class="pre">ignore_items</span></code> and <code class="docutils literal"><span class="pre">ignore_values</span></code> arguments can pick up +<code class="docutils literal"><span class="pre">items</span></code> (indicated by their order number) and <code class="docutils literal"><span class="pre">values</span></code> to leave aside +during the transposition.</p> +<p><em>Ignoring items</em></p> +<p>The new <code class="docutils literal"><span class="pre">values</span></code> meta’s numerical codes will always be enumerated from 1 to +the number of valid items for the transposition, so ignoring items 2, 3 and 4 +will lead to:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">transpose</span><span class="p">(</span><span class="s1">'q5'</span><span class="p">,</span> <span class="n">ignore_items</span><span class="o">=</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">])</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="p">[</span><span class="s1">'q5_trans'</span><span class="p">]</span><span class="o">.</span><span class="n">head</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> +<span class="go"> q5_trans_1 q5_trans_2 q5_trans_3 q5_trans_4 q5_trans_5 q5_trans_97 q5_trans_98</span> +<span class="go">0 2; 1;3; NaN NaN NaN NaN NaN</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">values</span><span class="p">(</span><span class="s1">'q5_trans'</span><span class="p">)</span> +<span class="go">[(1, 'Surfing'), (2, 'Cave diving'), (3, 'Windsurfing')]</span> +</pre></div> +</div> +<p><em>Ignoring values</em></p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">transpose</span><span class="p">(</span><span class="s1">'q5'</span><span class="p">,</span> <span class="n">ignore_values</span><span class="o">=</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">97</span><span class="p">])</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="p">[</span><span class="s1">'q5_trans'</span><span class="p">]</span><span class="o">.</span><span class="n">head</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> +<span class="go"> q5_trans_2 q5_trans_3 q5_trans_4 q5_trans_5 q5_trans_98</span> +<span class="go">0 1;2;3;4;6; NaN NaN NaN NaN</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">items</span><span class="p">(</span><span class="s1">'q5_trans'</span><span class="p">)</span> +<span class="go">[('q5_trans_2', u'Very unlikely'),</span> +<span class="go"> ('q5_trans_3', u"Probably wouldn't"),</span> +<span class="go"> ('q5_trans_4', u'Probably would if asked'),</span> +<span class="go"> ('q5_trans_5', u'Very likely'),</span> +<span class="go"> ('q5_trans_98', u"Don't know")]</span> +</pre></div> +</div> +<p><em>Ignoring both items and values</em></p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">transpose</span><span class="p">(</span><span class="s1">'q5'</span><span class="p">,</span> <span class="n">ignore_items</span><span class="o">=</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">],</span> <span class="n">ignore_values</span><span class="o">=</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">97</span><span class="p">])</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="p">[</span><span class="s1">'q5_trans'</span><span class="p">]</span><span class="o">.</span><span class="n">head</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> +<span class="go"> q5_trans_2 q5_trans_3 q5_trans_4 q5_trans_5 q5_trans_98</span> +<span class="go">0 1;3; NaN NaN NaN NaN</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'q5_trans'</span><span class="p">)</span> +<span class="go">delimited set items item texts codes texts missing</span> +<span class="go">q5_trans: How likely are you to do each of the ...</span> +<span class="go">1 q5_trans_2 Very unlikely 1 Surfing None</span> +<span class="go">2 q5_trans_3 Probably wouldn't 2 Cave diving None</span> +<span class="go">3 q5_trans_4 Probably would if asked 3 Windsurfing None</span> +<span class="go">4 q5_trans_5 Very likely</span> +<span class="go">5 q5_trans_98 Don't know</span> +</pre></div> +</div> +<p><strong>Flatten item answers</strong></p> +<ul class="simple"> +<li><code class="docutils literal"><span class="pre">flatten()</span></code></li> +</ul> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="06_logics.html" class="btn btn-neutral float-right" title="Logic and set operaters" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="04_editing.html" class="btn btn-neutral" title="Editing metadata" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/dataprocessing/06_logics.html b/docs/API/_build/html/sites/lib_doc/dataprocessing/06_logics.html new file mode 100644 index 000000000..adaac7c1e --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/dataprocessing/06_logics.html @@ -0,0 +1,589 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Logic and set operaters — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="Data processing" href="00_overview.html"/> + <link rel="next" title="Custom data recoding" href="07_custom_recoding.html"/> + <link rel="prev" title="Transforming variables" href="05_transforming.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html">Data processing</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html">Data processing</a> »</li> + + <li>Logic and set operaters</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/dataprocessing/06_logics.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="logic-and-set-operaters"> +<h1>Logic and set operaters<a class="headerlink" href="#logic-and-set-operaters" title="Permalink to this headline">¶</a></h1> +<div class="section" id="ranges"> +<h2>Ranges<a class="headerlink" href="#ranges" title="Permalink to this headline">¶</a></h2> +<p>The <code class="docutils literal"><span class="pre">frange()</span></code> function takes a string of abbreviated ranges, possibly delimited +by a comma (or some other character) and extrapolates its full, +unabbreviated list of ints.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">quantipy.core.tools.dp.prep</span> <span class="k">import</span> <span class="n">frange</span> +</pre></div> +</div> +<p><strong>Basic range</strong>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">frange</span><span class="p">(</span><span class="s1">'1-5'</span><span class="p">)</span> +<span class="go">[1, 2, 3, 4, 5]</span> +</pre></div> +</div> +<p><strong>Range in reverse</strong>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">frange</span><span class="p">(</span><span class="s1">'15-11'</span><span class="p">)</span> +<span class="go">[15, 14, 13, 12, 11]</span> +</pre></div> +</div> +<p><strong>Combination</strong>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">frange</span><span class="p">(</span><span class="s1">'1-5,7,9,15-11'</span><span class="p">)</span> +<span class="go">[1, 2, 3, 4, 5, 7, 9, 15, 14, 13, 12, 11]</span> +</pre></div> +</div> +<p><strong>May include spaces for clarity</strong>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">frange</span><span class="p">(</span><span class="s1">'1-5, 7, 9, 15-11'</span><span class="p">)</span> +<span class="go">[1, 2, 3, 4, 5, 7, 9, 15, 14, 13, 12, 11]</span> +</pre></div> +</div> +</div> +<div class="section" id="complex-logic"> +<h2>Complex logic<a class="headerlink" href="#complex-logic" title="Permalink to this headline">¶</a></h2> +<p>Multiple conditions can be combined using <code class="docutils literal"><span class="pre">union</span></code> or <code class="docutils literal"><span class="pre">intersection</span></code> set +statements. Logical mappers can be arbitrarily nested as long as they are +well-formed.</p> +<div class="section" id="union"> +<h3><code class="docutils literal"><span class="pre">union</span></code><a class="headerlink" href="#union" title="Permalink to this headline">¶</a></h3> +<p><code class="docutils literal"><span class="pre">union</span></code> takes a list of logical conditions that will be treated with +<strong>or</strong> logic.</p> +<p>Where <strong>any</strong> of logic_A, logic_B <strong>or</strong> logic_C are <code class="docutils literal"><span class="pre">True</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">union</span><span class="p">([</span><span class="n">logic_A</span><span class="p">,</span> <span class="n">logic_B</span><span class="p">,</span> <span class="n">logic_C</span><span class="p">])</span> +</pre></div> +</div> +</div> +<div class="section" id="intersection"> +<h3><code class="docutils literal"><span class="pre">intersection</span></code><a class="headerlink" href="#intersection" title="Permalink to this headline">¶</a></h3> +<p><code class="docutils literal"><span class="pre">intersection</span></code> takes a list of conditions that will be +treated with <strong>and</strong> logic.</p> +<p>Where <strong>all</strong> of logic_A, logic_B <strong>and</strong> logic_C are <code class="docutils literal"><span class="pre">True</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">intersection</span><span class="p">([</span><span class="n">logic_A</span><span class="p">,</span> <span class="n">logic_B</span><span class="p">,</span> <span class="n">logic_C</span><span class="p">])</span> +</pre></div> +</div> +</div> +<div class="section" id="list-logic"> +<h3>“List” logic<a class="headerlink" href="#list-logic" title="Permalink to this headline">¶</a></h3> +<p>Instead of using the verbose <code class="docutils literal"><span class="pre">has_any</span></code> operator, we can express simple, non-nested +<em>or</em> logics simply as a list of codes. For example <code class="docutils literal"><span class="pre">{"q1_1":</span> <span class="pre">[1,</span> <span class="pre">2]}</span></code> is an +example of list-logic, where <code class="docutils literal"><span class="pre">[1,</span> <span class="pre">2]</span></code> will be interpreted as <code class="docutils literal"><span class="pre">has_any([1,</span> <span class="pre">2])</span></code>, +meaning if <strong>q1_1</strong> has any of the values <strong>1</strong> or <strong>2</strong>.</p> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> has any of the responses 1, 2 or 3:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]}</span> +</pre></div> +</div> +</div> +<div class="section" id="has-any"> +<h3><code class="docutils literal"><span class="pre">has_any</span></code><a class="headerlink" href="#has-any" title="Permalink to this headline">¶</a></h3> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> has any of the responses 1, 2 or 3:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">has_any</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">])}</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> has any of the responses 1, 2 or 3 and no others:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">has_any</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="n">exclusive</span><span class="o">=</span><span class="kc">True</span><span class="p">)}</span> +</pre></div> +</div> +</div> +<div class="section" id="not-any"> +<h3><code class="docutils literal"><span class="pre">not_any</span></code><a class="headerlink" href="#not-any" title="Permalink to this headline">¶</a></h3> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> doesn’t have any of the responses 1, 2 or 3:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">not_any</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">])}</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> doesn’t have any of the responses 1, 2 or 3 but has some others:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">not_any</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="n">exclusive</span><span class="o">=</span><span class="kc">True</span><span class="p">)}</span> +</pre></div> +</div> +</div> +<div class="section" id="has-all"> +<h3><code class="docutils literal"><span class="pre">has_all</span></code><a class="headerlink" href="#has-all" title="Permalink to this headline">¶</a></h3> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> has all of the responses 1, 2 and 3:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">has_all</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">])}</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> has all of the responses 1, 2 and 3 and no others:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">has_all</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="n">exclusive</span><span class="o">=</span><span class="kc">True</span><span class="p">)}</span> +</pre></div> +</div> +</div> +<div class="section" id="not-all"> +<h3><code class="docutils literal"><span class="pre">not_all</span></code><a class="headerlink" href="#not-all" title="Permalink to this headline">¶</a></h3> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> doesn’t have all of the responses 1, 2 and 3:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">not_all</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">])}</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> doesn’t have all of the responses 1, 2 and 3 but has some others:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">not_all</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="n">exclusive</span><span class="o">=</span><span class="kc">True</span><span class="p">)}</span> +</pre></div> +</div> +</div> +<div class="section" id="has-count"> +<h3><code class="docutils literal"><span class="pre">has_count</span></code><a class="headerlink" href="#has-count" title="Permalink to this headline">¶</a></h3> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> has exactly 2 responses:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">has_count</span><span class="p">(</span><span class="mi">2</span><span class="p">)}</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> has 1, 2 or 3 responses:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">has_count</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">])}</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> has 1 or more responses:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">has_count</span><span class="p">([</span><span class="n">is_ge</span><span class="p">(</span><span class="mi">1</span><span class="p">)])}</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> has 1, 2 or 3 responses from the response group 5, 6, 7, 8 or 9:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">has_count</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="p">[</span><span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">9</span><span class="p">]])}</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> has 1 or more responses from the response group 5, 6, 7, 8 or 9:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">has_count</span><span class="p">([</span><span class="n">is_ge</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="p">[</span><span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">9</span><span class="p">]])}</span> +</pre></div> +</div> +</div> +<div class="section" id="not-count"> +<h3><code class="docutils literal"><span class="pre">not_count</span></code><a class="headerlink" href="#not-count" title="Permalink to this headline">¶</a></h3> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> doesn’t have exactly 2 responses:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">not_count</span><span class="p">(</span><span class="mi">2</span><span class="p">)}</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> doesn’t have 1, 2 or 3 responses:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">not_count</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">])}</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> doesn’t have 1 or more responses:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">not_count</span><span class="p">([</span><span class="n">is_ge</span><span class="p">(</span><span class="mi">1</span><span class="p">)])}</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> doesn’t have 1, 2 or 3 responses from the response group 5, 6, 7, 8 or 9:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">not_count</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="p">[</span><span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">9</span><span class="p">]])}</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">q1_1</span></code> doesn’t have 1 or more responses from the response group 5, 6, 7, 8 or 9:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">l</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="n">not_count</span><span class="p">([</span><span class="n">is_ge</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="p">[</span><span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">9</span><span class="p">]])}</span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="boolean-slicers-and-code-existence"> +<h2>Boolean slicers and code existence<a class="headerlink" href="#boolean-slicers-and-code-existence" title="Permalink to this headline">¶</a></h2> +<p><code class="docutils literal"><span class="pre">any()</span></code>, <code class="docutils literal"><span class="pre">all()</span></code> +<code class="docutils literal"><span class="pre">code_count()</span></code>, <code class="docutils literal"><span class="pre">is_nan()</span></code></p> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="07_custom_recoding.html" class="btn btn-neutral float-right" title="Custom data recoding" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="05_transforming.html" class="btn btn-neutral" title="Transforming variables" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/dataprocessing/07_custom_recoding.html b/docs/API/_build/html/sites/lib_doc/dataprocessing/07_custom_recoding.html new file mode 100644 index 000000000..6aa703602 --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/dataprocessing/07_custom_recoding.html @@ -0,0 +1,1036 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Custom data recoding — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="Data processing" href="00_overview.html"/> + <link rel="next" title="Batch" href="../batch/00_overview.html"/> + <link rel="prev" title="Logic and set operaters" href="06_logics.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html">Data processing</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html">Data processing</a> »</li> + + <li>Custom data recoding</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/dataprocessing/07_custom_recoding.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="custom-data-recoding"> +<h1>Custom data recoding<a class="headerlink" href="#custom-data-recoding" title="Permalink to this headline">¶</a></h1> +<div class="section" id="the-recode-method-in-detail"> +<h2>The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail<a class="headerlink" href="#the-recode-method-in-detail" title="Permalink to this headline">¶</a></h2> +<p>This function takes a mapper of <code class="docutils literal"><span class="pre">{key:</span> <span class="pre">logic}</span></code> entries and injects the +key into the target column where its paired logic is True. The logic +may be arbitrarily complex and may refer to any other variable or +variables in data. Where a pre-existing column has been used to +start the recode, the injected values can replace or be appended to +any data found there to begin with. Note that this function does +not edit the target column, it returns a recoded copy of the target +column. The recoded data will always comply with the column type +indicated for the target column according to the meta.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">method:</th><td class="field-body"><code class="docutils literal"><span class="pre">recode(target,</span> <span class="pre">mapper,</span> <span class="pre">default=None,</span> <span class="pre">append=False,</span> +<span class="pre">intersect=None,</span> <span class="pre">initialize=None,</span> <span class="pre">fillna=None,</span> <span class="pre">inplace=True)</span></code></td> +</tr> +</tbody> +</table> +<div class="section" id="target"> +<h3><code class="docutils literal"><span class="pre">target</span></code><a class="headerlink" href="#target" title="Permalink to this headline">¶</a></h3> +<p><code class="docutils literal"><span class="pre">target</span></code> controls which column meta should be used to control the +result of the recode operation. This is important because you cannot +recode multiple responses into a ‘single’-typed column.</p> +<p>The <code class="docutils literal"><span class="pre">target</span></code> column <strong>must</strong> already exist in meta.</p> +<p>The <code class="docutils literal"><span class="pre">recode</span></code> function is effectively a request to return a copy of +the <code class="docutils literal"><span class="pre">target</span></code> column, recoded as instructed. <code class="docutils literal"><span class="pre">recode</span></code> does not +edit the <code class="docutils literal"><span class="pre">target</span></code> column in place, it returns a recoded copy of it.</p> +<p>If the <code class="docutils literal"><span class="pre">target</span></code> column does not already exist in <code class="docutils literal"><span class="pre">data</span></code> then a new +series, named accordingly and initialized with <code class="docutils literal"><span class="pre">np.NaN</span></code>, will begin +the recode.</p> +<p>Return a recoded version of the column <code class="docutils literal"><span class="pre">radio_stations_xb</span></code> edited +based on the given mapper:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">recoded</span> <span class="o">=</span> <span class="n">recode</span><span class="p">(</span> +<span class="gp">... </span> <span class="n">meta</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">target</span><span class="o">=</span><span class="s1">'radio_stations_xb'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">mapper</span><span class="o">=</span><span class="n">mapper</span> +<span class="gp">... </span><span class="p">)</span> +</pre></div> +</div> +<p>By default, recoded data resulting from the the mapper will replace any +data already sitting in the target column (on a cell-by-cell basis).</p> +</div> +<div class="section" id="mapper"> +<h3><code class="docutils literal"><span class="pre">mapper</span></code><a class="headerlink" href="#mapper" title="Permalink to this headline">¶</a></h3> +<p>A mapper is a dict of <code class="docutils literal"><span class="pre">{value:</span> <span class="pre">logic}</span></code> entries where value represents +the data that will be injected for cases where the logic is True.</p> +<p>Here’s a simplified example of what a mapper looks like:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">mapper</span> <span class="o">=</span> <span class="p">{</span> +<span class="gp">... </span> <span class="mi">1</span><span class="p">:</span> <span class="n">logic_A</span><span class="p">,</span> +<span class="gp">... </span> <span class="mi">2</span><span class="p">:</span> <span class="n">logic_B</span><span class="p">,</span> +<span class="gp">... </span> <span class="mi">3</span><span class="p">:</span> <span class="n">logic_C</span><span class="p">,</span> +<span class="gp">... </span><span class="p">}</span> +</pre></div> +</div> +<p>1 will be generated where <code class="docutils literal"><span class="pre">logic_A</span></code> is <code class="docutils literal"><span class="pre">True</span></code>, 2 where <code class="docutils literal"><span class="pre">logic_B</span></code> is +<code class="docutils literal"><span class="pre">True</span></code> and 3 where <code class="docutils literal"><span class="pre">logic_C</span></code> is <code class="docutils literal"><span class="pre">True</span></code>.</p> +<p>The recode function, by referencing the type indicated by the meta, +will manage the complications involved in single vs delimited set +data.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">mapper</span> <span class="o">=</span> <span class="p">{</span> +<span class="gp">... </span> <span class="mi">901</span><span class="p">:</span> <span class="p">{</span><span class="s1">'radio_stations'</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'1-13'</span><span class="p">)},</span> +<span class="gp">... </span> <span class="mi">902</span><span class="p">:</span> <span class="p">{</span><span class="s1">'radio_stations'</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'14-20'</span><span class="p">)},</span> +<span class="gp">... </span> <span class="mi">903</span><span class="p">:</span> <span class="p">{</span><span class="s1">'radio_stations'</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'21-25'</span><span class="p">)}</span> +<span class="gp">... </span><span class="p">}</span> +</pre></div> +</div> +<p>This means: inject 901 if the column <code class="docutils literal"><span class="pre">radio_stations</span></code> has any of the +values 1-13, 902 where <code class="docutils literal"><span class="pre">radio_stations</span></code> has any of the values 14-20 +and 903 where <code class="docutils literal"><span class="pre">radio_stations</span></code> has any of the values 21-25.</p> +</div> +<div class="section" id="default"> +<h3><code class="docutils literal"><span class="pre">default</span></code><a class="headerlink" href="#default" title="Permalink to this headline">¶</a></h3> +<p>If you had lots of values to generate from the same reference column +(say most/all of them were based on <code class="docutils literal"><span class="pre">radio_stations</span></code>) then we can +omit the wildcard logic format and use recode’s default parameter.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">recoded</span> <span class="o">=</span> <span class="n">recode</span><span class="p">(</span> +<span class="gp">... </span> <span class="n">meta</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">target</span><span class="o">=</span><span class="s1">'radio_stations_xb'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">mapper</span><span class="o">=</span><span class="p">{</span> +<span class="gp">... </span> <span class="mi">901</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'1-13'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">902</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'14-20'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">903</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'21-25'</span><span class="p">)</span> +<span class="gp">... </span> <span class="p">},</span> +<span class="gp">... </span> <span class="n">default</span><span class="o">=</span><span class="s1">'radio_stations'</span> +<span class="gp">... </span><span class="p">)</span> +</pre></div> +</div> +<p>This means, all unkeyed logic will default to be keyed to +<code class="docutils literal"><span class="pre">radio_stations</span></code>. In this case the three codes 901, 902 and 903 will +be generated based on the data found in <code class="docutils literal"><span class="pre">radio_stations</span></code>.</p> +<p>You can combine this with reference to other columns, but you can only +provide one default column.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">recoded</span> <span class="o">=</span> <span class="n">recode</span><span class="p">(</span> +<span class="gp">... </span> <span class="n">meta</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">target</span><span class="o">=</span><span class="s1">'radio_stations_xb'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">mapper</span><span class="o">=</span><span class="p">{</span> +<span class="gp">... </span> <span class="mi">901</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'1-13'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">902</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'14-20'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">903</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'21-25'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">904</span><span class="p">:</span> <span class="p">{</span><span class="s1">'age'</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'18-34'</span><span class="p">)}</span> +<span class="gp">... </span> <span class="p">},</span> +<span class="gp">... </span> <span class="n">default</span><span class="o">=</span><span class="s1">'radio_stations'</span> +<span class="gp">... </span><span class="p">)</span> +</pre></div> +</div> +<p>Given that logic can be arbitrarily complicated, mappers can be as +well. You’ll see an example of a mapper that recodes a segmentation +in <strong>Example 4</strong>, below.</p> +</div> +<div class="section" id="append"> +<h3><code class="docutils literal"><span class="pre">append</span></code><a class="headerlink" href="#append" title="Permalink to this headline">¶</a></h3> +<p>If you want the recoded data to be appended to whatever may +already be in the target column (this is only applicable for ‘delimited +set’-typed columns), then you should use the append parameter.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">recoded</span> <span class="o">=</span> <span class="n">recode</span><span class="p">(</span> +<span class="gp">... </span> <span class="n">meta</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">target</span><span class="o">=</span><span class="s1">'radio_stations_xb'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">mapper</span><span class="o">=</span><span class="n">mapper</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">append</span><span class="o">=</span><span class="kc">True</span> +<span class="gp">... </span><span class="p">)</span> +</pre></div> +</div> +<p>The precise behaviour of the append parameter can be seen in the +following examples.</p> +<p>Given the following data:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">df</span><span class="p">[</span><span class="s1">'radio_stations_xb'</span><span class="p">]</span> +<span class="go">1 6;7;9;13;</span> +<span class="go">2 97;</span> +<span class="go">3 97;</span> +<span class="go">4 13;16;18;</span> +<span class="go">5 2;6;</span> +<span class="go">Name: radio_stations_xb, dtype: object</span> +</pre></div> +</div> +<p>We generate a recoded value of 901 if any of the values 1-13 are +found. With the default <code class="docutils literal"><span class="pre">append=False</span></code> behaviour we will return the +following:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">target</span> <span class="o">=</span> <span class="s1">'radio_stations_xb'</span> +<span class="gp">>>> </span><span class="n">recode</span><span class="p">(</span><span class="n">meta</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">target</span><span class="p">,</span> <span class="n">mapper</span><span class="p">)</span> +<span class="go">1 901;</span> +<span class="go">2 97;</span> +<span class="go">3 97;</span> +<span class="go">4 901;</span> +<span class="go">5 901;</span> +<span class="go">Name: radio_stations_xb, dtype: object</span> +</pre></div> +</div> +<p>However, if we instead use <code class="docutils literal"><span class="pre">append=True</span></code>, we will return the following:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">target</span> <span class="o">=</span> <span class="s1">'radio_stations_xb'</span> +<span class="gp">>>> </span><span class="n">recode</span><span class="p">(</span><span class="n">meta</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">target</span><span class="p">,</span> <span class="n">mapper</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +<span class="go">1 6;7;9;13;901;</span> +<span class="go">2 97;</span> +<span class="go">3 97;</span> +<span class="go">4 13;16;18;901;</span> +<span class="go">5 2;6;901;</span> +<span class="go">Name: radio_stations_xb, dtype: object</span> +</pre></div> +</div> +</div> +<div class="section" id="intersect"> +<h3><code class="docutils literal"><span class="pre">intersect</span></code><a class="headerlink" href="#intersect" title="Permalink to this headline">¶</a></h3> +<p>One way to help simplify complex logical conditions, especially when +they are in some way repetitive, is to use <code class="docutils literal"><span class="pre">intersect</span></code>, which +accepts any logical statement and forces every condition in the mapper +to become the intersection of both it and the intersect condition.</p> +<p>For example, we could limit our recode to males by giving a logical +condition to that effect to <code class="docutils literal"><span class="pre">intersect</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">recoded</span> <span class="o">=</span> <span class="n">recode</span><span class="p">(</span> +<span class="gp">... </span> <span class="n">meta</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">target</span><span class="o">=</span><span class="s1">'radio_stations_xb'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">mapper</span><span class="o">=</span><span class="p">{</span> +<span class="gp">... </span> <span class="mi">901</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'1-13'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">902</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'14-20'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">903</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'21-25'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">904</span><span class="p">:</span> <span class="p">{</span><span class="s1">'age'</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'18-34'</span><span class="p">)}</span> +<span class="gp">... </span> <span class="p">},</span> +<span class="gp">... </span> <span class="n">default</span><span class="o">=</span><span class="s1">'radio_stations'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">intersect</span><span class="o">=</span><span class="p">{</span><span class="s1">'gender'</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">]}</span> +<span class="gp">... </span><span class="p">)</span> +</pre></div> +</div> +</div> +<div class="section" id="initialize"> +<h3><code class="docutils literal"><span class="pre">initialize</span></code><a class="headerlink" href="#initialize" title="Permalink to this headline">¶</a></h3> +<p>You may also <code class="docutils literal"><span class="pre">initialize</span></code> your copy of the target column as part of your +recode operation. You can <code class="docutils literal"><span class="pre">initalize</span></code> with either np.NaN (to overwrite +anything that may already be there when your recode begins) or by naming +another column. When you name another column a copy of the data from that +column is used to initialize your recode.</p> +<p>Initialization occurs <strong>before</strong> your recode.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">recoded</span> <span class="o">=</span> <span class="n">recode</span><span class="p">(</span> +<span class="gp">... </span> <span class="n">meta</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">target</span><span class="o">=</span><span class="s1">'radio_stations_xb'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">mapper</span><span class="o">=</span><span class="p">{</span> +<span class="gp">... </span> <span class="mi">901</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'1-13'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">902</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'14-20'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">903</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'21-25'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">904</span><span class="p">:</span> <span class="p">{</span><span class="s1">'age'</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'18-34'</span><span class="p">)}</span> +<span class="gp">... </span> <span class="p">},</span> +<span class="gp">... </span> <span class="n">default</span><span class="o">=</span><span class="s1">'radio_stations'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">initialize</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">NaN</span> +<span class="gp">... </span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">recoded</span> <span class="o">=</span> <span class="n">recode</span><span class="p">(</span> +<span class="gp">... </span> <span class="n">meta</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">target</span><span class="o">=</span><span class="s1">'radio_stations_xb'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">mapper</span><span class="o">=</span><span class="p">{</span> +<span class="gp">... </span> <span class="mi">901</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'1-13'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">902</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'14-20'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">903</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'21-25'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">904</span><span class="p">:</span> <span class="p">{</span><span class="s1">'age'</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'18-34'</span><span class="p">)}</span> +<span class="gp">... </span> <span class="p">},</span> +<span class="gp">... </span> <span class="n">default</span><span class="o">=</span><span class="s1">'radio_stations'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">initialize</span><span class="o">=</span><span class="s1">'radio_stations'</span> +<span class="gp">... </span><span class="p">)</span> +</pre></div> +</div> +</div> +<div class="section" id="fillna"> +<h3><code class="docutils literal"><span class="pre">fillna</span></code><a class="headerlink" href="#fillna" title="Permalink to this headline">¶</a></h3> +<p>You may also provide a <code class="docutils literal"><span class="pre">fillna</span></code> value that will be used as per +<code class="docutils literal"><span class="pre">pd.Series.fillna()</span></code> <strong>after</strong> the recode has been performed.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">recoded</span> <span class="o">=</span> <span class="n">recode</span><span class="p">(</span> +<span class="gp">... </span> <span class="n">meta</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">target</span><span class="o">=</span><span class="s1">'radio_stations_xb'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">mapper</span><span class="o">=</span><span class="p">{</span> +<span class="gp">... </span> <span class="mi">901</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'1-13'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">902</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'14-20'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">903</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'21-25'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">904</span><span class="p">:</span> <span class="p">{</span><span class="s1">'age'</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'18-34'</span><span class="p">)}</span> +<span class="gp">... </span> <span class="p">},</span> +<span class="gp">... </span> <span class="n">default</span><span class="o">=</span><span class="s1">'radio_stations'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">initialize</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">NaN</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">fillna</span><span class="o">=</span><span class="mi">99</span> +<span class="gp">... </span><span class="p">)</span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="custom-recode-examples"> +<h2>Custom recode examples<a class="headerlink" href="#custom-recode-examples" title="Permalink to this headline">¶</a></h2> +<div class="section" id="building-a-net-code"> +<h3>Building a net code<a class="headerlink" href="#building-a-net-code" title="Permalink to this headline">¶</a></h3> +<p>Here’s an example of copying an existing question and recoding onto it a +net code.</p> +<p>Create the new metadata:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">meta</span><span class="p">[</span><span class="s1">'columns'</span><span class="p">][</span><span class="s1">'radio_stations_xb'</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span> +<span class="gp">... </span> <span class="n">meta</span><span class="p">[</span><span class="s1">'columns'</span><span class="p">][</span><span class="s1">'radio_stations'</span><span class="p">]</span> +<span class="gp">... </span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">meta</span><span class="p">[</span><span class="s1">'columns'</span><span class="p">][</span><span class="s1">'radio_stations_xb'</span><span class="p">][</span><span class="s1">'values'</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +<span class="gp">... </span> <span class="p">{</span> +<span class="gp">... </span> <span class="s2">"value"</span><span class="p">:</span> <span class="mi">901</span><span class="p">,</span> +<span class="gp">... </span> <span class="s2">"text"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"en-GB"</span><span class="p">:</span> <span class="s2">"NET: Listened to radio in past 30 days"</span><span class="p">}</span> +<span class="gp">... </span> <span class="p">}</span> +<span class="gp">... </span><span class="p">)</span> +</pre></div> +</div> +<p>Initialize the new column. In this case we’re starting with a copy of +the <code class="docutils literal"><span class="pre">radio_stations</span></code> column:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span><span class="p">[</span><span class="s1">'radio_stations_xb'</span><span class="p">]</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="s1">'radio_stations'</span><span class="p">]</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</pre></div> +</div> +<p>Recode the new column by appending the code 901 to it as indicated +by the mapper:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span><span class="p">[</span><span class="s1">'radio_stations_xb'</span><span class="p">]</span> <span class="o">=</span> <span class="n">recode</span><span class="p">(</span> +<span class="gp">... </span> <span class="n">meta</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">target</span><span class="o">=</span><span class="s1">'radio_stations_xb'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">mapper</span><span class="o">=</span><span class="p">{</span> +<span class="gp">... </span> <span class="mi">901</span><span class="p">:</span> <span class="p">{</span><span class="s1">'radio_stations'</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'1-23, 92, 94, 141'</span><span class="p">)}</span> +<span class="gp">... </span> <span class="p">},</span> +<span class="gp">... </span> <span class="n">append</span><span class="o">=</span><span class="kc">True</span> +<span class="gp">... </span><span class="p">)</span> +</pre></div> +</div> +<p>Check the result:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span><span class="p">[[</span><span class="s1">'radio_stations'</span><span class="p">,</span> <span class="s1">'radio_stations_xb'</span><span class="p">]]</span><span class="o">.</span><span class="n">head</span><span class="p">(</span><span class="mi">20</span><span class="p">)</span> +<span class="go"> radio_stations radio_stations_cb</span> +<span class="go">0 5; 5;901;</span> +<span class="go">1 97; 97;</span> +<span class="go">2 97; 97;</span> +<span class="go">3 97; 97;</span> +<span class="go">4 97; 97;</span> +<span class="go">5 4; 4;901;</span> +<span class="go">6 11; 11;901;</span> +<span class="go">7 4; 4;901;</span> +<span class="go">8 97; 97;</span> +<span class="go">9 97; 97;</span> +<span class="go">10 97; 97;</span> +<span class="go">11 92; 92;901;</span> +<span class="go">12 97; 97;</span> +<span class="go">13 1;13;17; 1;13;17;901;</span> +<span class="go">14 6; 6;901;</span> +<span class="go">15 1;5;6;10; 1;5;6;10;901;</span> +<span class="go">16 6; 6;901;</span> +<span class="go">17 2;4;16; 2;4;16;901;</span> +<span class="go">18 6;10; 6;10;901;</span> +<span class="go">19 6; 6;901;</span> +</pre></div> +</div> +</div> +<div class="section" id="create-and-fill"> +<h3>Create-and-fill<a class="headerlink" href="#create-and-fill" title="Permalink to this headline">¶</a></h3> +<p>Here’s an example where the value 1 is generated based on some logic +and then all remaining cases are given the value 2 using the +pandas.Series.fillna() method.</p> +<p>Create the new metadata</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">meta</span><span class="p">[</span><span class="s1">'columns'</span><span class="p">][</span><span class="s1">'age_xb'</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> +<span class="gp">... </span> <span class="s1">'type'</span><span class="p">:</span> <span class="s1">'single'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="s1">'Age'</span><span class="p">},</span> +<span class="gp">... </span> <span class="s1">'values'</span><span class="p">:</span> <span class="p">[</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'value'</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="s1">'16-25'</span><span class="p">}},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'value'</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="s1">'Others'</span><span class="p">}}</span> +<span class="gp">... </span> <span class="p">]</span> +<span class="gp">... </span> <span class="p">}</span> +</pre></div> +</div> +<p>Initialize the new column:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span><span class="p">[</span><span class="s1">'age_xb'</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">NaN</span> +</pre></div> +</div> +<p>Recode the new column:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span><span class="p">[</span><span class="s1">'age_xb'</span><span class="p">]</span> <span class="o">=</span> <span class="n">recode</span><span class="p">(</span> +<span class="gp">... </span> <span class="n">meta</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">target</span><span class="o">=</span><span class="s1">'age_xb'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">mapper</span><span class="o">=</span><span class="p">{</span> +<span class="gp">... </span> <span class="mi">1</span><span class="p">:</span> <span class="p">{</span><span class="s1">'age'</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'16-40'</span><span class="p">)}</span> +<span class="gp">... </span> <span class="p">}</span> +<span class="gp">... </span><span class="p">)</span> +</pre></div> +</div> +<p>Fill all cases that are still empty with the value 2:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span><span class="p">[</span><span class="s1">'age_xb'</span><span class="p">]</span><span class="o">.</span><span class="n">fillna</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="n">inplace</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</pre></div> +</div> +<p>Check the result:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span><span class="p">[[</span><span class="s1">'age'</span><span class="p">,</span> <span class="s1">'age_xb'</span><span class="p">]]</span><span class="o">.</span><span class="n">head</span><span class="p">(</span><span class="mi">20</span><span class="p">)</span> +<span class="go"> age age_grp_rc</span> +<span class="go">0 22 1</span> +<span class="go">1 68 2</span> +<span class="go">2 32 1</span> +<span class="go">3 44 2</span> +<span class="go">4 33 1</span> +<span class="go">5 52 2</span> +<span class="go">6 54 2</span> +<span class="go">7 44 2</span> +<span class="go">8 62 2</span> +<span class="go">9 49 2</span> +<span class="go">10 64 2</span> +<span class="go">11 73 2</span> +<span class="go">12 43 2</span> +<span class="go">13 28 1</span> +<span class="go">14 66 2</span> +<span class="go">15 39 1</span> +<span class="go">16 51 2</span> +<span class="go">17 50 2</span> +<span class="go">18 77 2</span> +<span class="go">19 42 2</span> +</pre></div> +</div> +</div> +<div class="section" id="numerical-banding"> +<h3>Numerical banding<a class="headerlink" href="#numerical-banding" title="Permalink to this headline">¶</a></h3> +<p>Here’s a typical example of recoding age into custom bands.</p> +<p>In this case we’re using list comprehension to generate the first ten +values objects and then concatenate that with a final ‘65+’ value object +which doesn’t folow the same label format.</p> +<p>Create the new metadata:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">meta</span><span class="p">[</span><span class="s1">'columns'</span><span class="p">][</span><span class="s1">'age_xb_1'</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> +<span class="gp">... </span> <span class="s1">'type'</span><span class="p">:</span> <span class="s1">'single'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="s1">'Age'</span><span class="p">},</span> +<span class="gp">... </span> <span class="s1">'values'</span><span class="p">:</span> <span class="p">[</span> +<span class="gp">... </span> <span class="p">{</span> +<span class="gp">... </span> <span class="s1">'value'</span><span class="p">:</span> <span class="n">i</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="s1">'</span><span class="si">{}</span><span class="s1">-</span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">r</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">r</span><span class="p">[</span><span class="mi">1</span><span class="p">])}</span> +<span class="gp">... </span> <span class="p">}</span> +<span class="gp">... </span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">r</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span> +<span class="gp">... </span> <span class="p">[</span> +<span class="gp">... </span> <span class="p">[</span><span class="mi">18</span><span class="p">,</span> <span class="mi">20</span><span class="p">],</span> +<span class="gp">... </span> <span class="p">[</span><span class="mi">21</span><span class="p">,</span> <span class="mi">25</span><span class="p">],</span> <span class="p">[</span><span class="mi">26</span><span class="p">,</span> <span class="mi">30</span><span class="p">],</span> +<span class="gp">... </span> <span class="p">[</span><span class="mi">31</span><span class="p">,</span> <span class="mi">35</span><span class="p">],</span> <span class="p">[</span><span class="mi">36</span><span class="p">,</span> <span class="mi">40</span><span class="p">],</span> +<span class="gp">... </span> <span class="p">[</span><span class="mi">41</span><span class="p">,</span> <span class="mi">45</span><span class="p">],</span> <span class="p">[</span><span class="mi">46</span><span class="p">,</span> <span class="mi">50</span><span class="p">],</span> +<span class="gp">... </span> <span class="p">[</span><span class="mi">51</span><span class="p">,</span> <span class="mi">55</span><span class="p">],</span> <span class="p">[</span><span class="mi">56</span><span class="p">,</span> <span class="mi">60</span><span class="p">],</span> +<span class="gp">... </span> <span class="p">[</span><span class="mi">61</span><span class="p">,</span> <span class="mi">65</span><span class="p">]</span> +<span class="gp">... </span> <span class="p">],</span> +<span class="gp">... </span> <span class="n">start</span><span class="o">=</span><span class="mi">1</span> +<span class="gp">... </span> <span class="p">)</span> +<span class="gp">... </span> <span class="p">]</span> <span class="o">+</span> <span class="p">[</span> +<span class="gp">... </span> <span class="p">{</span> +<span class="gp">... </span> <span class="s1">'value'</span><span class="p">:</span> <span class="mi">11</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="s1">'65+'</span><span class="p">}</span> +<span class="gp">... </span> <span class="p">}</span> +<span class="gp">... </span> <span class="p">]</span> +<span class="gp">... </span><span class="p">}</span> +</pre></div> +</div> +<p>Initialize the new column:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span><span class="p">[</span><span class="s1">'age_xb_1'</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">NaN</span> +</pre></div> +</div> +<p>Recode the new column:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span><span class="p">[</span><span class="s1">'age_xb_1'</span><span class="p">]</span> <span class="o">=</span> <span class="n">recode</span><span class="p">(</span> +<span class="gp">... </span> <span class="n">meta</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">target</span><span class="o">=</span><span class="s1">'age_xb_1'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">mapper</span><span class="o">=</span><span class="p">{</span> +<span class="gp">... </span> <span class="mi">1</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'18-20'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">2</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'21-25'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">3</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'26-30'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">4</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'31-35'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">5</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'36-40'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">6</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'41-45'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">7</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'46-50'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">8</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'51-55'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">9</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'56-60'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">10</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'61-65'</span><span class="p">),</span> +<span class="gp">... </span> <span class="mi">11</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'66-99'</span><span class="p">)</span> +<span class="gp">... </span> <span class="p">},</span> +<span class="gp">... </span> <span class="n">default</span><span class="o">=</span><span class="s1">'age'</span> +<span class="gp">... </span><span class="p">)</span> +</pre></div> +</div> +<p>Check the result:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span><span class="p">[[</span><span class="s1">'age'</span><span class="p">,</span> <span class="s1">'age_xb_1'</span><span class="p">]]</span><span class="o">.</span><span class="n">head</span><span class="p">(</span><span class="mi">20</span><span class="p">)</span> +<span class="go"> age age_cb</span> +<span class="go">0 22 2</span> +<span class="go">1 68 11</span> +<span class="go">2 32 4</span> +<span class="go">3 44 6</span> +<span class="go">4 33 4</span> +<span class="go">5 52 8</span> +<span class="go">6 54 8</span> +<span class="go">7 44 6</span> +<span class="go">8 62 10</span> +<span class="go">9 49 7</span> +<span class="go">10 64 10</span> +<span class="go">11 73 11</span> +<span class="go">12 43 6</span> +<span class="go">13 28 3</span> +<span class="go">14 66 11</span> +<span class="go">15 39 5</span> +<span class="go">16 51 8</span> +<span class="go">17 50 7</span> +<span class="go">18 77 11</span> +<span class="go">19 42 6</span> +</pre></div> +</div> +</div> +<div class="section" id="complicated-segmentation"> +<h3>Complicated segmentation<a class="headerlink" href="#complicated-segmentation" title="Permalink to this headline">¶</a></h3> +<p>Here’s an example of using a complicated, nested series of logic +statements to recode an obscure segmentation.</p> +<p>The segemenation was given with the following definition:</p> +<p><strong>1 - Self-directed:</strong></p> +<ul class="simple"> +<li>If q1_1 in [1,2] and q1_2 in [1,2] and q1_3 in [3,4,5]</li> +</ul> +<p><strong>2 - Validators:</strong></p> +<ul class="simple"> +<li>If q1_1 in [1,2] and q1_2 in [1,2] and q1_3 in [1,2]</li> +</ul> +<p><strong>3 - Delegators:</strong></p> +<ul class="simple"> +<li>If (q1_1 in [3,4,5] and q1_2 in [3,4,5] and q1_3 in [1,2])</li> +<li>Or (q1_1 in [3,4,5] and q1_2 in [1,2] and q1_3 in [1,2])</li> +<li>Or (q1_1 in [1,2] and q1_2 in [3,4,5] and q1_3 in [1,2])</li> +</ul> +<p><strong>4 - Avoiders:</strong></p> +<ul class="simple"> +<li>If (q1_1 in [3,4,5] and q1_2 in [3,4,5] and q1_3 in [3,4,5])</li> +<li>Or (q1_1 in [3,4,5] and q1_2 in [1,2] and q1_3 in [3,4,5])</li> +<li>Or (q1_1 in [1,2] and q1_2 in [3,4,5] and q1_3 in [3,4,5])</li> +</ul> +<p><strong>5 - Others:</strong></p> +<ul class="simple"> +<li>Everyone else.</li> +</ul> +<p>Create the new metadata:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">meta</span><span class="p">[</span><span class="s1">'columns'</span><span class="p">][</span><span class="s1">'segments'</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> +<span class="gp">... </span> <span class="s1">'type'</span><span class="p">:</span> <span class="s1">'single'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="s1">'Segments'</span><span class="p">},</span> +<span class="gp">... </span> <span class="s1">'values'</span><span class="p">:</span> <span class="p">[</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'value'</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="s1">'Self-directed'</span><span class="p">}},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'value'</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="s1">'Validators'</span><span class="p">}},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'value'</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span> <span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="s1">'Delegators'</span><span class="p">}},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'value'</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span> <span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="s1">'Avoiders'</span><span class="p">}},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'value'</span><span class="p">:</span> <span class="mi">5</span><span class="p">,</span> <span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="s1">'Other'</span><span class="p">}},</span> +<span class="gp">... </span> <span class="p">]</span> +<span class="gp">... </span><span class="p">}</span> +</pre></div> +</div> +<p>Initialize the new column?</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span><span class="p">[</span><span class="s1">'segments'</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">NaN</span> +</pre></div> +</div> +<p>Create the mapper separately, since it’s pretty massive!</p> +<p>See the <strong>Complex logic</strong> section for more information and examples +related to the use of <code class="docutils literal"><span class="pre">union</span></code> and <code class="docutils literal"><span class="pre">intersection</span></code>.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">mapper</span> <span class="o">=</span> <span class="p">{</span> +<span class="gp">... </span> <span class="mi">1</span><span class="p">:</span> <span class="n">intersection</span><span class="p">([</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_2"</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_3"</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">]}</span> +<span class="gp">... </span> <span class="p">]),</span> +<span class="gp">... </span> <span class="mi">2</span><span class="p">:</span> <span class="n">intersection</span><span class="p">([</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_2"</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_3"</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]}</span> +<span class="gp">... </span> <span class="p">]),</span> +<span class="gp">... </span> <span class="mi">3</span><span class="p">:</span> <span class="n">union</span><span class="p">([</span> +<span class="gp">... </span> <span class="n">intersection</span><span class="p">([</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_2"</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_3"</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]}</span> +<span class="gp">... </span> <span class="p">]),</span> +<span class="gp">... </span> <span class="n">intersection</span><span class="p">([</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_2"</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_3"</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]}</span> +<span class="gp">... </span> <span class="p">]),</span> +<span class="gp">... </span> <span class="n">intersection</span><span class="p">([</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_2"</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_3"</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]}</span> +<span class="gp">... </span> <span class="p">]),</span> +<span class="gp">... </span> <span class="p">]),</span> +<span class="gp">... </span> <span class="mi">4</span><span class="p">:</span> <span class="n">union</span><span class="p">([</span> +<span class="gp">... </span> <span class="n">intersection</span><span class="p">([</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_2"</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_3"</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">]}</span> +<span class="gp">... </span> <span class="p">]),</span> +<span class="gp">... </span> <span class="n">intersection</span><span class="p">([</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_2"</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_3"</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">]}</span> +<span class="gp">... </span> <span class="p">]),</span> +<span class="gp">... </span> <span class="n">intersection</span><span class="p">([</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_1"</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_2"</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s2">"q1_3"</span><span class="p">:</span> <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">]}</span> +<span class="gp">... </span> <span class="p">])</span> +<span class="gp">... </span> <span class="p">])</span> +<span class="gp">... </span><span class="p">}</span> +</pre></div> +</div> +<p>Recode the new column:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span><span class="p">[</span><span class="s1">'segments'</span><span class="p">]</span> <span class="o">=</span> <span class="n">recode</span><span class="p">(</span> +<span class="gp">... </span> <span class="n">meta</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">target</span><span class="o">=</span><span class="s1">'segments'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">mapper</span><span class="o">=</span><span class="n">mapper</span> +<span class="gp">... </span><span class="p">)</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">Anything not at the top level of the mapper will not benefit from using +the <code class="docutils literal"><span class="pre">default</span></code> parameter of the recode function. In this case, for example, +saying <code class="docutils literal"><span class="pre">default='q1_1'</span></code> would not have helped. Everything in a nested level +of the mapper, including anything in a <code class="docutils literal"><span class="pre">union</span></code> or <code class="docutils literal"><span class="pre">intersection</span></code> list, +must use the explicit dict form <code class="docutils literal"><span class="pre">{"q1_1":</span> <span class="pre">[1,</span> <span class="pre">2]}</span></code>.</p> +</div> +<p>Fill all cases that are still empty with the value 5:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span><span class="p">[</span><span class="s1">'segments'</span><span class="p">]</span><span class="o">.</span><span class="n">fillna</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="n">inplace</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</pre></div> +</div> +<p>Check the result:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data</span><span class="p">[[</span><span class="s1">'q1_1'</span><span class="p">,</span> <span class="s1">'q1_2'</span><span class="p">,</span> <span class="s1">'q1_3'</span><span class="p">,</span> <span class="s1">'segments'</span><span class="p">]]</span><span class="o">.</span><span class="n">head</span><span class="p">(</span><span class="mi">20</span><span class="p">)</span> +<span class="go"> q1_1 q1_2 q1_3 segments</span> +<span class="go">0 3 3 3 4</span> +<span class="go">1 3 3 3 4</span> +<span class="go">2 1 1 3 1</span> +<span class="go">3 1 1 2 2</span> +<span class="go">4 2 2 2 2</span> +<span class="go">5 1 1 5 1</span> +<span class="go">6 2 3 2 3</span> +<span class="go">7 2 2 3 1</span> +<span class="go">8 1 1 4 1</span> +<span class="go">9 3 3 3 4</span> +<span class="go">10 3 3 4 4</span> +<span class="go">11 2 2 4 1</span> +<span class="go">12 1 1 5 1</span> +<span class="go">13 2 2 4 1</span> +<span class="go">14 1 1 1 2</span> +<span class="go">15 2 2 4 1</span> +<span class="go">16 2 2 3 1</span> +<span class="go">17 1 1 5 1</span> +<span class="go">18 5 5 1 3</span> +<span class="go">19 1 1 4 1</span> +</pre></div> +</div> +</div> +<div class="section" id="variable-creation"> +<h3>Variable creation<a class="headerlink" href="#variable-creation" title="Permalink to this headline">¶</a></h3> +</div> +<div class="section" id="adding-derived-variables"> +<h3>Adding derived variables<a class="headerlink" href="#adding-derived-variables" title="Permalink to this headline">¶</a></h3> +</div> +<div class="section" id="interlocking-variables"> +<h3>Interlocking variables<a class="headerlink" href="#interlocking-variables" title="Permalink to this headline">¶</a></h3> +</div> +<div class="section" id="condition-based-code-removal"> +<h3>Condition-based code removal<a class="headerlink" href="#condition-based-code-removal" title="Permalink to this headline">¶</a></h3> +</div> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="../batch/00_overview.html" class="btn btn-neutral float-right" title="Batch" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="06_logics.html" class="btn btn-neutral" title="Logic and set operaters" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/engine/00_overview.html b/docs/API/_build/html/sites/lib_doc/engine/00_overview.html new file mode 100644 index 000000000..6c520c338 --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/engine/00_overview.html @@ -0,0 +1,449 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Analysis & aggregation — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="next" title="Collecting aggregations" href="01_links_stacks.html"/> + <link rel="prev" title="Inherited qp.DataSet methods" href="../batch/04_subclass.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1 current"><a class="current reference internal" href="#">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li>Analysis & aggregation</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/engine/00_overview.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="section" id="analysis-aggregation"> +<h1>Analysis & aggregation<a class="headerlink" href="#analysis-aggregation" title="Permalink to this headline">¶</a></h1> +<div class="toctree-wrapper compound"> +<ul> +<li class="toctree-l1"><a class="reference internal" href="01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l2"><a class="reference internal" href="01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l2"><a class="reference internal" href="01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="02_quantity.html">The computational engine</a></li> +<li class="toctree-l1"><a class="reference internal" href="03_test.html">Significance testing</a></li> +<li class="toctree-l1"><a class="reference internal" href="04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l2"><a class="reference internal" href="04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l2"><a class="reference internal" href="04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l2"><a class="reference internal" href="04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l2"><a class="reference internal" href="04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="01_links_stacks.html" class="btn btn-neutral float-right" title="Collecting aggregations" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="../batch/04_subclass.html" class="btn btn-neutral" title="Inherited qp.DataSet methods" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/engine/01_links_stacks.html b/docs/API/_build/html/sites/lib_doc/engine/01_links_stacks.html new file mode 100644 index 000000000..fef5dbbc8 --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/engine/01_links_stacks.html @@ -0,0 +1,553 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Collecting aggregations — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="Analysis & aggregation" href="00_overview.html"/> + <link rel="next" title="The computational engine" href="02_quantity.html"/> + <link rel="prev" title="Analysis & aggregation" href="00_overview.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html">Analysis & aggregation</a><ul class="current"> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html">Analysis & aggregation</a> »</li> + + <li>Collecting aggregations</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/engine/01_links_stacks.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="collecting-aggregations"> +<h1>Collecting aggregations<a class="headerlink" href="#collecting-aggregations" title="Permalink to this headline">¶</a></h1> +<p>All computational results are collected in a so-called <code class="docutils literal"><span class="pre">qp.Stack</span></code> object which +acts as a container for large amount of aggregations in form of <code class="docutils literal"><span class="pre">qp.Link</span></code>s.</p> +<div class="section" id="what-is-a-qp-link"> +<h2>What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code><a class="headerlink" href="#what-is-a-qp-link" title="Permalink to this headline">¶</a></h2> +<p>A <code class="docutils literal"><span class="pre">qp.Link</span></code> is defined by four attributes that make it unique and set how it is +stored in a <code class="docutils literal"><span class="pre">qp.Stack</span></code>. These four attributes are <code class="docutils literal"><span class="pre">data_key</span></code>, <code class="docutils literal"><span class="pre">filter</span></code>, +<code class="docutils literal"><span class="pre">x</span></code> (downbreak) and <code class="docutils literal"><span class="pre">y</span></code> (crossbreak), which are positioned in a <code class="docutils literal"><span class="pre">qp.Stack</span></code> +similar to a tree diagram:</p> +<blockquote> +<div><ul class="simple"> +<li>Each <code class="docutils literal"><span class="pre">Stack</span></code> can have various <code class="docutils literal"><span class="pre">data_key</span></code>s.</li> +<li>Each <code class="docutils literal"><span class="pre">data_key</span></code> can have various <code class="docutils literal"><span class="pre">filter</span></code>s.</li> +<li>Each <code class="docutils literal"><span class="pre">filter</span></code> can have various <code class="docutils literal"><span class="pre">x</span></code>s.</li> +<li>Each <code class="docutils literal"><span class="pre">x</span></code> can have various <code class="docutils literal"><span class="pre">y</span></code>s.</li> +</ul> +</div></blockquote> +<p>Consequently <code class="docutils literal"><span class="pre">qp.Stack[dk][filter][x][y]</span></code> is one <code class="docutils literal"><span class="pre">qp.Link</span></code> that can be added +using <code class="docutils literal"><span class="pre">add_link(self,</span> <span class="pre">data_keys=None,</span> <span class="pre">filters=['no_filter'],</span> <span class="pre">x=None,</span> <span class="pre">y=None,</span> <span class="pre">...)</span></code></p> +<p><code class="docutils literal"><span class="pre">qp.Link</span></code>s are are storing different <code class="docutils literal"><span class="pre">qp.View</span></code>s (frequencies, statistics, +etc. - all kinds of computations) that are applied on the same four data attributes.</p> +</div> +<div class="section" id="populating-a-qp-stack"> +<h2>Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code><a class="headerlink" href="#populating-a-qp-stack" title="Permalink to this headline">¶</a></h2> +<p>A <code class="docutils literal"><span class="pre">qp.Stack</span></code> is able to cope with a large amount of aggregations, so it is +impractical to add <code class="docutils literal"><span class="pre">Link</span></code>s one by one with repeated <code class="docutils literal"><span class="pre">Stack.add_link()</span></code> calls. +It is much easier to create a “construction plan” using a <code class="docutils literal"><span class="pre">qp.Batch</span></code> and +apply the settings saved in <code class="docutils literal"><span class="pre">DataSet._meta['sets']['batches']</span></code> to populate a +<code class="docutils literal"><span class="pre">qp.Stack</span></code> instance. In the following, let’s assume <code class="docutils literal"><span class="pre">dataset</span></code> is containing +the definitions of two <code class="docutils literal"><span class="pre">qp.Batch</span></code>es, a <code class="docutils literal"><span class="pre">qp.Stack</span></code> can be created running:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">stack</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">populate</span><span class="p">(</span><span class="n">batches</span><span class="o">=</span><span class="s1">'all'</span><span class="p">)</span> +</pre></div> +</div> +<p>For the <code class="docutils literal"><span class="pre">Batch</span></code> definitions from <a class="reference internal" href="../batch/00_overview.html"><span class="doc">here</span></a>, you +will get the following <em>construction plans</em>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch1</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">get_batch</span><span class="p">(</span><span class="s1">'batch1'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">batch1</span><span class="o">.</span><span class="n">add_y_on_y</span><span class="p">(</span><span class="s1">'y_keys'</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">print</span> <span class="n">batch1</span><span class="o">.</span><span class="n">x_y_map</span> +<span class="go">OrderedDict([('q1', ['@', 'gender', 'q1', 'locality', 'ethnicity']),</span> +<span class="go"> ('q2', ['locality', 'ethnicity']),</span> +<span class="go"> ('q6', ['@']),</span> +<span class="go"> ('@', ['q6']),</span> +<span class="go"> (u'q6_1', ['@', 'gender', 'q1']),</span> +<span class="go"> (u'q6_2', ['@', 'gender', 'q1']),</span> +<span class="go"> (u'q6_3', ['@', 'gender', 'q1'])])</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">print</span> <span class="n">batch1</span><span class="o">.</span><span class="n">x_filter_map</span> +<span class="go">OrderedDict([('q1', {'(men only)+(q1)': (<function _intersection at 0x0000000019AE06D8>, [{'gender': 1}, {'age': [20, 21, 22, 23, 24, 25]}])}),</span> +<span class="go"> ('q2', {'men only': {'gender': 1}}),</span> +<span class="go"> ('q6', {'men only': {'gender': 1}}),</span> +<span class="go"> ('q6_1', {'men only': {'gender': 1}}),</span> +<span class="go"> ('q6_2', {'men only': {'gender': 1}}),</span> +<span class="go"> ('q6_3', {'men only': {'gender': 1}})])</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch2</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">get_batch</span><span class="p">(</span><span class="s1">'batch2'</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">print</span> <span class="n">batch2</span><span class="o">.</span><span class="n">x_y_map</span> +<span class="go">OrderedDict([('q2b', ['@', 'gender'])])</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">print</span> <span class="n">batch2</span><span class="o">.</span><span class="n">x_filter_map</span> +<span class="go">OrderedDict([('q2b', 'no_filter')])</span> +</pre></div> +</div> +<p>As both <code class="docutils literal"><span class="pre">Batch</span></code>es refer to the same data file, the same <code class="docutils literal"><span class="pre">data_key</span></code> (in this +case the name of <code class="docutils literal"><span class="pre">dataset</span></code>) is defining all <code class="docutils literal"><span class="pre">Links</span></code>.</p> +<p>After populating the <code class="docutils literal"><span class="pre">Stack</span></code> content can be viewed using <code class="docutils literal"><span class="pre">.describe()</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">describe</span><span class="p">()</span> +<span class="go"> data filter x y view #</span> +<span class="go">0 Example Data (A) men only q1 q1 NaN 1</span> +<span class="go">1 Example Data (A) men only q1 @ NaN 1</span> +<span class="go">2 Example Data (A) men only q1 gender NaN 1</span> +<span class="go">3 Example Data (A) men only @ q6 NaN 1</span> +<span class="go">4 Example Data (A) men only q2 ethnicity NaN 1</span> +<span class="go">5 Example Data (A) men only q2 locality NaN 1</span> +<span class="go">6 Example Data (A) men only q6_1 q1 NaN 1</span> +<span class="go">7 Example Data (A) men only q6_1 @ NaN 1</span> +<span class="go">8 Example Data (A) men only q6_1 gender NaN 1</span> +<span class="go">9 Example Data (A) men only q6_2 q1 NaN 1</span> +<span class="go">10 Example Data (A) men only q6_2 @ NaN 1</span> +<span class="go">11 Example Data (A) men only q6_2 gender NaN 1</span> +<span class="go">12 Example Data (A) men only q6_3 q1 NaN 1</span> +<span class="go">13 Example Data (A) men only q6_3 @ NaN 1</span> +<span class="go">14 Example Data (A) men only q6_3 gender NaN 1</span> +<span class="go">15 Example Data (A) men only gender q1 NaN 1</span> +<span class="go">16 Example Data (A) men only gender @ NaN 1</span> +<span class="go">17 Example Data (A) men only gender gender NaN 1</span> +<span class="go">18 Example Data (A) men only q6 @ NaN 1</span> +<span class="go">19 Example Data (A) (men only)+(q1) q1 q1 NaN 1</span> +<span class="go">20 Example Data (A) (men only)+(q1) q1 @ NaN 1</span> +<span class="go">21 Example Data (A) (men only)+(q1) q1 locality NaN 1</span> +<span class="go">22 Example Data (A) (men only)+(q1) q1 ethnicity NaN 1</span> +<span class="go">23 Example Data (A) (men only)+(q1) q1 gender NaN 1</span> +<span class="go">24 Example Data (A) no_filter q2b @ NaN 1</span> +<span class="go">25 Example Data (A) no_filter q2b gender NaN 1</span> +</pre></div> +</div> +<p>You can find all combinations defined in the <code class="docutils literal"><span class="pre">x_y_map</span></code> in the +<code class="docutils literal"><span class="pre">Stack</span></code> structure, but also <code class="docutils literal"><span class="pre">Link</span></code>s like <code class="docutils literal"><span class="pre">Stack['Example</span> <span class="pre">Data</span> <span class="pre">(A)']['men</span> <span class="pre">only']['gender']['gender']</span></code> +are included. These special cases arising from the <code class="docutils literal"><span class="pre">y_on_y</span></code> setting. Sometimes +it is helpful to group a <code class="docutils literal"><span class="pre">describe</span></code>-dataframe and create a cross-tabulation +of the four <code class="docutils literal"><span class="pre">Link</span></code> attributes to get a better overview, e.g. to see how many +<code class="docutils literal"><span class="pre">Links</span></code> are included for each x-filter combination. +:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">describe</span><span class="p">(</span><span class="s1">'x'</span><span class="p">,</span> <span class="s1">'filter'</span><span class="p">)</span> +<span class="go">filter (men only)+(q1) men only no_filter</span> +<span class="go">x</span> +<span class="go">@ NaN 1.0 NaN</span> +<span class="go">gender NaN 3.0 NaN</span> +<span class="go">q1 5.0 3.0 NaN</span> +<span class="go">q2 NaN 2.0 NaN</span> +<span class="go">q2b NaN NaN 2.0</span> +<span class="go">q6 NaN 1.0 NaN</span> +<span class="go">q6_1 NaN 3.0 NaN</span> +<span class="go">q6_2 NaN 3.0 NaN</span> +<span class="go">q6_3 NaN 3.0 NaN</span> +</pre></div> +</div> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="02_quantity.html" class="btn btn-neutral float-right" title="The computational engine" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="00_overview.html" class="btn btn-neutral" title="Analysis & aggregation" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/engine/02_quantity.html b/docs/API/_build/html/sites/lib_doc/engine/02_quantity.html new file mode 100644 index 000000000..38764cd4d --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/engine/02_quantity.html @@ -0,0 +1,430 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>The computational engine — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="Analysis & aggregation" href="00_overview.html"/> + <link rel="next" title="Significance testing" href="03_test.html"/> + <link rel="prev" title="Collecting aggregations" href="01_links_stacks.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html">Analysis & aggregation</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html">Analysis & aggregation</a> »</li> + + <li>The computational engine</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/engine/02_quantity.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="the-computational-engine"> +<h1>The computational engine<a class="headerlink" href="#the-computational-engine" title="Permalink to this headline">¶</a></h1> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="03_test.html" class="btn btn-neutral float-right" title="Significance testing" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="01_links_stacks.html" class="btn btn-neutral" title="Collecting aggregations" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/engine/03_test.html b/docs/API/_build/html/sites/lib_doc/engine/03_test.html new file mode 100644 index 000000000..796d44d54 --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/engine/03_test.html @@ -0,0 +1,430 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Significance testing — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="Analysis & aggregation" href="00_overview.html"/> + <link rel="next" title="View aggregation" href="04_agg_methods.html"/> + <link rel="prev" title="The computational engine" href="02_quantity.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html">Analysis & aggregation</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02_quantity.html">The computational engine</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html">Analysis & aggregation</a> »</li> + + <li>Significance testing</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/engine/03_test.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="significance-testing"> +<h1>Significance testing<a class="headerlink" href="#significance-testing" title="Permalink to this headline">¶</a></h1> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="04_agg_methods.html" class="btn btn-neutral float-right" title="View aggregation" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="02_quantity.html" class="btn btn-neutral" title="The computational engine" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/engine/04_agg_methods.html b/docs/API/_build/html/sites/lib_doc/engine/04_agg_methods.html new file mode 100644 index 000000000..f5acf37d1 --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/engine/04_agg_methods.html @@ -0,0 +1,915 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>View aggregation — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="Analysis & aggregation" href="00_overview.html"/> + <link rel="next" title="Builds" href="../builds/00_overview.html"/> + <link rel="prev" title="Significance testing" href="03_test.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html">Analysis & aggregation</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="03_test.html">Significance testing</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html">Analysis & aggregation</a> »</li> + + <li>View aggregation</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/lib_doc/engine/04_agg_methods.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="view-aggregation"> +<h1>View aggregation<a class="headerlink" href="#view-aggregation" title="Permalink to this headline">¶</a></h1> +<p>All following examples are working with a <code class="docutils literal"><span class="pre">qp.Stack</span></code> that was populated +from a <code class="docutils literal"><span class="pre">qp.DataSet</span></code> including the following <code class="docutils literal"><span class="pre">qp.Batch</span></code> definitions:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch1</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">get_batch</span><span class="p">(</span><span class="s1">'batch1'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">batch1</span><span class="o">.</span><span class="n">add_y_on_y</span><span class="p">(</span><span class="s1">'y_keys'</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">print</span> <span class="n">batch1</span><span class="o">.</span><span class="n">x_y_map</span> +<span class="go">OrderedDict([('q1', ['@', 'gender', 'q1', 'locality', 'ethnicity']),</span> +<span class="go"> ('q2', ['locality', 'ethnicity']),</span> +<span class="go"> ('q6', ['@']),</span> +<span class="go"> ('@', ['q6']),</span> +<span class="go"> (u'q6_1', ['@', 'gender', 'q1']),</span> +<span class="go"> (u'q6_2', ['@', 'gender', 'q1']),</span> +<span class="go"> (u'q6_3', ['@', 'gender', 'q1'])])</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">print</span> <span class="n">batch1</span><span class="o">.</span><span class="n">x_filter_map</span> +<span class="go">OrderedDict([('q1', {'(men only)+(q1)': (<function _intersection at 0x0000000019AE06D8>, [{'gender': 1}, {'age': [20, 21, 22, 23, 24, 25]}])}),</span> +<span class="go"> ('q2', {'men only': {'gender': 1}}),</span> +<span class="go"> ('q6', {'men only': {'gender': 1}}),</span> +<span class="go"> ('q6_1', {'men only': {'gender': 1}}),</span> +<span class="go"> ('q6_2', {'men only': {'gender': 1}}),</span> +<span class="go"> ('q6_3', {'men only': {'gender': 1}})])</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">print</span> <span class="n">batch1</span><span class="o">.</span><span class="n">weights</span> +<span class="go">['weight_a']</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch2</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">get_batch</span><span class="p">(</span><span class="s1">'batch2'</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">print</span> <span class="n">batch2</span><span class="o">.</span><span class="n">x_y_map</span> +<span class="go">OrderedDict([('q2b', ['@', 'gender'])])</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">print</span> <span class="n">batch2</span><span class="o">.</span><span class="n">x_filter_map</span> +<span class="go">OrderedDict([('q2b', 'no_filter')])</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">print</span> <span class="n">batch2</span><span class="o">.</span><span class="n">weights</span> +<span class="go">['weight']</span> +</pre></div> +</div> +<div class="section" id="basic-views"> +<h2>Basic views<a class="headerlink" href="#basic-views" title="Permalink to this headline">¶</a></h2> +<p>It is possible to add various <code class="docutils literal"><span class="pre">qp.View</span></code>s to a <code class="docutils literal"><span class="pre">Link</span></code>. This can be performed +by running <code class="docutils literal"><span class="pre">Stack.add_link()</span></code> providing <code class="docutils literal"><span class="pre">View</span></code> objects via the <code class="docutils literal"><span class="pre">view</span></code> parameter. +Alternatively, the <code class="docutils literal"><span class="pre">qp.Batch</span></code> definitions that are stored in the meta data +help to add basic <code class="docutils literal"><span class="pre">View</span></code>s (counts, percentages, bases and sums). By simply +running <code class="docutils literal"><span class="pre">Stack.aggregate()</span></code> we can easily add a large amount of aggregations +in one step.</p> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last"><code class="docutils literal"><span class="pre">Stack.aggregate()</span></code> can only be used with pre-populated <code class="docutils literal"><span class="pre">Stack</span></code>s! +(see <a class="reference internal" href="01_links_stacks.html"><span class="doc">DataSet.populate()</span></a>).</p> +</div> +<p>For instance, we can add column percentages and (unweighted and weighted) base sizes +to all <code class="docutils literal"><span class="pre">Link</span></code>s of <code class="docutils literal"><span class="pre">batch2</span></code> like this:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">aggregate</span><span class="p">(</span><span class="n">views</span><span class="o">=</span><span class="p">[</span><span class="s1">'c%'</span><span class="p">,</span> <span class="s1">'cbase'</span><span class="p">],</span> <span class="n">unweighted_base</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">batches</span><span class="o">=</span><span class="s1">'batch2'</span><span class="p">,</span> <span class="n">verbose</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">describe</span><span class="p">()</span> +<span class="go"> data filter x y view #</span> +<span class="go">0 Example Data (A) men only q1 q1 NaN 1</span> +<span class="go">1 Example Data (A) men only q1 @ NaN 1</span> +<span class="go">2 Example Data (A) men only q1 gender NaN 1</span> +<span class="go">3 Example Data (A) men only @ q6 NaN 1</span> +<span class="go">4 Example Data (A) men only q2 ethnicity NaN 1</span> +<span class="go">5 Example Data (A) men only q2 locality NaN 1</span> +<span class="go">6 Example Data (A) men only q6_1 q1 NaN 1</span> +<span class="go">7 Example Data (A) men only q6_1 @ NaN 1</span> +<span class="go">8 Example Data (A) men only q6_1 gender NaN 1</span> +<span class="go">9 Example Data (A) men only q6_2 q1 NaN 1</span> +<span class="go">10 Example Data (A) men only q6_2 @ NaN 1</span> +<span class="go">11 Example Data (A) men only q6_2 gender NaN 1</span> +<span class="go">12 Example Data (A) men only q6_3 q1 NaN 1</span> +<span class="go">13 Example Data (A) men only q6_3 @ NaN 1</span> +<span class="go">14 Example Data (A) men only q6_3 gender NaN 1</span> +<span class="go">15 Example Data (A) men only gender q1 NaN 1</span> +<span class="go">16 Example Data (A) men only gender @ NaN 1</span> +<span class="go">17 Example Data (A) men only gender gender NaN 1</span> +<span class="go">18 Example Data (A) men only q6 @ NaN 1</span> +<span class="go">19 Example Data (A) (men only)+(q1) q1 q1 NaN 1</span> +<span class="go">20 Example Data (A) (men only)+(q1) q1 @ NaN 1</span> +<span class="go">21 Example Data (A) (men only)+(q1) q1 locality NaN 1</span> +<span class="go">22 Example Data (A) (men only)+(q1) q1 ethnicity NaN 1</span> +<span class="go">23 Example Data (A) (men only)+(q1) q1 gender NaN 1</span> +<span class="go">24 Example Data (A) no_filter q2b @ x|f|:|y|weight|c% 1</span> +<span class="go">25 Example Data (A) no_filter q2b @ x|f|x:||weight|cbase 1</span> +<span class="go">26 Example Data (A) no_filter q2b @ x|f|x:|||cbase 1</span> +<span class="go">27 Example Data (A) no_filter q2b gender x|f|:|y|weight|c% 1</span> +<span class="go">28 Example Data (A) no_filter q2b gender x|f|x:||weight|cbase 1</span> +<span class="go">29 Example Data (A) no_filter q2b gender x|f|x:|||cbase 1</span> +</pre></div> +</div> +<p>Obviously <code class="docutils literal"><span class="pre">View</span></code>s are only added to <code class="docutils literal"><span class="pre">Link</span></code>s defined by <code class="docutils literal"><span class="pre">batch2</span></code> and +automatically weighted according to the weight definition of <code class="docutils literal"><span class="pre">batch2</span></code>, +which is evident from the view keys (<code class="docutils literal"><span class="pre">x|f|:|y|weight|c%</span></code>). Combining the information +of the four <code class="docutils literal"><span class="pre">Link</span></code> attributes with a view key, leads to a <code class="docutils literal"><span class="pre">pd.DataFrame</span></code> +and its belonging meta information:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">link</span> <span class="o">=</span> <span class="n">stack</span><span class="p">[</span><span class="s1">'Example Data (A)'</span><span class="p">][</span><span class="s1">'no_filter'</span><span class="p">][</span><span class="s1">'q2b'</span><span class="p">][</span><span class="s1">'gender'</span><span class="p">]</span> +<span class="gp">>>> </span><span class="n">view_key</span> <span class="o">=</span> <span class="s1">'x|f|:|y|weight|c%'</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">link</span><span class="p">[</span><span class="n">view_key</span><span class="p">]</span> +<span class="go">Question q2b</span> +<span class="go">Values @</span> +<span class="go">Question Values</span> +<span class="go">q2b 1 11.992144</span> +<span class="go"> 2 80.802580</span> +<span class="go"> 3 7.205276</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">link</span><span class="p">[</span><span class="n">view_key</span><span class="p">]</span><span class="o">.</span><span class="n">meta</span><span class="p">()</span> +<span class="go">{</span> +<span class="go"> "agg": {</span> +<span class="go"> "weights": "weight",</span> +<span class="go"> "name": "c%",</span> +<span class="go"> "grp_text_map": null,</span> +<span class="go"> "text": "",</span> +<span class="go"> "fullname": "x|f|:|y|weight|c%",</span> +<span class="go"> "is_weighted": true,</span> +<span class="go"> "method": "frequency",</span> +<span class="go"> "is_block": false</span> +<span class="go"> },</span> +<span class="go"> "x": {</span> +<span class="go"> "is_array": false,</span> +<span class="go"> "name": "q2b",</span> +<span class="go"> "is_multi": false,</span> +<span class="go"> "is_nested": false</span> +<span class="go"> },</span> +<span class="go"> "shape": [</span> +<span class="go"> 3,</span> +<span class="go"> 1</span> +<span class="go"> ],</span> +<span class="go"> "y": {</span> +<span class="go"> "is_array": false,</span> +<span class="go"> "name": "@",</span> +<span class="go"> "is_multi": false,</span> +<span class="go"> "is_nested": false</span> +<span class="go"> }</span> +<span class="go">}</span> +</pre></div> +</div> +<p>Now we are adding <code class="docutils literal"><span class="pre">View</span></code>s to all <code class="docutils literal"><span class="pre">batch1</span></code>-defined <code class="docutils literal"><span class="pre">Link</span></code>s as well:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">aggregate</span><span class="p">(</span><span class="n">views</span><span class="o">=</span><span class="p">[</span><span class="s1">'c%'</span><span class="p">,</span> <span class="s1">'counts'</span><span class="p">,</span> <span class="s1">'cbase'</span><span class="p">],</span> <span class="n">unweighted_base</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">batches</span><span class="o">=</span><span class="s1">'batch1'</span><span class="p">,</span> <span class="n">verbose</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">describe</span><span class="p">([</span><span class="s1">'x'</span><span class="p">,</span> <span class="s1">'view'</span><span class="p">],</span> <span class="s1">'y'</span><span class="p">)</span><span class="o">.</span><span class="n">loc</span><span class="p">[[</span><span class="s1">'@'</span><span class="p">,</span> <span class="s1">'q6'</span><span class="p">],</span> <span class="p">[</span><span class="s1">'@'</span><span class="p">,</span> <span class="s1">'q6'</span><span class="p">]]</span> +<span class="go">y @ q6</span> +<span class="go">x view</span> +<span class="go">@ x|f|:|y|weight_a|c% NaN 1.0</span> +<span class="go"> x|f|:||weight_a|counts NaN 1.0</span> +<span class="go">q6 x|f|:|y|weight_a|c% 1.0 NaN</span> +<span class="go"> x|f|:||weight_a|counts 1.0 NaN</span> +</pre></div> +</div> +<p>Even if unweighted bases are requested, they get skipped for array summaries +and transposed arrays.</p> +<p>Since <code class="docutils literal"><span class="pre">y_on_y</span></code> is requested, for a variable used as cross- and downbreak, with an extended filter (in this +example <code class="docutils literal"><span class="pre">q1</span></code>), two <code class="docutils literal"><span class="pre">Link</span></code>s with <code class="docutils literal"><span class="pre">View</span></code>s are created:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">describe</span><span class="p">([</span><span class="s1">'y'</span><span class="p">,</span> <span class="s1">'filter'</span><span class="p">,</span> <span class="s1">'view'</span><span class="p">],</span> <span class="s1">'x'</span><span class="p">)</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span><span class="s1">'q1'</span><span class="p">,</span> <span class="s1">'q1'</span><span class="p">]</span> +<span class="go">filter view</span> +<span class="go">(men only)+(q1) x|f|:|y|weight_a|c% 1.0</span> +<span class="go"> x|f|:||weight_a|counts 1.0</span> +<span class="go"> x|f|x:||weight_a|cbase 1.0</span> +<span class="go"> x|f|x:|||cbase 1.0</span> +<span class="go">men only x|f|:|y|weight_a|c% 1.0</span> +<span class="go"> x|f|:||weight_a|counts 1.0</span> +<span class="go"> x|f|x:||weight_a|cbase 1.0</span> +<span class="go"> x|f|x:|||cbase 1.0</span> +</pre></div> +</div> +<p>The first one is the aggregation defined by the <code class="docutils literal"><span class="pre">Batch</span></code> construction plan, +the second one shows the <code class="docutils literal"><span class="pre">y_on_y</span></code> aggregation using only the main +<code class="docutils literal"><span class="pre">Batch.filter</span></code>.</p> +</div> +<div class="section" id="non-categorical-variables"> +<h2>Non-categorical variables<a class="headerlink" href="#non-categorical-variables" title="Permalink to this headline">¶</a></h2> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch3</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">add_batch</span><span class="p">(</span><span class="s1">'batch3'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">batch3</span><span class="o">.</span><span class="n">add_x</span><span class="p">(</span><span class="s1">'age'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">stack</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">populate</span><span class="p">(</span><span class="s1">'batch3'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">describe</span><span class="p">()</span> +<span class="go"> data filter x y view #</span> +<span class="go">0 Example Data (A) no_filter age @ NaN 1</span> +</pre></div> +</div> +<p>Non-categorical variables (<code class="docutils literal"><span class="pre">ìnt</span></code> or <code class="docutils literal"><span class="pre">float</span></code>) are handled in a special way. +There are two options:</p> +<blockquote> +<div><ul> +<li><p class="first">Treat them like categorical variables: +Append them to the parameter <code class="docutils literal"><span class="pre">categorize</span></code>, then counts, percentage +and sum aggregations can be added alongside the <code class="docutils literal"><span class="pre">cbase</span></code> <code class="docutils literal"><span class="pre">View</span></code>.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">aggregate</span><span class="p">(</span><span class="n">views</span><span class="o">=</span><span class="p">[</span><span class="s1">'c%'</span><span class="p">,</span> <span class="s1">'counts'</span><span class="p">,</span> <span class="s1">'cbase'</span><span class="p">,</span> <span class="s1">'counts_sum'</span><span class="p">,</span> <span class="s1">'c%_sum'</span><span class="p">],</span> +<span class="go"> unweighted_base=True,</span> +<span class="go"> categorize=['age'],</span> +<span class="go"> batches='batch3',</span> +<span class="go"> verbose=False)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">describe</span><span class="p">()</span> +<span class="go"> data filter x y view #</span> +<span class="go">0 Example Data (A) no_filter age @ x|f|:|||counts 1</span> +<span class="go">1 Example Data (A) no_filter age @ x|f.c:f|x:|y||c%_sum 1</span> +<span class="go">2 Example Data (A) no_filter age @ x|f|:|y||c% 1</span> +<span class="go">3 Example Data (A) no_filter age @ x|f|x:|||cbase 1</span> +<span class="go">4 Example Data (A) no_filter age @ x|f.c:f|x:|||counts_sum 1</span> +</pre></div> +</div> +</li> +<li><p class="first">Do not categorize the variable: +Only <code class="docutils literal"><span class="pre">cbase</span></code> is created and additional descriptive statistics +<code class="docutils literal"><span class="pre">View</span></code>s must be added. The method will raise a warning:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">aggregate</span><span class="p">(</span><span class="n">views</span><span class="o">=</span><span class="p">[</span><span class="s1">'c%'</span><span class="p">,</span> <span class="s1">'counts'</span><span class="p">,</span> <span class="s1">'cbase'</span><span class="p">,</span> <span class="s1">'counts_sum'</span><span class="p">,</span> <span class="s1">'c%_sum'</span><span class="p">],</span> +<span class="go"> unweighted_base=True,</span> +<span class="go"> batches='batch3',</span> +<span class="go"> verbose=True)</span> +<span class="go">Warning: Found 1 non-categorized numeric variable(s): ['age'].</span> +<span class="go">Descriptive statistics must be added!</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">describe</span><span class="p">()</span> +<span class="go"> data filter x y view #</span> +<span class="go">0 Example Data (A) no_filter age @ x|f|x:|||cbase 1</span> +</pre></div> +</div> +</li> +</ul> +</div></blockquote> +</div> +<div class="section" id="descriptive-statistics"> +<h2>Descriptive statistics<a class="headerlink" href="#descriptive-statistics" title="Permalink to this headline">¶</a></h2> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">b_name</span> <span class="o">=</span> <span class="s1">'batch4'</span> +<span class="gp">>>> </span><span class="n">batch4</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">add_batch</span><span class="p">(</span><span class="n">b_name</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">batch4</span><span class="o">.</span><span class="n">add_x</span><span class="p">([</span><span class="s1">'q2b'</span><span class="p">,</span> <span class="s1">'q6'</span><span class="p">,</span> <span class="s1">'age'</span><span class="p">])</span> +<span class="gp">>>> </span><span class="n">stack</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">populate</span><span class="p">(</span><span class="n">b_name</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">aggregate</span><span class="p">(</span><span class="n">views</span><span class="o">=</span><span class="p">[</span><span class="s1">'counts'</span><span class="p">,</span> <span class="s1">'cbase'</span><span class="p">],</span> <span class="n">batches</span><span class="o">=</span><span class="n">b_name</span><span class="p">,</span> <span class="n">verbose</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">describe</span><span class="p">()</span> +<span class="go"> data filter x y view #</span> +<span class="go">0 Example Data (A) no_filter q2b @ x|f|:|||counts 1</span> +<span class="go">1 Example Data (A) no_filter q2b @ x|f|x:|||cbase 1</span> +<span class="go">2 Example Data (A) no_filter q6_1 @ x|f|:|||counts 1</span> +<span class="go">3 Example Data (A) no_filter q6_1 @ x|f|x:|||cbase 1</span> +<span class="go">4 Example Data (A) no_filter q6_2 @ x|f|:|||counts 1</span> +<span class="go">5 Example Data (A) no_filter q6_2 @ x|f|x:|||cbase 1</span> +<span class="go">6 Example Data (A) no_filter q6_3 @ x|f|:|||counts 1</span> +<span class="go">7 Example Data (A) no_filter q6_3 @ x|f|x:|||cbase 1</span> +<span class="go">8 Example Data (A) no_filter age @ x|f|x:|||cbase 1</span> +<span class="go">9 Example Data (A) no_filter q6 @ x|f|:|||counts 1</span> +<span class="go">10 Example Data (A) no_filter q6 @ x|f|x:|||cbase 1</span> +</pre></div> +</div> +<p>Adding descriptive statistics <code class="docutils literal"><span class="pre">View</span></code>s like mean, stddev, min, max, median, etc. +can be added with the method <code class="docutils literal"><span class="pre">stack.add_stats()</span></code>. With the parameters +<code class="docutils literal"><span class="pre">other_source</span></code>, <code class="docutils literal"><span class="pre">rescale</span></code> and <code class="docutils literal"><span class="pre">exclude</span></code> you can specify the calculation. +Again each combination of the parameters refers to a unique view key. Note that +in <code class="docutils literal"><span class="pre">on_vars</span></code> included arrays get unrolled, that means also all belonging +array items get equipped with the added <code class="docutils literal"><span class="pre">View</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">add_stats</span><span class="p">(</span><span class="n">on_vars</span><span class="o">=</span><span class="p">[</span><span class="s1">'q2b'</span><span class="p">,</span> <span class="s1">'age'</span><span class="p">],</span> <span class="n">stats</span><span class="o">=</span><span class="s1">'mean'</span><span class="p">,</span> <span class="n">_batches</span><span class="o">=</span><span class="n">b_name</span><span class="p">,</span> <span class="n">verbose</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">add_stats</span><span class="p">(</span><span class="n">on_vars</span><span class="o">=</span><span class="p">[</span><span class="s1">'q6'</span><span class="p">],</span> <span class="n">stats</span><span class="o">=</span><span class="s1">'stddev'</span><span class="p">,</span> <span class="n">_batches</span><span class="o">=</span><span class="n">b_name</span><span class="p">,</span> <span class="n">verbose</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">add_stats</span><span class="p">(</span><span class="n">on_vars</span><span class="o">=</span><span class="p">[</span><span class="s1">'q2b'</span><span class="p">],</span> <span class="n">stats</span><span class="o">=</span><span class="s1">'mean'</span><span class="p">,</span> <span class="n">rescale</span><span class="o">=</span><span class="p">{</span><span class="mi">1</span><span class="p">:</span><span class="mi">100</span><span class="p">,</span> <span class="mi">2</span><span class="p">:</span><span class="mi">50</span><span class="p">,</span> <span class="mi">3</span><span class="p">:</span><span class="mi">0</span><span class="p">},</span> +<span class="gp">... </span> <span class="n">custom_text</span><span class="o">=</span><span class="s1">'rescale mean'</span><span class="p">,</span> <span class="n">_batches</span><span class="o">=</span><span class="n">b_name</span><span class="p">,</span> <span class="n">verbose</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">describe</span><span class="p">(</span><span class="s1">'view'</span><span class="p">,</span> <span class="s1">'x'</span><span class="p">)</span> +<span class="go">x age q2b q6 q6_1 q6_2 q6_3</span> +<span class="go">view</span> +<span class="go">x|d.mean|x:|||stat 1.0 1.0 NaN NaN NaN NaN</span> +<span class="go">x|d.mean|x[{100,50,0}]:|||stat NaN 1.0 NaN NaN NaN NaN</span> +<span class="go">x|d.stddev|x:|||stat NaN NaN 1.0 1.0 1.0 1.0</span> +<span class="go">x|f|:|||counts NaN 1.0 1.0 1.0 1.0 1.0</span> +<span class="go">x|f|x:|||cbase 1.0 1.0 1.0 1.0 1.0 1.0</span> +</pre></div> +</div> +</div> +<div class="section" id="nets"> +<h2>Nets<a class="headerlink" href="#nets" title="Permalink to this headline">¶</a></h2> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">b_name</span> <span class="o">=</span> <span class="s1">'batch5'</span> +<span class="gp">>>> </span><span class="n">batch5</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">add_batch</span><span class="p">(</span><span class="n">b_name</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">batch5</span><span class="o">.</span><span class="n">add_x</span><span class="p">([</span><span class="s1">'q2b'</span><span class="p">,</span> <span class="s1">'q6'</span><span class="p">])</span> +<span class="gp">>>> </span><span class="n">stack</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">populate</span><span class="p">(</span><span class="n">b_name</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">aggregate</span><span class="p">(</span><span class="n">views</span><span class="o">=</span><span class="p">[</span><span class="s1">'counts'</span><span class="p">,</span> <span class="s1">'c%'</span><span class="p">,</span> <span class="s1">'cbase'</span><span class="p">],</span> <span class="n">batches</span><span class="o">=</span><span class="n">b_name</span><span class="p">,</span> <span class="n">verbose</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">describe</span><span class="p">(</span><span class="s1">'view'</span><span class="p">,</span> <span class="s1">'x'</span><span class="p">)</span> +<span class="go">x q2b q6 q6_1 q6_2 q6_3</span> +<span class="go">view</span> +<span class="go">x|f|:|y||c% 1 1 1 1 1</span> +<span class="go">x|f|:|||counts 1 1 1 1 1</span> +<span class="go">x|f|x:|||cbase 1 1 1 1 1</span> +</pre></div> +</div> +<p>Net-like <code class="docutils literal"><span class="pre">View</span></code>s can be added with the method <code class="docutils literal"><span class="pre">Stack.add_nets()</span></code> by defining +<code class="docutils literal"><span class="pre">net_map</span></code>s for selected variables. There is a distinction between two different +types of net <code class="docutils literal"><span class="pre">View</span></code>s:</p> +<blockquote> +<div><ul> +<li><p class="first">Expanded nets: +The existing counts or percentage <code class="docutils literal"><span class="pre">View</span></code>s are replaced with the new +net <code class="docutils literal"><span class="pre">View</span></code>s, which will the net-defining codes after or before the +computed net groups (i.e. “overcode” nets).</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">add_nets</span><span class="p">(</span><span class="s1">'q2b'</span><span class="p">,</span> <span class="p">[{</span><span class="s1">'Top2'</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]}],</span> <span class="n">expand</span><span class="o">=</span><span class="s1">'after'</span><span class="p">,</span> <span class="n">_batches</span><span class="o">=</span><span class="n">b_name</span><span class="p">,</span> <span class="n">verbose</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">describe</span><span class="p">(</span><span class="s1">'view'</span><span class="p">,</span> <span class="s1">'x'</span><span class="p">)</span> +<span class="go">x q2b q6 q6_1 q6_2 q6_3</span> +<span class="go">view</span> +<span class="go">x|f|:|y||c% NaN 1.0 1.0 1.0 1.0</span> +<span class="go">x|f|:|||counts NaN 1.0 1.0 1.0 1.0</span> +<span class="go">x|f|x:|||cbase 1.0 1.0 1.0 1.0 1.0</span> +<span class="go">x|f|x[{1,2}+]*:|y||net 1.0 NaN NaN NaN NaN</span> +<span class="go">x|f|x[{1,2}+]*:|||net 1.0 NaN NaN NaN NaN</span> +</pre></div> +</div> +</li> +<li><p class="first">Not expanded nets: +The new net <code class="docutils literal"><span class="pre">View</span></code>s are added to the stack, which contain only the +computed net groups.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">add_nets</span><span class="p">(</span><span class="s1">'q2b'</span><span class="p">,</span> <span class="p">[{</span><span class="s1">'Top2'</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]}],</span> <span class="n">_batches</span><span class="o">=</span><span class="n">b_name</span><span class="p">,</span> <span class="n">verbose</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">describe</span><span class="p">(</span><span class="s1">'view'</span><span class="p">,</span> <span class="s1">'x'</span><span class="p">)</span> +<span class="go">x q2b q6 q6_1 q6_2 q6_3</span> +<span class="go">view</span> +<span class="go">x|f|:|y||c% NaN 1.0 1.0 1.0 1.0</span> +<span class="go">x|f|:|||counts NaN 1.0 1.0 1.0 1.0</span> +<span class="go">x|f|x:|||cbase 1.0 1.0 1.0 1.0 1.0</span> +<span class="go">x|f|x[{1,2}+]*:|y||net 1.0 NaN NaN NaN NaN</span> +<span class="go">x|f|x[{1,2}+]*:|||net 1.0 NaN NaN NaN NaN</span> +<span class="go">x|f|x[{1,2}]:|y||net 1.0 NaN NaN NaN NaN</span> +<span class="go">x|f|x[{1,2}]:|||net 1.0 NaN NaN NaN NaN</span> +</pre></div> +</div> +</li> +</ul> +</div></blockquote> +<p>The difference between the two net types are also visible in the view keys: +<code class="docutils literal"><span class="pre">x|f|x[{1,2}+]*:|||net</span></code> versus <code class="docutils literal"><span class="pre">x|f|x[{1,2}]:|||net</span></code>.</p> +<div class="section" id="net-definitions"> +<h3>Net definitions<a class="headerlink" href="#net-definitions" title="Permalink to this headline">¶</a></h3> +<p>To create more complex net definitions the method <code class="docutils literal"><span class="pre">quantipy.net()</span></code> can be used, +which generates a well-formatted instruction dict and appends it to the <code class="docutils literal"><span class="pre">net_map</span></code>. +It’s a helper especially concerning including various texts with different +valid <code class="docutils literal"><span class="pre">text_keys</span></code>. The next example shows how to prepare a net for ‘q6’ +(promoters, detractors):</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">q6_net</span> <span class="o">=</span> <span class="n">qp</span><span class="o">.</span><span class="n">net</span><span class="p">([],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">],</span> <span class="s1">'Promotors'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'en-GB'</span><span class="p">,</span> <span class="s1">'sv-SE'</span><span class="p">])</span> +<span class="gp">>>> </span><span class="n">q6_net</span> <span class="o">=</span> <span class="n">qp</span><span class="o">.</span><span class="n">net</span><span class="p">(</span><span class="n">q6_net</span><span class="p">,</span> <span class="p">[</span><span class="mi">9</span><span class="p">,</span> <span class="mi">10</span><span class="p">],</span> <span class="p">{</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="s1">'Detractors'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'sv_SE'</span><span class="p">:</span> <span class="s1">'Detractors'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'de-DE'</span><span class="p">:</span> <span class="s1">'Kritiker'</span><span class="p">})</span> +<span class="gp">>>> </span><span class="n">qp</span><span class="o">.</span><span class="n">net</span><span class="p">(</span><span class="n">q6_net</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">text</span><span class="o">=</span><span class="s1">'Promoter'</span><span class="p">,</span> <span class="n">text_key</span><span class="o">=</span><span class="s1">'de-DE'</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">print</span> <span class="n">q6_net</span> +<span class="go">[</span> +<span class="go"> {</span> +<span class="go"> "1": [1, 2, 3, 4, 5, 6],</span> +<span class="go"> "text": {</span> +<span class="go"> "en-GB": "Promotors",</span> +<span class="go"> "sv-SE": "Promotors",</span> +<span class="go"> "de-DE": "Promoter"</span> +<span class="go"> }</span> +<span class="go"> },</span> +<span class="go"> {</span> +<span class="go"> "2": [9, 10],</span> +<span class="go"> "text": {</span> +<span class="go"> "en-GB": "Detractors",</span> +<span class="go"> "sv_SE": "Detractors",</span> +<span class="go"> "de-DE": "Kritiker"</span> +<span class="go"> }</span> +<span class="go"> }</span> +<span class="go">]</span> +</pre></div> +</div> +</div> +<div class="section" id="calculations"> +<h3>Calculations<a class="headerlink" href="#calculations" title="Permalink to this headline">¶</a></h3> +<p><code class="docutils literal"><span class="pre">Stack.add_nets()</span></code> has the parameter <code class="docutils literal"><span class="pre">calc</span></code>, which allows adding <code class="docutils literal"><span class="pre">View</span></code>s +that are calculated out of the defined nets. The method <code class="docutils literal"><span class="pre">qp.calc()</span></code> is a +helper to create a well-formatted instruction dict for the calculation. +For instance, to calculate the NPS (<em>promoters</em> - <em>detractors</em>) for <code class="docutils literal"><span class="pre">'q6'</span></code>, see the example +above and create the following calculation:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">q6_calc</span> <span class="o">=</span> <span class="n">qp</span><span class="o">.</span><span class="n">calc</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="s1">'-'</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="s1">'NPS'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'en-GB'</span><span class="p">,</span> <span class="s1">'sv-SE'</span><span class="p">,</span> <span class="s1">'de-DE'</span><span class="p">])</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">print</span> <span class="n">q6_calc</span> +<span class="go">OrderedDict([('calc', ('net_1', <built-in function sub>, 'net_2')),</span> +<span class="go"> ('calc_only', False),</span> +<span class="go"> ('text', {'en-GB': 'NPS',</span> +<span class="go"> 'sv-SE': 'NPS',</span> +<span class="go"> 'de-DE': 'NPS'})])</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">add_nets</span><span class="p">(</span><span class="s1">'q6'</span><span class="p">,</span> <span class="n">q6_net</span><span class="p">,</span> <span class="n">calc</span><span class="o">=</span><span class="n">q6_calc</span><span class="p">,</span> <span class="n">_batches</span><span class="o">=</span><span class="n">b_name</span><span class="p">,</span> <span class="n">verbose</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">describe</span><span class="p">(</span><span class="s1">'view'</span><span class="p">,</span> <span class="s1">'x'</span><span class="p">)</span> +<span class="go">x q2b q6 q6_1 q6_2 q6_3</span> +<span class="go">view</span> +<span class="go">x|f.c:f|x[{1,2,3,4,5,6}],x[{9,10}],x[{1,2,3,4,5... NaN 1.0 1.0 1.0 1.0</span> +<span class="go">x|f.c:f|x[{1,2,3,4,5,6}],x[{9,10}],x[{1,2,3,4,5... NaN 1.0 1.0 1.0 1.0</span> +<span class="go">x|f|:|y||c% NaN 1.0 1.0 1.0 1.0</span> +<span class="go">x|f|:|||counts NaN 1.0 1.0 1.0 1.0</span> +<span class="go">x|f|x:|||cbase 1.0 1.0 1.0 1.0 1.0</span> +<span class="go">x|f|x[{1,2}+]*:|y||net 1.0 NaN NaN NaN NaN</span> +<span class="go">x|f|x[{1,2}+]*:|||net 1.0 NaN NaN NaN NaN</span> +<span class="go">x|f|x[{1,2}]:|y||net 1.0 NaN NaN NaN NaN</span> +<span class="go">x|f|x[{1,2}]:|||net 1.0 NaN NaN NaN NaN</span> +</pre></div> +</div> +<p>You can see that nets that are added on arrays are also applied for all array items.</p> +</div> +</div> +<div class="section" id="cumulative-sums"> +<h2>Cumulative sums<a class="headerlink" href="#cumulative-sums" title="Permalink to this headline">¶</a></h2> +<p>Cumulative sum <code class="docutils literal"><span class="pre">View</span></code>s can be added to a specified collection of xks of the +<code class="docutils literal"><span class="pre">Stack</span></code> using <code class="docutils literal"><span class="pre">stack.cumulative_sum()</span></code>. These <code class="docutils literal"><span class="pre">View</span></code>s will always +replace the regular counts and percentage <code class="docutils literal"><span class="pre">View</span></code>s:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">b_name</span> <span class="o">=</span> <span class="s1">'batch6'</span> +<span class="gp">>>> </span><span class="n">batch6</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">add_batch</span><span class="p">(</span><span class="n">b_name</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">batch6</span><span class="o">.</span><span class="n">add_x</span><span class="p">([</span><span class="s1">'q2b'</span><span class="p">,</span> <span class="s1">'q6'</span><span class="p">])</span> +<span class="gp">>>> </span><span class="n">stack</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">populate</span><span class="p">(</span><span class="n">b_name</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">aggregate</span><span class="p">(</span><span class="n">views</span><span class="o">=</span><span class="p">[</span><span class="s1">'counts'</span><span class="p">,</span> <span class="s1">'c%'</span><span class="p">,</span> <span class="s1">'cbase'</span><span class="p">],</span> <span class="n">batches</span><span class="o">=</span><span class="n">b_name</span><span class="p">,</span> <span class="n">verbose</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">cumulative_sum</span><span class="p">(</span><span class="s1">'q6'</span><span class="p">,</span> <span class="n">verbose</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">describe</span><span class="p">(</span><span class="s1">'view'</span><span class="p">,</span> <span class="s1">'x'</span><span class="p">)</span> +<span class="go">x q2b q6 q6_1 q6_2 q6_3</span> +<span class="go">view</span> +<span class="go">x|f.c:f|x++:|y||c%_cumsum NaN 1.0 1.0 1.0 1.0</span> +<span class="go">x|f.c:f|x++:|||counts_cumsum NaN 1.0 1.0 1.0 1.0</span> +<span class="go">x|f|:|y||c% 1.0 NaN NaN NaN NaN</span> +<span class="go">x|f|:|||counts 1.0 NaN NaN NaN NaN</span> +<span class="go">x|f|x:|||cbase 1.0 1.0 1.0 1.0 1.0</span> +</pre></div> +</div> +</div> +<div class="section" id="significance-tests"> +<h2>Significance tests<a class="headerlink" href="#significance-tests" title="Permalink to this headline">¶</a></h2> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch2</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">get_batch</span><span class="p">(</span><span class="s1">'batch2'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">batch2</span><span class="o">.</span><span class="n">set_sigtests</span><span class="p">([</span><span class="mf">0.05</span><span class="p">])</span> +<span class="gp">>>> </span><span class="n">batch5</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">get_batch</span><span class="p">(</span><span class="s1">'batch5'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">batch5</span><span class="o">.</span><span class="n">set_sigtests</span><span class="p">([</span><span class="mf">0.01</span><span class="p">,</span> <span class="mf">0.05</span><span class="p">])</span> +<span class="gp">>>> </span><span class="n">stack</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">populate</span><span class="p">([</span><span class="s1">'batch2'</span><span class="p">,</span> <span class="s1">'batch5'</span><span class="p">])</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">aggregate</span><span class="p">([</span><span class="s1">'counts'</span><span class="p">,</span> <span class="s1">'cbase'</span><span class="p">],</span> <span class="n">batches</span><span class="o">=</span><span class="p">[</span><span class="s1">'batch2'</span><span class="p">,</span> <span class="s1">'batch5'</span><span class="p">],</span> <span class="n">verbose</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">describe</span><span class="p">([</span><span class="s1">'view'</span><span class="p">,</span> <span class="s1">'y'</span><span class="p">],</span> <span class="s1">'x'</span><span class="p">)</span> +<span class="go">x q2b q6 q6_1 q6_2 q6_3</span> +<span class="go">view y</span> +<span class="go">x|f|:||weight|counts @ 1.0 NaN NaN NaN NaN</span> +<span class="go"> gender 1.0 NaN NaN NaN NaN</span> +<span class="go">x|f|:|||counts @ 1.0 1.0 1.0 1.0 1.0</span> +<span class="go">x|f|x:||weight|cbase @ 1.0 NaN NaN NaN NaN</span> +<span class="go"> gender 1.0 NaN NaN NaN NaN</span> +<span class="go">x|f|x:|||cbase @ 1.0 1.0 1.0 1.0 1.0</span> +<span class="go"> gender 1.0 NaN NaN NaN NaN</span> +</pre></div> +</div> +<p>Significance tests can only be added <code class="docutils literal"><span class="pre">Batch</span></code>-wise, which also means that +significance levels must be defined for each <code class="docutils literal"><span class="pre">Batch</span></code> before running +<code class="docutils literal"><span class="pre">stack.add_tests()</span></code>.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">add_tests</span><span class="p">([</span><span class="s1">'batch2'</span><span class="p">,</span> <span class="s1">'batch5'</span><span class="p">],</span> <span class="n">verbose</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">stack</span><span class="o">.</span><span class="n">describe</span><span class="p">([</span><span class="s1">'view'</span><span class="p">,</span> <span class="s1">'y'</span><span class="p">],</span> <span class="s1">'x'</span><span class="p">)</span> +<span class="go">x q2b q6 q6_1 q6_2 q6_3</span> +<span class="go">view y</span> +<span class="go">x|f|:||weight|counts @ 1.0 NaN NaN NaN NaN</span> +<span class="go"> gender 1.0 NaN NaN NaN NaN</span> +<span class="go">x|f|:|||counts @ 1.0 1.0 1.0 1.0 1.0</span> +<span class="go">x|f|x:||weight|cbase @ 1.0 NaN NaN NaN NaN</span> +<span class="go"> gender 1.0 NaN NaN NaN NaN</span> +<span class="go">x|f|x:|||cbase @ 1.0 1.0 1.0 1.0 1.0</span> +<span class="go"> gender 1.0 NaN NaN NaN NaN</span> +<span class="go">x|t.props.Dim.01|:|||significance @ 1.0 NaN 1.0 1.0 1.0</span> +<span class="go">x|t.props.Dim.05|:||weight|significance @ 1.0 NaN NaN NaN NaN</span> +<span class="go"> gender 1.0 NaN NaN NaN NaN</span> +<span class="go">x|t.props.Dim.05|:|||significance @ 1.0 NaN 1.0 1.0 1.0</span> +</pre></div> +</div> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="../builds/00_overview.html" class="btn btn-neutral float-right" title="Builds" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="03_test.html" class="btn btn-neutral" title="Significance testing" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/lib_doc/overview.html b/docs/API/_build/html/sites/lib_doc/overview.html new file mode 100644 index 000000000..7490bfe88 --- /dev/null +++ b/docs/API/_build/html/sites/lib_doc/overview.html @@ -0,0 +1,417 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Documentation — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../genindex.html"/> + <link rel="search" title="Search" href="../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../index.html"/> + + + <script src="../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul> +<li class="toctree-l1"><a class="reference internal" href="../release_notes/00_overview.html">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../release_notes/03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../release_notes/how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="../release_notes/how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="../release_notes/how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../release_notes/how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../release_notes/how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../release_notes/how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Stack.html">Stack</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../index.html">Docs</a> »</li> + + <li>Documentation</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../_sources/sites/lib_doc/overview.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="section" id="documentation"> +<h1>Documentation<a class="headerlink" href="#documentation" title="Permalink to this headline">¶</a></h1> +<div class="toctree-wrapper compound"> +</div> +</div> + + + </div> + </div> + <footer> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../_static/jquery.js"></script> + <script type="text/javascript" src="../../_static/underscore.js"></script> + <script type="text/javascript" src="../../_static/doctools.js"></script> + <script type="text/javascript" src="../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/release_notes/00_overview.html b/docs/API/_build/html/sites/release_notes/00_overview.html new file mode 100644 index 000000000..1da0b13ef --- /dev/null +++ b/docs/API/_build/html/sites/release_notes/00_overview.html @@ -0,0 +1,463 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Release notes — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../genindex.html"/> + <link rel="search" title="Search" href="../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../index.html"/> + <link rel="next" title="Latest (01/10/2018)" href="01_latest.html"/> + <link rel="prev" title="Quantipy: Python survey data toolkit" href="../../index.html"/> + + + <script src="../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1 current"><a class="current reference internal" href="#">Release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="01_latest.html">Latest (01/10/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Stack.html">Stack</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../index.html">Docs</a> »</li> + + <li>Release notes</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../_sources/sites/release_notes/00_overview.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="section" id="release-notes"> +<h1>Release notes<a class="headerlink" href="#release-notes" title="Permalink to this headline">¶</a></h1> +<div class="toctree-wrapper compound"> +<ul> +<li class="toctree-l1"><a class="reference internal" href="01_latest.html">Latest (01/10/2018)</a></li> +<li class="toctree-l1"><a class="reference internal" href="02_archive.html">Archived release notes</a><ul> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +</ul> +</div> +<div class="toctree-wrapper compound"> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="01_latest.html" class="btn btn-neutral float-right" title="Latest (01/10/2018)" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="../../index.html" class="btn btn-neutral" title="Quantipy: Python survey data toolkit" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../_static/jquery.js"></script> + <script type="text/javascript" src="../../_static/underscore.js"></script> + <script type="text/javascript" src="../../_static/doctools.js"></script> + <script type="text/javascript" src="../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/release_notes/01_latest.html b/docs/API/_build/html/sites/release_notes/01_latest.html new file mode 100644 index 000000000..7e73e6dd7 --- /dev/null +++ b/docs/API/_build/html/sites/release_notes/01_latest.html @@ -0,0 +1,523 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Latest (01/10/2018) — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../genindex.html"/> + <link rel="search" title="Search" href="../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../index.html"/> + <link rel="up" title="Release notes" href="00_overview.html"/> + <link rel="next" title="Archived release notes" href="02_archive.html"/> + <link rel="prev" title="Release notes" href="00_overview.html"/> + + + <script src="../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html">Release notes</a><ul class="current"> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Latest (01/10/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Stack.html">Stack</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html">Release notes</a> »</li> + + <li>Latest (01/10/2018)</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../_sources/sites/release_notes/01_latest.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="latest-01-10-2018"> +<h1>Latest (01/10/2018)<a class="headerlink" href="#latest-01-10-2018" title="Permalink to this headline">¶</a></h1> +<p><strong>New</strong>: “rewrite” of Rules module (affecting sorting):</p> +<p><strong>sorting “normal” columns</strong>:</p> +<ul class="simple"> +<li><code class="docutils literal"><span class="pre">sort_on</span></code> always ‘@’</li> +<li><code class="docutils literal"><span class="pre">fix</span></code> any categories</li> +<li><code class="docutils literal"><span class="pre">sort_by_weight</span></code> default is unweighted (None), but each weight (included</li> +</ul> +<p>in data) can be used</p> +<p>If sort_by_weight and the view-weight differ, a warning is shown.</p> +<p><strong>sorting “expanded net” columns</strong>:</p> +<ul class="simple"> +<li><code class="docutils literal"><span class="pre">sort_on</span></code> always ‘@’</li> +<li><code class="docutils literal"><span class="pre">fix</span></code> any categories</li> +<li>sorting <code class="docutils literal"><span class="pre">within</span></code> or <code class="docutils literal"><span class="pre">between</span></code> net groups is available</li> +<li><code class="docutils literal"><span class="pre">sort_by_weight</span></code>: as default the weight of the first found</li> +</ul> +<p>expanded-net-view is taken. Only weights of aggregated net-views are possible</p> +<p><strong>sorting “array summaries”</strong>:</p> +<ul class="simple"> +<li><code class="docutils literal"><span class="pre">sort_on</span></code> can be any desc (‘median’, ‘stddev’, ‘sem’, ‘max’, ‘min’,</li> +</ul> +<p>‘mean’, ‘upper_q’, ‘lower_q’) or nets (‘net_1’, ‘net_2’, …. enumerated +by the net_def) +* <code class="docutils literal"><span class="pre">sort_by_weight</span></code>: as default the weight of the first found desc/net-view +is taken. Only weights of aggregated desc/net-views are possible +* <code class="docutils literal"><span class="pre">sort_on</span></code> can also be any category, here each weight can be used to sort_on</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.min_value_count()</span></code></p> +<p>A new wrapper for <code class="docutils literal"><span class="pre">DataSet.hiding()</span></code> is included. All values are hidden, +that have less counts than the included number <code class="docutils literal"><span class="pre">min</span></code>. +The used data can be weighted or filtered using the parameters <code class="docutils literal"><span class="pre">weight</span></code> and +<code class="docutils literal"><span class="pre">condition</span></code>.</p> +<p>Usage as Batch method: +<code class="docutils literal"><span class="pre">Batch.min_value_count()</span></code> without the parameters <code class="docutils literal"><span class="pre">weight</span></code> and +<code class="docutils literal"><span class="pre">condition</span></code> automatically grabs <code class="docutils literal"><span class="pre">Batch.weights[0]</span></code> and <code class="docutils literal"><span class="pre">Batch.filter</span></code> +to calculate low value counts.</p> +<hr class="docutils" /> +<p><strong>New</strong>: Prevent weak duplicated in data</p> +<p>As Python is case sensitive it is possible to have two or more variables with +the same name, but in lower- and uppercases. Most other software do not support +that, so a warning is shown if a weak dupe is created. Additionally +<code class="docutils literal"><span class="pre">Dataset.write_dimensions()</span></code> performs auto-renaming is weak dupes are detected.</p> +<hr class="docutils" /> +<p><strong>New</strong>: Prevent single-cat delimited sets</p> +<p><code class="docutils literal"><span class="pre">DataSet.add_meta(...,</span> <span class="pre">qtype='delimited</span> <span class="pre">set',</span> <span class="pre">categories=[...],</span> <span class="pre">...)</span></code> +automatically switches <code class="docutils literal"><span class="pre">qtype</span></code> to single if only one category is defined. +<code class="docutils literal"><span class="pre">DataSet.convert(name,</span> <span class="pre">'single')</span></code> allows conversion from <code class="docutils literal"><span class="pre">delimited</span> <span class="pre">set</span></code> to +<code class="docutils literal"><span class="pre">single</span></code> if the variable has only one category. +<code class="docutils literal"><span class="pre">DataSet.repair()</span></code> and <code class="docutils literal"><span class="pre">DataSt.remove_values()</span></code> convert delimited sets +automatically to singles if only one category is included.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: merge warnings + merging delimites sets</p> +<p>Warnings in <code class="docutils literal"><span class="pre">hmerge()</span></code> and <code class="docutils literal"><span class="pre">vmerge()</span></code> are updated. If a column exists in +the left and the right dataset, the type is compared. Some type inconsistencies +are allowed, but return a warning, while others end up in a raise.</p> +<p>delimited sets in <code class="docutils literal"><span class="pre">vmerge()</span></code>:</p> +<p>If a column is a delimited set in the left dataset, but a single, int or float +in the right dataset, the data of the right column is converted into a delimited +set.</p> +<p>delimited sets in <code class="docutils literal"><span class="pre">hmerge(...merge_existing=None)</span></code>:</p> +<p>For the hmerge a new parameter <code class="docutils literal"><span class="pre">merge_existing</span></code> is included, which can be +<code class="docutils literal"><span class="pre">None</span></code>, a list of variable-names or <code class="docutils literal"><span class="pre">'all'</span></code>.</p> +<p>If delimited sets are included in left and right dataset:</p> +<ul class="simple"> +<li><code class="docutils literal"><span class="pre">merge_existing=None</span></code>: Only meta is adjusted. Data is untouched (left data</li> +</ul> +<p>is taken). +* <code class="docutils literal"><span class="pre">merge_existing='all'</span></code>: Meta and data are merged for all delimited sets, +that are included in both datasets. +* <code class="docutils literal"><span class="pre">merge_existing=[variable-names]</span></code>: Meta and data are merged for all +delimited sets, that are listed and included in both datasets.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: encoding in <code class="docutils literal"><span class="pre">DataSet.get_batch(name)</span></code></p> +<p>The method is not that encoding sensitive anymore. It returns the depending +<code class="docutils literal"><span class="pre">Batch</span></code>, no matter if <code class="docutils literal"><span class="pre">'...'</span></code>, <code class="docutils literal"><span class="pre">u'...'</span></code> or <code class="docutils literal"><span class="pre">'...'.decode('utf8')</span></code> is +included as name.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: warning in weight engine</p> +<p>Missing codes in the sample are only alerted, if the belonging target is not 0.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.to_array(...,</span> <span class="pre">variables,</span> <span class="pre">...)</span></code></p> +<p>Duplicated vars in <code class="docutils literal"><span class="pre">variables</span></code> are not allowed anymore, these were causing +problems in the ChainManager class.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Batch.add_open_ends()</span></code></p> +<p>Method raises an error if no vars are included in <code class="docutils literal"><span class="pre">oe</span></code> and <code class="docutils literal"><span class="pre">break_by</span></code>. The +empty dataframe was causing issues in the ChainManager class.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Batch.extend_x()</span></code></p> +<p>The method automatically checks if the included variables are arrays and adds +them to <code class="docutils literal"><span class="pre">Batch.summaries</span></code> if they are included yet.</p> +<hr class="docutils" /> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="02_archive.html" class="btn btn-neutral float-right" title="Archived release notes" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="00_overview.html" class="btn btn-neutral" title="Release notes" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../_static/jquery.js"></script> + <script type="text/javascript" src="../../_static/underscore.js"></script> + <script type="text/javascript" src="../../_static/doctools.js"></script> + <script type="text/javascript" src="../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/release_notes/02_archive.html b/docs/API/_build/html/sites/release_notes/02_archive.html new file mode 100644 index 000000000..e0c791e03 --- /dev/null +++ b/docs/API/_build/html/sites/release_notes/02_archive.html @@ -0,0 +1,1573 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Archived release notes — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../genindex.html"/> + <link rel="search" title="Search" href="../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../index.html"/> + <link rel="up" title="Release notes" href="00_overview.html"/> + <link rel="next" title="How-to-snippets" href="03_how_to_snippets.html"/> + <link rel="prev" title="Latest (01/10/2018)" href="01_latest.html"/> + + + <script src="../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html">Release notes</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="01_latest.html">Latest (01/10/2018)</a></li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="#sd-04-06-2018">sd (04/06/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="03_how_to_snippets.html">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Stack.html">Stack</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html">Release notes</a> »</li> + + <li>Archived release notes</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../_sources/sites/release_notes/02_archive.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="archived-release-notes"> +<h1>Archived release notes<a class="headerlink" href="#archived-release-notes" title="Permalink to this headline">¶</a></h1> +<div class="section" id="sd-04-06-2018"> +<h2>sd (04/06/2018)<a class="headerlink" href="#sd-04-06-2018" title="Permalink to this headline">¶</a></h2> +<p><strong>New</strong>: Additional variable (names) “getter”-like and resolver methods</p> +<ul class="simple"> +<li><code class="docutils literal"><span class="pre">DataSet.created()</span></code></li> +<li><code class="docutils literal"><span class="pre">DataSet.find(str_tags=None,</span> <span class="pre">suffixed=False)</span></code></li> +<li><code class="docutils literal"><span class="pre">DataSet.names()</span></code></li> +<li><code class="docutils literal"><span class="pre">DataSet.resolve_name()</span></code></li> +</ul> +<p>A bunch of new methods enhancing the options of finding and testing for variable +names have been added. <code class="docutils literal"><span class="pre">created()</span></code> will list all variables that have been added +to a dataset using core functions, i.e. <code class="docutils literal"><span class="pre">add_meta()</span></code> and <code class="docutils literal"><span class="pre">derive()</span></code>, resp. +all helper methods that use them internally (as <code class="docutils literal"><span class="pre">band()</span></code> or <code class="docutils literal"><span class="pre">categorize()</span></code> do +for instance).</p> +<p>The <code class="docutils literal"><span class="pre">find()</span></code> method is returning all variable names that contain any of the +provided substrings in <code class="docutils literal"><span class="pre">str_tags</span></code>. To only consider names that end with these +strings, set <code class="docutils literal"><span class="pre">suffixed=True</span></code>. If no <code class="docutils literal"><span class="pre">str_tags</span></code> are passed, the method will +use a default list of tags including <code class="docutils literal"><span class="pre">['_rc',</span> <span class="pre">'_net',</span> <span class="pre">'</span> <span class="pre">(categories',</span> <span class="pre">'</span> <span class="pre">(NET',</span> <span class="pre">'_rec']</span></code>.</p> +<p>Sometimes a dataset might contain “semi-duplicated” names, variables that differ +in respect to case sensitivity but have otherwise identical names. Calling +<code class="docutils literal"><span class="pre">names()</span></code> will report such cases in a <code class="docutils literal"><span class="pre">pd.DataFrame</span></code> that lists all name +variants under the respective <code class="docutils literal"><span class="pre">str.lower()</span></code> version. If no semi-duplicates +are found, <code class="docutils literal"><span class="pre">names()</span></code> will simply return <code class="docutils literal"><span class="pre">DataSet.variables()</span></code>.</p> +<p>Lastly, <code class="docutils literal"><span class="pre">resolve_name()</span></code> can be used to return the “proper”, existing representation(s) of a given variable name’s spelling.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">Batch.remove()</span></code></p> +<p>Not needed batches can be removed from <code class="docutils literal"><span class="pre">meta</span></code>, so they are not aggregated +anymore.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">Batch.rename(new_name)</span></code></p> +<p>Sometimes standard batches have long/ complex names. They can now be changed +into a custom name. Please take into account, that for most hubs the name of +omnibus batches should look like ‘client ~ topic’.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: Handling verbatims in <code class="docutils literal"><span class="pre">qp.Batch</span></code></p> +<p>Instead of holding the well prepared open-end dataframe in <code class="docutils literal"><span class="pre">batch.verbatims</span></code>, +the attribute is now filled by <code class="docutils literal"><span class="pre">batch.add_open_ends()</span></code> with instructions to +create the open-end dataframe. It is easier to to modify/ overwrite existing +verbatims. Therefore also a new parameter is included <code class="docutils literal"><span class="pre">overwrite=True</span></code>.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Batch.copy(...,</span> <span class="pre">b_filter=None,</span> <span class="pre">as_addition=False)</span></code></p> +<p>It is now possible to define an additional filter for a copied batch and also +to set it as addition to the master batch.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: Regrouping the variable list using <code class="docutils literal"><span class="pre">DataSet.order(...,</span> <span class="pre">regroup=True)</span></code></p> +<p>A new parameter called <code class="docutils literal"><span class="pre">regroup</span></code> will instruct reordering all newly created +variables into their logical position of the dataset’s main variable order, i.e. +attempting to place <em>derived</em> variables after the <em>originating</em> ones.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">add_meta()</span></code> and duplicated categorical <code class="docutils literal"><span class="pre">values</span></code> codes</p> +<p>Providing duplicated numerical codes while attempting to create new metadata +using <code class="docutils literal"><span class="pre">add_meta()</span></code> will now correctly raise a <code class="docutils literal"><span class="pre">ValueError</span></code> to prevent +corrupting the <code class="docutils literal"><span class="pre">DataSet</span></code>.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">cats</span> <span class="o">=</span> <span class="p">[(</span><span class="mi">1</span><span class="p">,</span> <span class="s1">'A'</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="s1">'B'</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="s1">'C'</span><span class="p">),</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="s1">'D'</span><span class="p">),</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="s1">'AA'</span><span class="p">)]</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">add_meta</span><span class="p">(</span><span class="s1">'test_var'</span><span class="p">,</span> <span class="s1">'single'</span><span class="p">,</span> <span class="s1">'test label'</span><span class="p">,</span> <span class="n">cats</span><span class="p">)</span> +<span class="go">ValueError: Cannot resolve category definition due to code duplicates: [2, 3]</span> +</pre></div> +</div> +</div> +<div class="section" id="sd-04-04-2018"> +<h2>sd (04/04/2018)<a class="headerlink" href="#sd-04-04-2018" title="Permalink to this headline">¶</a></h2> +<p><strong>New</strong>: Emptiness handlers in <code class="docutils literal"><span class="pre">DataSet</span></code> and <code class="docutils literal"><span class="pre">Batch</span></code> classes</p> +<ul class="simple"> +<li><code class="docutils literal"><span class="pre">DataSet.empty(name,</span> <span class="pre">condition=None)</span></code></li> +<li><code class="docutils literal"><span class="pre">DataSet.empty_items(name,</span> <span class="pre">condition=None,</span> <span class="pre">by_name=True)</span></code></li> +<li><code class="docutils literal"><span class="pre">DataSet.hide_empty_items(condition=None,</span> <span class="pre">arrays=None)</span></code></li> +<li><code class="docutils literal"><span class="pre">Batch.hide_empty(xks=True,</span> <span class="pre">summaries=True)</span></code></li> +</ul> +<p><code class="docutils literal"><span class="pre">empty()</span></code> is used to test if regular variables are completely empty, +<code class="docutils literal"><span class="pre">empty_items()</span></code> checks the same for the items of an array mask definition. +Both can be run on lists of variables. If a single variable is tested, the former +returns simply boolean, the latter will list all empty items. If lists are checked, +<code class="docutils literal"><span class="pre">empty()</span></code> returns the sublist of empty variables, <code class="docutils literal"><span class="pre">empty_items()</span></code> is mapping +the list of empty items per array name. The <code class="docutils literal"><span class="pre">condition</span></code> parameter of these +methods takes a <code class="docutils literal"><span class="pre">Quantipy</span> <span class="pre">logic</span></code> expression to restrict the test to a subset +of the data, i.e. to check if variables will be empty if the dataset is filtered +a certain way. A very simple example:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">add_meta</span><span class="p">(</span><span class="s1">'test_var'</span><span class="p">,</span> <span class="s1">'int'</span><span class="p">,</span> <span class="s1">'Variable is empty'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="s1">'test_var'</span><span class="p">)</span> +<span class="go">True</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="p">[</span><span class="n">dataset</span><span class="o">.</span><span class="n">take</span><span class="p">({</span><span class="s1">'gender'</span><span class="p">:</span> <span class="mi">1</span><span class="p">}),</span> <span class="s1">'test_var'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="s1">'test_var'</span><span class="p">)</span> +<span class="go">False</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">empty</span><span class="p">(</span><span class="s1">'test_var'</span><span class="p">,</span> <span class="p">{</span><span class="s1">'gender'</span><span class="p">:</span> <span class="mi">2</span><span class="p">})</span> +<span class="go">True</span> +</pre></div> +</div> +<p>The <code class="docutils literal"><span class="pre">DataSet</span></code> method <code class="docutils literal"><span class="pre">hide_empty_items()</span></code> uses the emptiness tests to +automatically apply a <strong>hiding rule</strong> on all empty items found in the dataset. +To restrict this to specific arrays only, their names can be provided via the +<code class="docutils literal"><span class="pre">arrays</span></code> argument. <code class="docutils literal"><span class="pre">Batch.hide_empty()</span></code> takes into account the current +<code class="docutils literal"><span class="pre">Batch.filter</span></code> setup and by drops/hides <em>all</em> relevant empty variables from the +<code class="docutils literal"><span class="pre">xks</span></code> list and summary aggregations by default. Summaries that would end up without valid +items because of this are automatically removed from the <code class="docutils literal"><span class="pre">summaries</span></code> collection +and the user is warned.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">qp.set_option('fast_stack_filters',</span> <span class="pre">True)</span></code></p> +<p>A new option to enable a more efficient test for already existing filters +inside the <code class="docutils literal"><span class="pre">qp.Stack</span></code> object has been added. Set the <code class="docutils literal"><span class="pre">'fast_stack_filters'</span></code> +option to <code class="docutils literal"><span class="pre">True</span></code> to use it, the default is <code class="docutils literal"><span class="pre">False</span></code> to ensure compatibility +in different versions of production DP template workspaces.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Stack.add_stats(...,</span> <span class="pre">factor_labels=True,</span> <span class="pre">...)</span></code></p> +<p>The parameter <code class="docutils literal"><span class="pre">factor_labels</span></code> is now also able to take the string <code class="docutils literal"><span class="pre">'()'</span></code>, +then factors are written in the normal brackets next to the label (instead +of <code class="docutils literal"><span class="pre">[]</span></code>).</p> +<p>In the new version factor_labels are also just added if there are none included +before, except new scales are used.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">DataSet</span></code> <code class="docutils literal"><span class="pre">np.NaN</span></code> insertion to <code class="docutils literal"><span class="pre">delimited_set</span></code> variables</p> +<p><code class="docutils literal"><span class="pre">np.NaN</span></code> was incorrectly transformed when inserted into <code class="docutils literal"><span class="pre">delimited_set</span></code> +before, leading to either <code class="docutils literal"><span class="pre">numpy</span></code> type conflicts or type casting exceptions. +This is now fixed.</p> +</div> +<div class="section" id="sd-27-02-2018"> +<h2>sd (27/02/2018)<a class="headerlink" href="#sd-27-02-2018" title="Permalink to this headline">¶</a></h2> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet._dimensions_suffix</span></code></p> +<p><code class="docutils literal"><span class="pre">DataSet</span></code> has a new attribute <code class="docutils literal"><span class="pre">_dimensions_suffix</span></code>, which is used as mask +suffix while running <code class="docutils literal"><span class="pre">DataSet.dimensionize()</span></code>. The default is <code class="docutils literal"><span class="pre">_grid</span></code> and +it can be modified with <code class="docutils literal"><span class="pre">DataSet.set_dim_suffix()</span></code>.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Stack._get_chain()</span></code> (old chain)</p> +<p>The method is speeded-up. If a filter is already included in the Stack, it is +not calculated from scratch anymore. Additionally the method has a new parameter +<code class="docutils literal"><span class="pre">described</span></code>, which takes a describing dataframe of the Stack, so it no longer +needs to be calculated in each loop.</p> +<p>Nets that are applied on array variables will now also create a new recoded +array that reflects the net definitions if <code class="docutils literal"><span class="pre">recoded</span></code> is used. The +method has been creating only the item versions before.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Stack.add_stats()</span></code></p> +<p>The method will now create a new metadata property called <code class="docutils literal"><span class="pre">'factor'</span></code> for each +variable it is applied on. You can only have one factor assigned to one +categorical value, so for multiple statistic definitions (exclusions, etc.) +it will get overwritten.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.from_batch()</span></code> (<code class="docutils literal"><span class="pre">additions</span></code> parameter)</p> +<p>The <code class="docutils literal"><span class="pre">additions</span></code> parameter has been updated to also be able to create recoded +variables from existing “additional” Batches that are attached to a parent one. +Filter variables will get the new meta <code class="docutils literal"><span class="pre">'properties'</span></code> tag <code class="docutils literal"><span class="pre">'recoded_filter'</span></code> +and only have one category (<code class="docutils literal"><span class="pre">1</span></code>, <code class="docutils literal"><span class="pre">'active'</span></code>). They are named simply +<code class="docutils literal"><span class="pre">'filter_1'</span></code>, <code class="docutils literal"><span class="pre">'filter_2'</span></code> and so on. The new possible values of the +parameters are now:</p> +<blockquote> +<div><ul class="simple"> +<li><code class="docutils literal"><span class="pre">None</span></code>: <code class="docutils literal"><span class="pre">as_addition()</span></code>-Batches are not considered.</li> +<li><code class="docutils literal"><span class="pre">'variables'</span></code>: Only cross- and downbreak variables are considered.</li> +<li><code class="docutils literal"><span class="pre">'filters'</span></code>: Only filters are recoded.</li> +<li><code class="docutils literal"><span class="pre">'full'</span></code>: <code class="docutils literal"><span class="pre">'variables'</span></code> + <code class="docutils literal"><span class="pre">'filters'</span></code></li> +</ul> +</div></blockquote> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">ViewManager._request_views()</span></code></p> +<p>Cumulative sums are only requested if they are included in the belonging +<code class="docutils literal"><span class="pre">Stack</span></code>. Additionally the correct related sig-tests are now taken for +cumulative sums.</p> +</div> +<div class="section" id="sd-12-01-2018"> +<h2>sd (12/01/2018)<a class="headerlink" href="#sd-12-01-2018" title="Permalink to this headline">¶</a></h2> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">Audit</span></code></p> +<p><code class="docutils literal"><span class="pre">Audit</span></code> is a new class which takes <code class="docutils literal"><span class="pre">DataSet</span></code> instances, compares and aligns +them.</p> +<p>The class compares/ reports/ aligns the following aspects:</p> +<blockquote> +<div><ul class="simple"> +<li>datasets are valid (<code class="docutils literal"><span class="pre">DataSet.validate()</span></code>)</li> +<li>mismatches (variables are not included in all datasets)</li> +<li>different types (variables are in more than one dataset, but have different types)</li> +<li>labels (variables are in more than one dataset, but have different labels for the same text_key)</li> +<li>value codes (variables are in more than one dataset, but have different value codes)</li> +<li>value texts (variables are in more than one dataset, but have different value texts)</li> +<li>array items (arrays are in more than one dataset, but have different items)</li> +<li>item labels (arrays are in more than one dataset, but their items have different labels)</li> +</ul> +</div></blockquote> +<p>This is the first draft of the class, so it will need some testing and probably +adjustments.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.reorder_items(name,</span> <span class="pre">new_order)</span></code></p> +<p>The new method reorders the items of the included array. The ints in the +<code class="docutils literal"><span class="pre">new_order</span></code> list match up to the number of the items +(<code class="docutils literal"><span class="pre">DataSet.item_no('item_name')</span></code>), not to the position.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.valid_tks</span></code>, Arabic</p> +<p>Arabic (<code class="docutils literal"><span class="pre">ar-AR</span></code>) is included as default valid text-key.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.extend_items(name,</span> <span class="pre">ext_items,</span> <span class="pre">text_key=None)</span></code></p> +<p>The new method extends the items of an existing array.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.set_missings()</span></code></p> +<p>The method is now limited to <code class="docutils literal"><span class="pre">DataSet</span></code>, <code class="docutils literal"><span class="pre">Batch</span></code> does not inherit it.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet</span></code></p> +<p>The whole class is reordered and cleaned up. Some new deprecation warnings +will appear.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.add_meta()</span></code> / <code class="docutils literal"><span class="pre">DataSet.derive()</span></code></p> +<p>Both methods will now raise a <code class="docutils literal"><span class="pre">ValueError:</span> <span class="pre">Duplicated</span> <span class="pre">codes</span> <span class="pre">provided.</span> <span class="pre">Value</span> <span class="pre">codes</span> <span class="pre">must</span> <span class="pre">be</span> <span class="pre">unique!</span></code> +if categorical <code class="docutils literal"><span class="pre">values</span></code> definitions try to apply duplicated codes.</p> +</div> +<hr class="docutils" /> +<div class="section" id="sd-18-12-2017"> +<h2>sd (18/12/2017)<a class="headerlink" href="#sd-18-12-2017" title="Permalink to this headline">¶</a></h2> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">Batch.remove_filter()</span></code></p> +<p>Removes all defined (global + extended) filters from a Batch instance.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Batch.add_filter()</span></code></p> +<p>It’s now possible to extend the global filter of a Batch instance. These options +are possible.</p> +<p>Add first filter:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">filter</span><span class="p">,</span> <span class="n">batch</span><span class="o">.</span><span class="n">filter_names</span> +<span class="go">'no_filter', ['no_filter']</span> +<span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">add_filter</span><span class="p">(</span><span class="s1">'filter1'</span><span class="p">,</span> <span class="n">logic1</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">filter</span><span class="p">,</span> <span class="n">batch</span><span class="o">.</span><span class="n">filter_names</span> +<span class="go">{'filter1': logic1}, ['filter1']</span> +</pre></div> +</div> +<p>Extend filter:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">filter</span><span class="p">,</span> <span class="n">batch</span><span class="o">.</span><span class="n">filter_names</span> +<span class="go">{'filter1': logic}, ['filter1']</span> +<span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">add_filter</span><span class="p">(</span><span class="s1">'filter2'</span><span class="p">,</span> <span class="n">logic2</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">filter</span><span class="p">,</span> <span class="n">batch</span><span class="o">.</span><span class="n">filter_names</span> +<span class="go">{'filter1' + 'filter2': intersection([logic1, logic2])}, ['filter1' + 'filter2']</span> +</pre></div> +</div> +<p>Replace filter:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">filter</span><span class="p">,</span> <span class="n">batch</span><span class="o">.</span><span class="n">filter_names</span> +<span class="go">{'filter1': logic}, ['filter1']</span> +<span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">add_filter</span><span class="p">(</span><span class="s1">'filter1'</span><span class="p">,</span> <span class="n">logic2</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">batch</span><span class="o">.</span><span class="n">filter</span><span class="p">,</span> <span class="n">batch</span><span class="o">.</span><span class="n">filter_names</span> +<span class="go">{'filter1': logic2}, ['filter1']</span> +</pre></div> +</div> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Stack.add_stats(...,</span> <span class="pre">recode)</span></code></p> +<p>The new parameter <code class="docutils literal"><span class="pre">recode</span></code> defines if a new numerical variable is created which +satisfies the stat definitions.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.populate()</span></code></p> +<p>A progress tracker is added to this method.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">Batch.add_open_ends()</span></code></p> +<p><code class="docutils literal"><span class="pre">=</span></code> is removed from all responsess in the included variables, as it causes +errors in the Excel-Painter.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">Batch.extend_x()</span></code> and <code class="docutils literal"><span class="pre">Batch.extend_y()</span></code></p> +<p>Check if included variables exist and unroll included masks.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">Stack.add_nets(...,</span> <span class="pre">calc)</span></code></p> +<p>If the operator in calc is <code class="docutils literal"><span class="pre">div</span></code>/ <code class="docutils literal"><span class="pre">/</span></code>, the calculation is now performed +correctly.</p> +</div> +<hr class="docutils" /> +<div class="section" id="sd-28-11-2017"> +<h2>sd (28/11/2017)<a class="headerlink" href="#sd-28-11-2017" title="Permalink to this headline">¶</a></h2> +<p><strong>New</strong> <code class="docutils literal"><span class="pre">DataSet.from_batch()</span></code></p> +<p>Creates a new <code class="docutils literal"><span class="pre">DataSet</span></code> instance out of <code class="docutils literal"><span class="pre">Batch</span></code> definitions (xks, yks, +filter, weight, language, additions, edits).</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">Batch.add_total()</span></code></p> +<p>Defines if total column <code class="docutils literal"><span class="pre">@</span></code> should be included in the downbreaks (yks).</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">Batch.set_unwgt_counts()</span></code></p> +<p>If cellitems are <code class="docutils literal"><span class="pre">cp</span></code> and a weight is provided, it is possible to request +unweighted count views (percentages are still weighted).</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Batch.add_y_on_y(name,</span> <span class="pre">y_filter=None,</span> <span class="pre">main_filter='extend')</span></code></p> +<p>Multiple <code class="docutils literal"><span class="pre">y_on_y</span></code> aggregations can now be added to a <code class="docutils literal"><span class="pre">Batch</span></code> instance +and each can have an own filter. The y_on_y-filter can <code class="docutils literal"><span class="pre">extend</span></code> or <code class="docutils literal"><span class="pre">replace</span></code> +the main_filter of the <code class="docutils literal"><span class="pre">Batch</span></code>.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Stack.add_nets(...,</span> <span class="pre">recode)</span></code></p> +<p>The new parameter <code class="docutils literal"><span class="pre">recode</span></code> defines if a new variable is created which +satisfies the net definitions. Different options for <code class="docutils literal"><span class="pre">recode</span></code> are:</p> +<blockquote> +<div><ul class="simple"> +<li><code class="docutils literal"><span class="pre">'extend_codes'</span></code>: The new variable contains all codes of the original +variable and all nets as new categories.</li> +<li><code class="docutils literal"><span class="pre">'drop_codes'</span></code>: The new variable contains only all nets as new categories.</li> +<li><code class="docutils literal"><span class="pre">'collect_codes'</span></code> or <code class="docutils literal"><span class="pre">'collect_codes@cat_name'</span></code>: The new variable contains +all nets as new categories and another new category which sums all cases that +are not in any net. The new category text can be defined by adding <code class="docutils literal"><span class="pre">@cat_name</span></code> +to <code class="docutils literal"><span class="pre">collect_codes</span></code>. If none is provided <code class="docutils literal"><span class="pre">Other</span></code> is used as default.</li> +</ul> +</div></blockquote> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Stack.add_nets()</span></code></p> +<p>If a variable in the <code class="docutils literal"><span class="pre">Stack</span></code> already has a net_view, it gets overwritten +if a new net is added.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.set_missings(...,</span> <span class="pre">missing_map)</span></code></p> +<p>The parameter <code class="docutils literal"><span class="pre">missing_map</span></code> can also handle lists now. All included +codes are be flagged as <code class="docutils literal"><span class="pre">'exclude'</span></code>.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">request_views(...,</span> <span class="pre">sums='mid')</span></code> (<code class="docutils literal"><span class="pre">ViewManager</span></code>/<code class="docutils literal"><span class="pre">query.py</span></code>)</p> +<p>Allow different positions for sums in the view-order. They can be placed in +the middle (<code class="docutils literal"><span class="pre">'mid'</span></code>) between the basics/ nets and the stats or at the +<code class="docutils literal"><span class="pre">'bottom'</span></code> after the stats.</p> +<hr class="docutils" /> +<p><strong>Update/ New</strong>: <code class="docutils literal"><span class="pre">write_dimensions()</span></code></p> +<p>Converting qp data to mdd and ddf files by using <code class="docutils literal"><span class="pre">write_dimensions()</span></code> is +updated now. A bug regarding encoding texts is fixed and additionally all +included <code class="docutils literal"><span class="pre">text_keys</span></code> in the meta are transferred into the mdd. Therefore +two new classes are included: <code class="docutils literal"><span class="pre">DimLabels</span></code> and <code class="docutils literal"><span class="pre">DimLabel</span></code>.</p> +</div> +<div class="section" id="sd-13-11-2017"> +<h2>sd (13/11/2017)<a class="headerlink" href="#sd-13-11-2017" title="Permalink to this headline">¶</a></h2> +<dl class="docutils"> +<dt><strong>New</strong> <a href="#id1"><span class="problematic" id="id2">``</span></a>DataSet.to_delimited_set(name, label, variables,</dt> +<dd>from_dichotomous=True, codes_from_name=True)``</dd> +</dl> +<p>Creates a new delimited set variable out of other variables. If the input- +variables are dichotomous (<code class="docutils literal"><span class="pre">from_dichotomous</span></code>), the new value-codes can be +taken from the variable-names or from the order of the variables +(<code class="docutils literal"><span class="pre">codes_from_name</span></code>).</p> +<hr class="docutils" /> +<p><strong>Update</strong> <code class="docutils literal"><span class="pre">Stack.aggregate(...,</span> <span class="pre">bases={})</span></code></p> +<p>A dictionary in form of:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">bases</span> <span class="o">=</span> <span class="p">{</span> + <span class="s1">'cbase'</span><span class="p">:</span> <span class="p">{</span> + <span class="s1">'wgt'</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> + <span class="s1">'unwgt'</span><span class="p">:</span> <span class="kc">False</span><span class="p">},</span> + <span class="s1">'cbase_gross'</span><span class="p">:</span> <span class="p">{</span> + <span class="s1">'wgt'</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> + <span class="s1">'unwgt'</span><span class="p">:</span> <span class="kc">True</span><span class="p">},</span> + <span class="s1">'ebase'</span><span class="p">:</span> <span class="p">{</span> + <span class="s1">'wgt'</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> + <span class="s1">'unwgt'</span><span class="p">:</span> <span class="kc">False</span><span class="p">}</span> + <span class="p">}</span> +</pre></div> +</div> +<p>defines what kind of bases will be aggregated. If <code class="docutils literal"><span class="pre">bases</span></code> is provided the +old parameter <code class="docutils literal"><span class="pre">unweighted_base</span></code> and any bases in the parameter <code class="docutils literal"><span class="pre">views</span></code> +will be ignored. If bases is not provided and any base is included in <code class="docutils literal"><span class="pre">views</span></code>, +a dictionary is automatically created out of <code class="docutils literal"><span class="pre">views</span></code> and <code class="docutils literal"><span class="pre">unweighted_base</span></code>.</p> +</div> +<div class="section" id="sd-17-10-2017"> +<h2>sd (17/10/2017)<a class="headerlink" href="#sd-17-10-2017" title="Permalink to this headline">¶</a></h2> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">del</span> <span class="pre">DataSet['var_name']</span></code> and <code class="docutils literal"><span class="pre">'var_name'</span> <span class="pre">in</span> <span class="pre">DataSet</span></code> syntax support</p> +<p>It is now possible to test membership of a variable name simply using the <code class="docutils literal"><span class="pre">in</span></code> +operator instead of <code class="docutils literal"><span class="pre">DataSet.var_exists('var_name')</span></code> and delete a variable definition +from <code class="docutils literal"><span class="pre">DataSet</span></code> using the <code class="docutils literal"><span class="pre">del</span></code> keyword inplace of the <code class="docutils literal"><span class="pre">drop('var_name')</span></code> +method.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.is_single(name)</span></code>, <code class="docutils literal"><span class="pre">.is_delimited_set(name)</span></code>, <code class="docutils literal"><span class="pre">.is_int(name)</span></code>, <code class="docutils literal"><span class="pre">.is_float(name)</span></code>, <code class="docutils literal"><span class="pre">.is_string(name)</span></code>, <code class="docutils literal"><span class="pre">.is_date(name)</span></code>, <code class="docutils literal"><span class="pre">.is_array(name)</span></code></p> +<p>These new methods make testing a variable’s type easy.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.singles(array_items=True)</span></code> and all other non-<code class="docutils literal"><span class="pre">array</span></code> type iterators</p> +<p>It is now possible to exclude <code class="docutils literal"><span class="pre">array</span></code> items from <code class="docutils literal"><span class="pre">singles()</span></code>, <code class="docutils literal"><span class="pre">delimited_sets()</span></code>, +<code class="docutils literal"><span class="pre">ints()</span></code> and <code class="docutils literal"><span class="pre">floats()</span></code> variable lists by setting the new <code class="docutils literal"><span class="pre">array_items</span></code> +parameter to <code class="docutils literal"><span class="pre">False</span></code>.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Batch.set_sigtests(...,</span> <span class="pre">flags=None,</span> <span class="pre">test_total=None)</span></code>, <code class="docutils literal"><span class="pre">Batch.sigproperties</span></code></p> +<p>The significancetest-settings for flagging and testing against total, can now +be modified by the two parameters <code class="docutils literal"><span class="pre">flags</span></code> and <code class="docutils literal"><span class="pre">test_total</span></code>. The <code class="docutils literal"><span class="pre">Batch</span></code> +attribute <code class="docutils literal"><span class="pre">siglevels</span></code> is removed, instead all sig-settings are stored +in <code class="docutils literal"><span class="pre">Batch.sigproperties</span></code>.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Batch.make_summaries(...,</span> <span class="pre">exclusive=False)</span></code>, <code class="docutils literal"><span class="pre">Batch.skip_items</span></code></p> +<p>The new parameter <code class="docutils literal"><span class="pre">exclusive</span></code> can take a list of arrays or a boolean. If a list +is included, these arrays are added to <code class="docutils literal"><span class="pre">Batch.skip_items</span></code>, if it is True all +variables from <code class="docutils literal"><span class="pre">Batch.summaries</span></code> are added to <code class="docutils literal"><span class="pre">Batch.skip_items</span></code></p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">quantipy.sandbox.sandbox.Chain.paint(...,</span> <span class="pre">totalize=True)</span></code></p> +<p>If <code class="docutils literal"><span class="pre">totalize</span></code> is <code class="docutils literal"><span class="pre">True</span></code>, <code class="docutils literal"><span class="pre">@</span></code>-Total columns of a (x-oriented) <code class="docutils literal"><span class="pre">Chain.dataframe</span></code> +will be painted as <code class="docutils literal"><span class="pre">'Total'</span></code> instead of showing the corresponsing <code class="docutils literal"><span class="pre">x</span></code>-variables +question text.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">quantipy.core.weights.Rim.Rake</span></code></p> +<p>The weighting algorithm’s <code class="docutils literal"><span class="pre">generate_report()</span></code> method can be caught up in a +<code class="docutils literal"><span class="pre">MemoryError</span></code> for complex weight schemes run on very large sample sizes. This +is now prevented to ensure the weight factors are computed with priority and +the algorithm is able to terminate correctly. A warning is raised:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="ne">UserWarning</span><span class="p">:</span> <span class="n">OOM</span><span class="p">:</span> <span class="n">Could</span> <span class="ow">not</span> <span class="n">finish</span> <span class="n">writing</span> <span class="n">report</span><span class="o">...</span> +</pre></div> +</div> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Batch.replace_y()</span></code></p> +<p>Conditional replacements of y-variables of a <code class="docutils literal"><span class="pre">Batch</span></code> will now always also +automatically add the <code class="docutils literal"><span class="pre">@</span></code>-Total indicator if not provided.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">DataSet.force_texts(...,</span>  <span class="pre">overwrite=True)</span></code></p> +<p>Forced overwriting of existing <code class="docutils literal"><span class="pre">text_key</span></code> meta data was failing for <code class="docutils literal"><span class="pre">array</span></code> +<code class="docutils literal"><span class="pre">mask</span></code> objects. This is now solved.</p> +</div> +<hr class="docutils" /> +<div class="section" id="sd-15-09-2017"> +<h2>sd (15/09/2017)<a class="headerlink" href="#sd-15-09-2017" title="Permalink to this headline">¶</a></h2> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.meta_to_json(key=None,</span> <span class="pre">collection=None)</span></code></p> +<p>The new method allows saving parts of the metadata as a json file. The parameters +<code class="docutils literal"><span class="pre">key</span></code> and <code class="docutils literal"><span class="pre">collection</span></code> define the metaobject which will be saved.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.save()</span></code> and <code class="docutils literal"><span class="pre">DataSet.revert()</span></code></p> +<p>These two new methods are useful in interactive sessions like <strong>Ipython</strong> or +<strong>Jupyter</strong> notebooks. <code class="docutils literal"><span class="pre">save()</span></code> will make a temporary (only im memory, not +written to disk) copy of the <code class="docutils literal"><span class="pre">DataSet</span></code> and store its current state. You can +then use <code class="docutils literal"><span class="pre">revert()</span></code> to rollback to that snapshot of the data at a later +stage (e.g. a complex recode operation went wrong, reloading from the physical files takes +too long…).</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.by_type(types=None)</span></code></p> +<p>The <code class="docutils literal"><span class="pre">by_type()</span></code> method is replacing the soon to be deprecated implementation +of <code class="docutils literal"><span class="pre">variables()</span></code> (see below). It provides the same functionality +(<code class="docutils literal"><span class="pre">pd.DataFrame</span></code> summary of variable types) as the latter.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.variables()</span></code> absorbs <code class="docutils literal"><span class="pre">list_variables()</span></code> and <code class="docutils literal"><span class="pre">variables_from_set()</span></code></p> +<p>In conjunction with the addition of <code class="docutils literal"><span class="pre">by_type()</span></code>, <code class="docutils literal"><span class="pre">variables()</span></code> is +replacing the related <code class="docutils literal"><span class="pre">list_variables()</span></code> and <code class="docutils literal"><span class="pre">variables_from_set()</span></code> methods in order to offer a unified solution for querying the <code class="docutils literal"><span class="pre">DataSet</span></code>’s (main) variable collection.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Batch.as_addition()</span></code></p> +<p>The possibility to add multiple cell item iterations of one <code class="docutils literal"><span class="pre">Batch</span></code> definition +via that method has been reintroduced (it was working by accident in previous +versions with subtle side effects and then removed). Have fun!</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Batch.add_open_ends()</span></code></p> +<p>The method will now raise an <code class="docutils literal"><span class="pre">Exception</span></code> if called on a <code class="docutils literal"><span class="pre">Batch</span></code> that has +been added to a parent one via <code class="docutils literal"><span class="pre">as_addition()</span></code> to warn the user and prevent +errors at the build stage:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span>NotImplementedError: Cannot add open end DataFrames to as_addition()-Batches! +</pre></div> +</div> +</div> +<div class="section" id="sd-31-08-2017"> +<h2>sd (31/08/2017)<a class="headerlink" href="#sd-31-08-2017" title="Permalink to this headline">¶</a></h2> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.code_from_label(...,</span> <span class="pre">exact=True)</span></code></p> +<p>The new parameter <code class="docutils literal"><span class="pre">exact</span></code> is implemented. If <code class="docutils literal"><span class="pre">exact=True</span></code> codes are returned +whose belonging label is equal the included <code class="docutils literal"><span class="pre">text_label</span></code>. Otherwise the +method checks if the labels contain the included <code class="docutils literal"><span class="pre">text_label</span></code>.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.order(new_order=None,</span> <span class="pre">reposition=None)</span></code></p> +<p>This new method can be used to change the global order of the <code class="docutils literal"><span class="pre">DataSet</span></code> +variables. You can either pass a complete <code class="docutils literal"><span class="pre">new_order</span></code> list of variable names to +set the order or provide a list of dictionaries to move (multiple) variables +before a reference variable name. The order is reflected in the case data +<code class="docutils literal"><span class="pre">pd.DataFrame.columns</span></code> order and the meta <code class="docutils literal"><span class="pre">'data</span> <span class="pre">file'</span></code> <code class="docutils literal"><span class="pre">set</span></code> object’s items.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.dichotomize(name,</span> <span class="pre">value_texts=None,</span> <span class="pre">keep_variable_text=True,</span> <span class="pre">ignore=None,</span> <span class="pre">replace=False,</span> <span class="pre">text_key=None)</span></code></p> +<p>Use this to convert a <code class="docutils literal"><span class="pre">'delimited</span> <span class="pre">set'</span></code> variable into a set of binary coded +<code class="docutils literal"><span class="pre">'single'</span></code> variables. Variables will have the values 1/0 and by default use +<code class="docutils literal"><span class="pre">'Yes'</span></code> / <code class="docutils literal"><span class="pre">'No'</span></code> as the corresponding labels. Use the <code class="docutils literal"><span class="pre">value_texts</span></code> +parameter to apply custom labels.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">Batch.extend_x(ext_xks)</span></code></p> +<p>The new method enables an easy extension of <code class="docutils literal"><span class="pre">Batch.xks</span></code>. In <code class="docutils literal"><span class="pre">ext_xks</span></code> +included <code class="docutils literal"><span class="pre">str</span></code> are added at the end of <code class="docutils literal"><span class="pre">Batch.xks</span></code>. Values of included +<code class="docutils literal"><span class="pre">dict</span></code>s are positioned in front of the related key.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Batch.extend_y(ext_yks,</span> <span class="pre">...)</span></code></p> +<p>The parameter <code class="docutils literal"><span class="pre">ext_yks</span></code> now also takes <code class="docutils literal"><span class="pre">dict</span></code>s, which define the position +of the additional <code class="docutils literal"><span class="pre">yks</span></code>.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Batch.add_open_ends(...,</span> <span class="pre">replacements)</span></code></p> +<p>The new parameter <code class="docutils literal"><span class="pre">replacements</span></code> is implemented. The method loops over the +whole pd.DataFrame and replaces all keys of the included <code class="docutils literal"><span class="pre">dict</span></code> +with the belonging value.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Stack.add_stats(...,</span> <span class="pre">other_source)</span></code></p> +<p>Statistic views can now be added to delimited sets if <code class="docutils literal"><span class="pre">other_source</span></code> is used. +In this case <code class="docutils literal"><span class="pre">other_source</span></code> must be a single or numerical variable.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.validate(...,</span> <span class="pre">spss_limits=False)</span></code></p> +<p>The new parameter <code class="docutils literal"><span class="pre">spss_limits</span></code> is implemented. If <code class="docutils literal"><span class="pre">spss_limits=True</span></code>, the +validate output dataframe is extended by 3 columns which show if the SPSS label +limitations are satisfied.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">DataSet.convert()</span></code></p> +<p>A bug that prevented conversions from <code class="docutils literal"><span class="pre">single</span></code> to numeric types has been fixed.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">DataSet.add_meta()</span></code></p> +<p>A bug that prevented the creation of numerical arrays outside of <code class="docutils literal"><span class="pre">to.array()</span></code> +has been fixed. It is now possible to create <code class="docutils literal"><span class="pre">array</span></code> metadata without providing +category references.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">Stack.add_stats()</span></code></p> +<p>Checking the statistic views is skipped now if no single typed variables are +included even if a checking cluster is provided.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">Batch.copy()</span></code></p> +<p>Instead of using a deepcopy of the <code class="docutils literal"><span class="pre">Batch</span></code> instance, a new instance is created +and filled with the attributes of the initial one. Then the copied instance can +be used as additional <code class="docutils literal"><span class="pre">Batch</span></code>.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">qp.core.builds.powerpoint</span></code></p> +<p>Access to bar-chart series and colour-filling is now working for +different Powerpoint versions. Also a bug is fixed which came up in +<code class="docutils literal"><span class="pre">PowerPointpainter()</span></code> for variables which have fixed categories and whose +values are located in <code class="docutils literal"><span class="pre">lib</span></code>.</p> +</div> +<div class="section" id="sd-24-07-2017"> +<h2>sd (24/07/2017)<a class="headerlink" href="#sd-24-07-2017" title="Permalink to this headline">¶</a></h2> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">qp.set_option()</span></code></p> +<p>It is now possible to set library-wide settings registered in <code class="docutils literal"><span class="pre">qp.OPTIONS</span></code> +by providing the setting’s name (key) and the desired value. Currently supported +are:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">OPTIONS</span> <span class="o">=</span> <span class="p">{</span> + <span class="s1">'new_rules'</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> + <span class="s1">'new_chains'</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> + <span class="s1">'short_item_texts'</span><span class="p">:</span> <span class="kc">False</span> +<span class="p">}</span> +</pre></div> +</div> +<p>So for example, to work with the currently refactored <code class="docutils literal"><span class="pre">Chain</span></code> interim class +we can use <code class="docutils literal"><span class="pre">qp.set_options('new_chains',</span> <span class="pre">True)</span></code>.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">qp.Batch()</span></code></p> +<p>This is a new object aimed at defining and structuring aggregation and build +setups. Please see an <a class="reference internal" href="../lib_doc/batch/00_overview.html"><span class="doc">extensive overview here</span></a>.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">Stack.aggregate()</span></code> / <code class="docutils literal"><span class="pre">add_nets()</span></code> / <code class="docutils literal"><span class="pre">add_stats()</span></code> / <code class="docutils literal"><span class="pre">add_tests()</span></code> / …</p> +<p>Connected to the new <code class="docutils literal"><span class="pre">Batch</span></code> class, some new <code class="docutils literal"><span class="pre">Stack</span></code> methods to ease up +view creation have been added. You can <a class="reference internal" href="../lib_doc/engine/00_overview.html"><span class="doc">find the docs here</span></a>.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.populate()</span></code></p> +<p>Use this to create a <code class="docutils literal"><span class="pre">qp.Stack</span></code> from <code class="docutils literal"><span class="pre">Batch</span></code> definitions. This connects the +<code class="docutils literal"><span class="pre">Batch</span></code> and <code class="docutils literal"><span class="pre">Stack</span></code> objects; check out the <a class="reference internal" href="../lib_doc/batch/00_overview.html"><span class="doc">Batch</span></a> +and <a class="reference internal" href="../lib_doc/engine/00_overview.html"><span class="doc">Analysis & aggregation</span></a> docs.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.write_dimensions(path_mdd=None,</span> <span class="pre">path_ddf=None,</span> <span class="pre">text_key=None,</span> <span class="pre">mdm_lang='ENG',</span> <span class="pre">run=True,</span> <span class="pre">clean_up=True)</span></code></p> +<p>It is now possible to directly convert a <code class="docutils literal"><span class="pre">DataSet</span></code> into a Dimensions .ddf/.mdd +file pair (given SPSS Data Collection Base Professional is installed on your +machine). By default, files will be saved to the same location in that the +<code class="docutils literal"><span class="pre">DataSet</span></code> resides and keep its <code class="docutils literal"><span class="pre">text_key</span></code>.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.repair()</span></code></p> +<p>This new method can be used to try to fix common <code class="docutils literal"><span class="pre">DataSet</span></code> metadata problems +stemming from outdated versions, incorrect manual editing of the meta dictionary +or other inconsistencies. The method is checking and repairing following issues:</p> +<blockquote> +<div><ul class="simple"> +<li><code class="docutils literal"><span class="pre">'name'</span></code> is present for all variable metadata</li> +<li><code class="docutils literal"><span class="pre">'source'</span></code> and <code class="docutils literal"><span class="pre">'subtype'</span></code> references for array variables</li> +<li>correct <code class="docutils literal"><span class="pre">'lib'</span></code>-based <code class="docutils literal"><span class="pre">'values'</span></code> object for array variables</li> +<li><code class="docutils literal"><span class="pre">text</span> <span class="pre">key</span></code>-dependent <code class="docutils literal"><span class="pre">'x</span> <span class="pre">edits'</span></code> / <code class="docutils literal"><span class="pre">'y</span> <span class="pre">edits'</span></code> meta data</li> +<li><code class="docutils literal"><span class="pre">['data</span> <span class="pre">file']['items']</span></code> set entries exist in <code class="docutils literal"><span class="pre">'columns'</span></code> / <code class="docutils literal"><span class="pre">'masks'</span></code></li> +</ul> +</div></blockquote> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.subset(variables=None,</span> <span class="pre">from_set=None,</span> <span class="pre">inplace=False)</span></code></p> +<p>As a counterpart to <code class="docutils literal"><span class="pre">filter()</span></code>, <code class="docutils literal"><span class="pre">subset()</span></code> can be used to create a new +<code class="docutils literal"><span class="pre">DataSet</span></code> that contains only a selection of variables. The new variables +collection can be provided either as a list of names or by naming an already +existing set containing the desired variables.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.variables_from_set(setname)</span></code></p> +<p>Get the list of variables belonging to the passed set indicated by +<code class="docutils literal"><span class="pre">setname</span></code>.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.is_like_numeric(name)</span></code></p> +<p>A new method to test if all of a <code class="docutils literal"><span class="pre">string</span></code> variable’s values can be converted +to a numerical (<code class="docutils literal"><span class="pre">int</span></code> / <code class="docutils literal"><span class="pre">float</span></code>) type. Returns a boolean <code class="docutils literal"><span class="pre">True</span></code> / <code class="docutils literal"><span class="pre">False</span></code>.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.convert()</span></code></p> +<p>It is now possible to convert inplace from <code class="docutils literal"><span class="pre">string</span></code> to <code class="docutils literal"><span class="pre">int</span></code> / <code class="docutils literal"><span class="pre">float</span></code> if +the respective internal <code class="docutils literal"><span class="pre">is_like_numeric()</span></code> check identifies numeric-like values.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.from_components(...,</span> <span class="pre">reset=True)</span></code>, <code class="docutils literal"><span class="pre">DataSet.read_quantipy(...,</span> <span class="pre">reset=True)</span></code></p> +<p>Loaded <code class="docutils literal"><span class="pre">.json</span></code> metadata dictionaries will get cleaned now by default from any +user-defined, non-native objects inside the <code class="docutils literal"><span class="pre">'lib'</span></code> and <code class="docutils literal"><span class="pre">'sets'</span></code> +collections. Set <code class="docutils literal"><span class="pre">reset=False</span></code> to keep any extra entires (restoring the old +behaviour).</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.from_components(data_df,</span> <span class="pre">meta_dict=None,</span> <span class="pre">...)</span></code></p> +<p>It is now possible to create a <code class="docutils literal"><span class="pre">DataSet</span></code> instance by providing a <code class="docutils literal"><span class="pre">pd.DataFrame</span></code> +alone, without any accompanying meta data. While reading in the case data, the meta +component will be created by inferring the proper <code class="docutils literal"><span class="pre">Quantipy</span></code> variable types +from the <code class="docutils literal"><span class="pre">pandas</span></code> <code class="docutils literal"><span class="pre">dtype</span></code> information.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">Quantity.swap(var,</span> <span class="pre">...,</span> <span class="pre">update_axis_def=True)</span></code></p> +<p>It is now possible to <code class="docutils literal"><span class="pre">swap()</span></code> the <code class="docutils literal"><span class="pre">'x'</span></code> variable of an array based <code class="docutils literal"><span class="pre">Quantity</span></code>, +as long as the length oh the constructing <code class="docutils literal"><span class="pre">'items'</span></code> collection is identical. +In addition, the new parameter <code class="docutils literal"><span class="pre">update_axis_def</span></code> is now by default enforcing +an update of the axis defintions (<code class="docutils literal"><span class="pre">pd.DataFrame</span></code> column names, etc) while +previously the method was keeping the original index and column names. The old +behaviour can be restored by setting the parameter to <code class="docutils literal"><span class="pre">False</span></code>.</p> +<p><em>Array example</em>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">link</span> <span class="o">=</span> <span class="n">stack</span><span class="p">[</span><span class="n">name_data</span><span class="p">][</span><span class="s1">'no_filter'</span><span class="p">][</span><span class="s1">'q5'</span><span class="p">][</span><span class="s1">'@'</span><span class="p">]</span> +<span class="gp">>>> </span><span class="n">q</span> <span class="o">=</span> <span class="n">qp</span><span class="o">.</span><span class="n">Quantity</span><span class="p">(</span><span class="n">link</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">q</span><span class="o">.</span><span class="n">summarize</span><span class="p">()</span> +<span class="go">Array q5</span> +<span class="go">Questions q5_1 q5_2 q5_3 q5_4 q5_5 q5_6</span> +<span class="go">Question Values</span> +<span class="go">q5 All 8255.000000 8255.000000 8255.000000 8255.000000 8255.000000 8255.000000</span> +<span class="go"> mean 26.410297 22.260569 25.181466 39.842883 24.399758 28.972017</span> +<span class="go"> stddev 40.415559 38.060583 40.018463 46.012205 40.537497 41.903322</span> +<span class="go"> min 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000</span> +<span class="go"> 25% 3.000000 3.000000 3.000000 3.000000 1.000000 3.000000</span> +<span class="go"> median 5.000000 3.000000 3.000000 5.000000 3.000000 5.000000</span> +<span class="go"> 75% 5.000000 5.000000 5.000000 98.000000 5.000000 97.000000</span> +<span class="go"> max 98.000000 98.000000 98.000000 98.000000 98.000000 98.000000</span> +</pre></div> +</div> +<p><em>Updated axis definiton</em>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">q</span><span class="o">.</span><span class="n">swap</span><span class="p">(</span><span class="s1">'q7'</span><span class="p">,</span> <span class="n">update_axis_def</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">q</span><span class="o">.</span><span class="n">summarize</span><span class="p">()</span> +<span class="go">Array q7</span> +<span class="go">Questions q7_1 q7_2 q7_3 q7_4 q7_5 q7_6</span> +<span class="go">Question Values</span> +<span class="go">q7 All 1195.000000 1413.000000 3378.000000 35.000000 43.000000 36.000000</span> +<span class="go"> mean 5.782427 5.423213 5.795145 4.228571 4.558140 5.333333</span> +<span class="go"> stddev 2.277894 2.157226 2.366247 2.073442 2.322789 2.552310</span> +<span class="go"> min 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000</span> +<span class="go"> 25% 4.000000 4.000000 4.000000 3.000000 3.000000 3.000000</span> +<span class="go"> median 6.000000 6.000000 6.000000 4.000000 4.000000 6.000000</span> +<span class="go"> 75% 8.000000 7.000000 8.000000 6.000000 6.000000 7.750000</span> +<span class="go"> max 9.000000 9.000000 9.000000 8.000000 9.000000 9.000000</span> +</pre></div> +</div> +<p><em>Original axis definiton</em>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">q</span> <span class="o">=</span> <span class="n">qp</span><span class="o">.</span><span class="n">Quantity</span><span class="p">(</span><span class="n">link</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">q</span><span class="o">.</span><span class="n">swap</span><span class="p">(</span><span class="s1">'q7'</span><span class="p">,</span> <span class="n">update_axis_def</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">q</span><span class="o">.</span><span class="n">summarize</span><span class="p">()</span> +<span class="go">Array q5</span> +<span class="go">Questions q5_1 q5_2 q5_3 q5_4 q5_5 q5_6</span> +<span class="go">Question Values</span> +<span class="go">q5 All 1195.000000 1413.000000 3378.000000 35.000000 43.000000 36.000000</span> +<span class="go"> mean 5.782427 5.423213 5.795145 4.228571 4.558140 5.333333</span> +<span class="go"> stddev 2.277894 2.157226 2.366247 2.073442 2.322789 2.552310</span> +<span class="go"> min 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000</span> +<span class="go"> 25% 4.000000 4.000000 4.000000 3.000000 3.000000 3.000000</span> +<span class="go"> median 6.000000 6.000000 6.000000 4.000000 4.000000 6.000000</span> +<span class="go"> 75% 8.000000 7.000000 8.000000 6.000000 6.000000 7.750000</span> +<span class="go"> max 9.000000 9.000000 9.000000 8.000000 9.000000 9.000000</span> +</pre></div> +</div> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.merge_texts()</span></code></p> +<p>The method will now always overwrite existing <code class="docutils literal"><span class="pre">text_key</span></code> meta, which makes it +possible to merge <code class="docutils literal"><span class="pre">text</span></code>s from meta of the same <code class="docutils literal"><span class="pre">text_key</span></code> as the master +<code class="docutils literal"><span class="pre">DataSet</span></code>.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">DataSet.band()</span></code></p> +<p><code class="docutils literal"><span class="pre">band(new_name=None)</span></code>’s automatic name generation was incorrectly creating +new variables with the name <code class="docutils literal"><span class="pre">None_banded</span></code>. This is now fixed.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">DataSet.copy()</span></code></p> +<p>The method will now check if the name of the copy already exists in the +<code class="docutils literal"><span class="pre">DataSet</span></code> and drop the referenced variable if found to prevent +inconsistencies. Additionally, it is not longer possible to copy isolated +<code class="docutils literal"><span class="pre">array</span></code> items:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="s1">'q5_1'</span><span class="p">)</span> +<span class="go">NotImplementedError: Cannot make isolated copy of array item 'q5_1'. Please copy array variable 'q5' instead!</span> +</pre></div> +</div> +</div> +<div class="section" id="sd-08-06-2017"> +<h2>sd (08/06/2017)<a class="headerlink" href="#sd-08-06-2017" title="Permalink to this headline">¶</a></h2> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.extend_valid_tks()</span></code>, <code class="docutils literal"><span class="pre">DataSet.valid_tks</span></code></p> +<p><code class="docutils literal"><span class="pre">DataSet</span></code> has a new attribute <code class="docutils literal"><span class="pre">valid_tks</span></code> that contains a list of all valid +textkeys. All methods that take a textkey as parameter are checked against that +list.</p> +<p>If a datafile contains a special/ unusual textkey (for example <code class="docutils literal"><span class="pre">'id-ID'</span></code> or +<code class="docutils literal"><span class="pre">'zh-TW'</span></code>), the list can be extended with <code class="docutils literal"><span class="pre">DataSet.extend_valid_tks()</span></code>. +This extension can also be used to create a textkey for special conditions, +for example to create texts only for powerpoint outputs:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">extend_valid_tks</span><span class="p">(</span><span class="s1">'pptx'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">force_texts</span><span class="p">(</span><span class="s1">'pptx'</span><span class="p">,</span> <span class="s1">'en-GB'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">set_variable_text</span><span class="p">(</span><span class="s1">'gender'</span><span class="p">,</span><span class="s1">'Gender label for pptx'</span><span class="p">,</span> <span class="n">text_key</span><span class="o">=</span><span class="s1">'pptx'</span><span class="p">)</span> +</pre></div> +</div> +<hr class="docutils" /> +<p><strong>New</strong>: Equal error messages</p> +<p>All methods that use the parameters <code class="docutils literal"><span class="pre">name</span></code>/<code class="docutils literal"><span class="pre">var</span></code>, <code class="docutils literal"><span class="pre">text_key</span></code> or +<code class="docutils literal"><span class="pre">axis_edit</span></code>/ <code class="docutils literal"><span class="pre">axis</span></code> now have a decorator that checks the provided values. +The following shows a few examples for the new error messages:</p> +<p><code class="docutils literal"><span class="pre">name</span></code> & <code class="docutils literal"><span class="pre">var</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="s1">'name'</span> <span class="n">argument</span> <span class="k">for</span> <span class="n">meta</span><span class="p">()</span> <span class="n">must</span> <span class="n">be</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">'columns'</span><span class="p">,</span> <span class="s1">'masks'</span><span class="p">]</span><span class="o">.</span> +<span class="n">q1</span> <span class="ow">is</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">'columns'</span><span class="p">,</span> <span class="s1">'masks'</span><span class="p">]</span><span class="o">.</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">text_key</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span>'en-gb' is not a valid text_key! Supported are: ['en-GB', 'da-DK', 'fi-FI', 'nb-NO', 'sv-SE', 'de-DE'] +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">axis_edit</span></code> & <code class="docutils literal"><span class="pre">axis</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span>'xs' is not a valid axis! Supported are: ['x', 'y'] +</pre></div> +</div> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.repair_text_edits(text_key)</span></code></p> +<p>This new method can be used in trackers, that were drawn up in an older <code class="docutils literal"><span class="pre">Quantipy</span></code> +version. Text objects can be repaired if are not well prepared, for example if +it looks like this:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="p">{</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="s1">'some English text'</span><span class="p">,</span> + <span class="s1">'sv_SE'</span><span class="p">:</span> <span class="s1">'some Swedish text'</span><span class="p">,</span> + <span class="s1">'x edits'</span><span class="p">:</span> <span class="s1">'new text'</span><span class="p">}</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">DataSet.repair_text_edits()</span></code> loops over all text objects in the dataset and +matches the <code class="docutils literal"><span class="pre">x</span> <span class="pre">edits</span></code> and <code class="docutils literal"><span class="pre">y</span> <span class="pre">edits</span></code> texts to all included textkeys:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">repair_text_edits</span><span class="p">([</span><span class="s1">'en-GB'</span><span class="p">,</span> <span class="s1">'sv-SE'</span><span class="p">])</span> +<span class="go">{'en-GB': 'some English text',</span> +<span class="go"> 'sv_SE': 'some Swedish text',</span> +<span class="go"> 'x edits': {'en-GB': new text', 'sv-SE': 'new text'}}</span> +</pre></div> +</div> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.meta()</span></code>/ <code class="docutils literal"><span class="pre">.text()</span></code>/ <code class="docutils literal"><span class="pre">.values()</span></code>/ <code class="docutils literal"><span class="pre">.value_texts()</span></code>/ <code class="docutils literal"><span class="pre">.items()</span></code>/ <code class="docutils literal"><span class="pre">.item_texts()</span></code></p> +<p>All these methods now can take the parameters <code class="docutils literal"><span class="pre">text_key</span></code> and <code class="docutils literal"><span class="pre">axis_edit</span></code>. +The related text is taken from the meta information and shown in the output. +If a text key or axis edit is not included the text is returned as None.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.compare(dataset,</span> <span class="pre">variables=None,</span> <span class="pre">strict=False,</span> <span class="pre">text_key=None)</span></code></p> +<p>The method is totally updated, works more precise and contains a few new +features. Generally variables included in <code class="docutils literal"><span class="pre">dataset</span></code> are compared with +eponymous variables in the main <code class="docutils literal"><span class="pre">DataSet</span></code> instance. You can specify witch +<code class="docutils literal"><span class="pre">variables</span></code> should be compared, if question/ value texts should be compared +<code class="docutils literal"><span class="pre">strict</span></code> or not and for which <code class="docutils literal"><span class="pre">text_key</span></code>.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.validate(verbose=True)</span></code></p> +<p>A few new features are tested now and the output has changed. Set <code class="docutils literal"><span class="pre">verbose=True</span></code> +to see the definitions of the different error columns:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">name</span><span class="p">:</span> <span class="n">column</span><span class="o">/</span><span class="n">mask</span> <span class="n">name</span> <span class="ow">and</span> <span class="n">meta</span><span class="p">[</span><span class="n">collection</span><span class="p">][</span><span class="n">var</span><span class="p">][</span><span class="s1">'name'</span><span class="p">]</span> <span class="n">are</span> <span class="ow">not</span> <span class="n">identical</span> + +<span class="n">q_label</span><span class="p">:</span> <span class="n">text</span> <span class="nb">object</span> <span class="ow">is</span> <span class="n">badly</span> <span class="n">formated</span> <span class="ow">or</span> <span class="n">has</span> <span class="n">empty</span> <span class="n">text</span> <span class="n">mapping</span> + +<span class="n">values</span><span class="p">:</span> <span class="n">categorical</span> <span class="n">var</span> <span class="n">does</span> <span class="ow">not</span> <span class="n">contain</span> <span class="n">values</span><span class="p">,</span> <span class="n">value</span> <span class="n">text</span> <span class="ow">is</span> <span class="n">badly</span> +<span class="n">formated</span> <span class="ow">or</span> <span class="n">has</span> <span class="n">empty</span> <span class="n">text</span> <span class="n">mapping</span> + +<span class="n">textkeys</span><span class="p">:</span> <span class="n">dataset</span><span class="o">.</span><span class="n">text_key</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">included</span> <span class="ow">or</span> <span class="n">existing</span> <span class="n">tks</span> <span class="n">are</span> <span class="ow">not</span> +<span class="n">consistent</span> <span class="p">(</span><span class="n">also</span> <span class="k">for</span> <span class="n">parents</span><span class="p">)</span> + +<span class="n">source</span><span class="p">:</span> <span class="n">parents</span> <span class="ow">or</span> <span class="n">items</span> <span class="n">do</span> <span class="ow">not</span> <span class="n">exist</span> + +<span class="n">codes</span><span class="p">:</span> <span class="n">codes</span> <span class="ow">in</span> <span class="o">.</span><span class="n">data</span> <span class="n">are</span> <span class="ow">not</span> <span class="n">included</span> <span class="ow">in</span> <span class="o">.</span><span class="n">meta</span> +</pre></div> +</div> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.sorting()</span></code> / <code class="docutils literal"><span class="pre">.slicing()</span></code> / <code class="docutils literal"><span class="pre">.hiding()</span></code></p> +<p>These methods will now also work on lists of variable names.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.set_variable_text()</span></code>, <code class="docutils literal"><span class="pre">Dataset.set_item_texts()</span></code></p> +<p>If these methods are applied to an array item, the new variable text is also +included in the meta information of the parent array. The same works also the +other way around, if an array text is set, then the array item texts are modified.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.__init__(self,</span> <span class="pre">name,</span> <span class="pre">dimensions_comp=True)</span></code></p> +<p>A few new features are included to handle data coming from Crunch. While +initializing a new <code class="docutils literal"><span class="pre">DataSet</span></code> instance dimensions compatibility can be set to +False. In the custom template use <code class="docutils literal"><span class="pre">t.get_qp_dataset(name,</span> <span class="pre">dim_comp=False)</span></code> +in the load cells.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">DataSet.hmerge()</span></code></p> +<p>If <code class="docutils literal"><span class="pre">right_on</span></code> and <code class="docutils literal"><span class="pre">left_on</span></code> are used and <code class="docutils literal"><span class="pre">right_on</span></code> is also included in +the main file, it is not overwritten any more.</p> +</div> +<div class="section" id="sd-17-05-2017"> +<h2>sd (17/05/2017)<a class="headerlink" href="#sd-17-05-2017" title="Permalink to this headline">¶</a></h2> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.set_variable_text(...,</span> <span class="pre">axis_edit=None)</span></code>, <code class="docutils literal"><span class="pre">DataSet.set_value_texts(...,</span> <span class="pre">axis_edit=False)</span></code></p> +<p>The new <code class="docutils literal"><span class="pre">axis_edit</span></code> argument can be used with one of <code class="docutils literal"><span class="pre">'x'</span></code>, <code class="docutils literal"><span class="pre">'y'</span></code> or <code class="docutils literal"><span class="pre">['x',</span> <span class="pre">'y']</span></code> to instruct a text metadata change that will only be visible in build exports.</p> +<div class="admonition warning"> +<p class="first admonition-title">Warning</p> +<p class="last">In a future version <code class="docutils literal"><span class="pre">set_col_text_edit()</span></code> and <code class="docutils literal"><span class="pre">set_val_text_text()</span></code> will +be removed! The identical functionality is provided via this <code class="docutils literal"><span class="pre">axis_edit</span></code> parameter.</p> +</div> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.replace_texts(...,</span> <span class="pre">text_key=None)</span></code></p> +<p>The method loops over all meta text objects and replaces unwanted strings. +It is now possible to perform the replacement only for specified <code class="docutils literal"><span class="pre">text_key</span></code>s. +If <code class="docutils literal"><span class="pre">text_key=None</span></code> the method replaces the strings for all <code class="docutils literal"><span class="pre">text_key</span></code>s.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.force_texts(copy_to=None,</span> <span class="pre">copy_from=None,</span> <span class="pre">update_existing=False)</span></code></p> +<p>The method is now only able to force texts for all meta text objects (for +single variables use the methods <code class="docutils literal"><span class="pre">set_variable_text()</span></code> and +<code class="docutils literal"><span class="pre">set_value_texts()</span></code>).</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">DataSet.copy()</span></code></p> +<p>Copied variables get the tag <code class="docutils literal"><span class="pre">created</span></code> and can be listed with +<code class="docutils literal"><span class="pre">t.list_variables(dataset,</span> <span class="pre">'created')</span></code>.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">DataSet.hmerge()</span></code>, <code class="docutils literal"><span class="pre">DataSet.vmerge()</span></code></p> +<p>Array meta information in merged datafiles is now updated correctly.</p> +</div> +<div class="section" id="sd-04-05-2017"> +<h2>sd (04/05/2017)<a class="headerlink" href="#sd-04-05-2017" title="Permalink to this headline">¶</a></h2> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.var_exists()</span></code></p> +<p>Returns True if the input variable/ list of variables are included in the +<code class="docutils literal"><span class="pre">DataSet</span></code> instance, otherwise False.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.remove_html()</span></code>, <code class="docutils literal"><span class="pre">DataSet.replace_texts(replace)</span></code></p> +<p>The <code class="docutils literal"><span class="pre">DataSet</span></code> method <code class="docutils literal"><span class="pre">clean_texts()</span></code> has been removed and split into two +methods to make usage more clear: <code class="docutils literal"><span class="pre">remove_html()</span></code> will strip all <code class="docutils literal"><span class="pre">text</span></code> +metadata objects from any html and formatting tags. <code class="docutils literal"><span class="pre">replace_texts()</span></code> will +use a <code class="docutils literal"><span class="pre">dict</span></code> mapping of old to new <code class="docutils literal"><span class="pre">str</span></code> terms to change the matching +<code class="docutils literal"><span class="pre">text</span></code> throughout the <code class="docutils literal"><span class="pre">DataSet</span></code> metadata.</p> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.item_no(name)</span></code></p> +<p>This method will return the positional index number of an array item, e.g.:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">item_no</span><span class="p">(</span><span class="s1">'Q4A[</span><span class="si">{q4a_1}</span><span class="s1">].Q4A_grid'</span><span class="p">)</span> +<span class="go">1</span> +</pre></div> +</div> +<hr class="docutils" /> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">QuantipyViews</span></code>: <code class="docutils literal"><span class="pre">counts_cumsum</span></code>, <code class="docutils literal"><span class="pre">c%_cumsum</span></code></p> +<p>These two new views contain frequencies with cumulative sums which are computed +over the x-axis.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.text(name,</span> <span class="pre">shorten=True)</span></code></p> +<p>The new parameter <code class="docutils literal"><span class="pre">shorten</span></code> is now controlling if the variable <code class="docutils literal"><span class="pre">text</span></code> metadata +of array masks will be reported in short format, i.e. without the corresponding +mask label text. This is now also the default behaviour.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.to_array()</span></code></p> +<p>Created mask meta information now also contains keys <code class="docutils literal"><span class="pre">parent</span></code> and <code class="docutils literal"><span class="pre">subtype</span></code>. +Variable names are compatible with crunch and dimensions meta:</p> +<p>Example in Dimensions modus:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">to_array</span><span class="p">(</span><span class="s1">'Q11'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'Q1'</span><span class="p">,</span> <span class="s1">'Q2'</span><span class="p">,</span> <span class="s1">'Q3'</span><span class="p">,</span> <span class="s1">'Q4'</span><span class="p">,</span> <span class="s1">'Q5'</span><span class="p">],</span> <span class="s1">'label'</span><span class="p">)</span> +</pre></div> +</div> +<p>The new grid is named <code class="docutils literal"><span class="pre">'Q11.Q11_grid'</span></code> and the source/column variables are +<code class="docutils literal"><span class="pre">'Q11[{Q1}].-Q11_grid'</span></code> - <code class="docutils literal"><span class="pre">'Q11[{Q5}].-Q11_grid'</span></code>.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></p> +<p>Meta is now Crunch and Dimensions compatible. Also mask meta information are updated.</p> +</div> +<div class="section" id="sd-24-04-2017"> +<h2>sd (24/04/2017)<a class="headerlink" href="#sd-24-04-2017" title="Permalink to this headline">¶</a></h2> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.hiding(...,</span> <span class="pre">hide_values=True)</span></code></p> +<p>The new parameter <code class="docutils literal"><span class="pre">hide_values</span></code> is only necessary if the input variable is a +mask. If <code class="docutils literal"><span class="pre">False</span></code>, mask items are hidden, if <code class="docutils literal"><span class="pre">True</span></code> mask values are hidden +for all mask items and for array summary sheets.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">DataSet.set_col_text_edit(name)</span></code></p> +<p>If the input variable is an array item, the new column text is also added to +<code class="docutils literal"><span class="pre">meta['mask'][name]['items]</span></code>.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">DataSet.drop(name,</span> <span class="pre">ignore_items=False)</span></code></p> +<p>If a mask is dropped, but the items are kept, all items are handled now as +individual variables and their meta information is not stored in <code class="docutils literal"><span class="pre">meta['lib']</span></code> +anymore.</p> +</div> +<div class="section" id="sd-06-04-2017"> +<h2>sd (06/04/2017)<a class="headerlink" href="#sd-06-04-2017" title="Permalink to this headline">¶</a></h2> +<p>Only small adjustments.</p> +</div> +<div class="section" id="sd-29-03-2017"> +<h2>sd (29/03/2017)<a class="headerlink" href="#sd-29-03-2017" title="Permalink to this headline">¶</a></h2> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">DataSet.codes_in_data(name)</span></code></p> +<p>This method returns a list of codes that exist in the data of a variable. This +information can be used for more complex recodes, for example copying a variable, +but keeping only all categories with more than 50 ratings, e.g.:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">valid_code</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">codes_in_data</span><span class="p">(</span><span class="s1">'varname'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">keep_code</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">valid_code</span> <span class="k">if</span> <span class="n">dataset</span><span class="p">[</span><span class="s1">'varname'</span><span class="p">]</span><span class="o">.</span><span class="n">value_counts</span><span class="p">()[</span><span class="n">x</span><span class="p">]</span> <span class="o">></span> <span class="mi">49</span><span class="p">]</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="s1">'varname'</span><span class="p">,</span> <span class="s1">'rc'</span><span class="p">,</span> <span class="n">copy_only</span><span class="o">=</span><span class="n">keep_code</span><span class="p">)</span> +</pre></div> +</div> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.copy(...,</span> <span class="pre">copy_not=None)</span></code></p> +<p>The new parameter <code class="docutils literal"><span class="pre">copy_not</span></code> takes a list of codes that should be ignored +for the copied version of the provided variable. The metadata of the copy will +be reduced as well.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.code_count()</span></code></p> +<p>This method is now alligned with <code class="docutils literal"><span class="pre">any()</span></code> and <code class="docutils literal"><span class="pre">all()</span></code> in that it can be used +on <code class="docutils literal"><span class="pre">'array'</span></code> variables as well. In such a case, the resulting <code class="docutils literal"><span class="pre">pandas.Series</span></code> +is reporting the number of answer codes found across all items per case data +row, i.e.:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">code_count</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">code_count</span><span class="p">(</span><span class="s1">'Q4A.Q4A_grid'</span><span class="p">,</span> <span class="n">count_only</span><span class="o">=</span><span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">])</span> +<span class="gp">>>> </span><span class="n">check</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">concat</span><span class="p">([</span><span class="n">dataset</span><span class="p">[</span><span class="s1">'Q4A.Q4A_grid'</span><span class="p">],</span> <span class="n">code_count</span><span class="p">],</span> <span class="n">axis</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">check</span><span class="o">.</span><span class="n">head</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span> +<span class="go"> Q4A[{q4a_1}].Q4A_grid Q4A[{q4a_2}].Q4A_grid Q4A[{q4a_3}].Q4A_grid 0</span> +<span class="go">0 3.0 3.0 NaN 2</span> +<span class="go">1 NaN NaN NaN 0</span> +<span class="go">2 3.0 3.0 4.0 3</span> +<span class="go">3 5.0 4.0 2.0 1</span> +<span class="go">4 4.0 4.0 4.0 3</span> +<span class="go">5 4.0 5.0 4.0 2</span> +<span class="go">6 3.0 3.0 3.0 3</span> +<span class="go">7 4.0 4.0 4.0 3</span> +<span class="go">8 6.0 6.0 6.0 0</span> +<span class="go">9 4.0 5.0 5.0 1</span> +</pre></div> +</div> +</div> +<hr class="docutils" /> +<div class="section" id="sd-20-03-2017"> +<h2>sd (20/03/2017)<a class="headerlink" href="#sd-20-03-2017" title="Permalink to this headline">¶</a></h2> +<p><strong>New</strong>: <code class="docutils literal"><span class="pre">qp.DataSet(dimensions_comp=True)</span></code></p> +<p>The <code class="docutils literal"><span class="pre">DataSet</span></code> class can now be explicitly run in a Dimensions compatibility +mode to control the naming conventions of <code class="docutils literal"><span class="pre">array</span></code> variables (“grids”). This +is also the default behaviour for now. This comes with a few changes related to +meta creation and variable access using <code class="docutils literal"><span class="pre">DataSet</span></code> methods. Please see a brief +case study on this topic <a class="reference internal" href="how_to_snippets/dimensions_comp.html"><span class="doc">here</span></a>.</p> +<hr class="docutils" /> +<p><strong>New</strong>: enriched <code class="docutils literal"><span class="pre">items</span></code> / <code class="docutils literal"><span class="pre">masks</span></code> meta data</p> +<p><code class="docutils literal"><span class="pre">masks</span></code> will now also store the <code class="docutils literal"><span class="pre">subtype</span></code> (<code class="docutils literal"><span class="pre">single</span></code>, <code class="docutils literal"><span class="pre">delimited</span> <span class="pre">set</span></code>, etc.) +while <code class="docutils literal"><span class="pre">items</span></code> elements will now contain a reference to the defining <code class="docutils literal"><span class="pre">masks</span></code> +entrie(s) in a new <code class="docutils literal"><span class="pre">parent</span></code> object.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.weight(...,</span> <span class="pre">subset=None)</span></code></p> +<p>Filters the dataset by giving a Quantipy complex logic expression and weights +only the remaining subset.</p> +<hr class="docutils" /> +<p><strong>Update</strong>: Defining categorical <code class="docutils literal"><span class="pre">values</span></code> meta and <code class="docutils literal"><span class="pre">array</span></code> items</p> +<p>Both <code class="docutils literal"><span class="pre">values</span></code> and <code class="docutils literal"><span class="pre">items</span></code> can now be created in three different ways when +working with the <code class="docutils literal"><span class="pre">DataSet</span></code> methods <code class="docutils literal"><span class="pre">add_meta()</span></code>, <code class="docutils literal"><span class="pre">extend_values()</span></code> and +<code class="docutils literal"><span class="pre">derive()</span></code>: (1) Tuples that map element code to label, (2) only labels or (3) +only element codes. Please see quick guide on that <a class="reference internal" href="how_to_snippets/create_categorical_meta.html"><span class="doc">here</span></a></p> +</div> +<div class="section" id="sd-07-03-2017"> +<h2>sd (07/03/2017)<a class="headerlink" href="#sd-07-03-2017" title="Permalink to this headline">¶</a></h2> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.code_count(...,</span> <span class="pre">count_not=None)</span></code></p> +<p>The new parameter <code class="docutils literal"><span class="pre">count_not</span></code> can be used to restrict the set of codes feeding +into the resulting <code class="docutils literal"><span class="pre">pd.Series</span></code> by exclusion (while <code class="docutils literal"><span class="pre">count_only</span></code> restricts +by inclusion).</p> +<hr class="docutils" /> +<p><strong>Update</strong>: <code class="docutils literal"><span class="pre">DataSet.copy(...,</span> <span class="pre">copy_only=None)</span></code></p> +<p>The new parameter <code class="docutils literal"><span class="pre">copy_only</span></code> takes a list of codes that should be included +for the copied version of the provided variable, all others will be ignored +and the metadata of the copy will be reduced as well.</p> +<hr class="docutils" /> +<p><strong>Bugfix</strong>: <code class="docutils literal"><span class="pre">DataSet.band()</span></code></p> +<p>There was a bug that was causing the method to crash for negative values. It is +now possible to create negative single value bands, while negative ranges +(lower and/or upper bound < 0) will raise a <code class="docutils literal"><span class="pre">ValueError</span></code>.</p> +</div> +<hr class="docutils" /> +<div class="section" id="sd-24-02-2017"> +<h2>sd (24/02/2017)<a class="headerlink" href="#sd-24-02-2017" title="Permalink to this headline">¶</a></h2> +<ul class="simple"> +<li>Some minor bugfixes and updates. Please use latest version.</li> +</ul> +</div> +<hr class="docutils" /> +<div class="section" id="sd-16-02-2017"> +<h2>sd (16/02/2017)<a class="headerlink" href="#sd-16-02-2017" title="Permalink to this headline">¶</a></h2> +<p><strong>New:</strong> <code class="docutils literal"><span class="pre">DataSet.derotate(levels,</span> <span class="pre">mapper,</span> <span class="pre">other=None,</span> <span class="pre">unique_key='identity',</span> <span class="pre">dropna=True)</span></code></p> +<p>Create a derotated (“levelled”, responses-to-cases) <code class="docutils literal"><span class="pre">DataSet</span></code> instance by +defining level variables, looped variables and other (simple) variables that +should be added.</p> +<p>View more information on the topic <a class="reference internal" href="how_to_snippets/derotate.html"><span class="doc">here</span></a>.</p> +<hr class="docutils" /> +<p><strong>New:</strong> <code class="docutils literal"><span class="pre">DataSet.to_array(name,</span> <span class="pre">variables,</span> <span class="pre">label)</span></code></p> +<p>Combine <code class="docutils literal"><span class="pre">column</span></code> variables with identical <code class="docutils literal"><span class="pre">values</span></code> objects to an <code class="docutils literal"><span class="pre">array</span></code> +incl. all required <code class="docutils literal"><span class="pre">meta['masks']</span></code> information.</p> +<hr class="docutils" /> +<p><strong>Update:</strong> <code class="docutils literal"><span class="pre">DataSet.interlock(...,</span> <span class="pre">variables)</span></code></p> +<p>It is now possible to add <code class="docutils literal"><span class="pre">dict</span></code>s to <code class="docutils literal"><span class="pre">variables</span></code>. In these <code class="docutils literal"><span class="pre">dict</span></code>s a +<code class="docutils literal"><span class="pre">derive()</span></code>-like mapper can be included which will then create a temporary +variable for the interlocked result. Example:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">variables</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'gender'</span><span class="p">,</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'agegrp'</span><span class="p">:</span> <span class="p">[(</span><span class="mi">1</span><span class="p">,</span> <span class="s1">'18-34'</span><span class="p">,</span> <span class="p">{</span><span class="s1">'age'</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'18-34'</span><span class="p">)}),</span> +<span class="gp">... </span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="s1">'35-54'</span><span class="p">,</span> <span class="p">{</span><span class="s1">'age'</span><span class="p">:</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'35-54'</span><span class="p">)}),</span> +<span class="gp">... </span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="s1">'55+'</span><span class="p">,</span> <span class="p">{</span><span class="s1">'age'</span><span class="p">:</span> <span class="n">is_ge</span><span class="p">(</span><span class="mi">55</span><span class="p">)})]},</span> +<span class="gp">... </span> <span class="s1">'region'</span><span class="p">]</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">interlock</span><span class="p">(</span><span class="s1">'new_var'</span><span class="p">,</span> <span class="s1">'label'</span><span class="p">,</span> <span class="n">variables</span><span class="p">)</span> +</pre></div> +</div> +</div> +<hr class="docutils" /> +<div class="section" id="sd-04-01-2017"> +<h2>sd (04/01/2017)<a class="headerlink" href="#sd-04-01-2017" title="Permalink to this headline">¶</a></h2> +<p><strong>New:</strong> <code class="docutils literal"><span class="pre">DataSet.flatten(name,</span> <span class="pre">codes,</span> <span class="pre">new_name=None,</span> <span class="pre">text_key=None)</span></code></p> +<p>Creates a new <code class="docutils literal"><span class="pre">delimited</span> <span class="pre">set</span></code> variable that groups <code class="docutils literal"><span class="pre">grid</span> <span class="pre">item</span></code> answers to +categories. The <code class="docutils literal"><span class="pre">items</span></code> become <code class="docutils literal"><span class="pre">values</span></code> of the new variable. If an +<code class="docutils literal"><span class="pre">item</span></code> contains one of the <code class="docutils literal"><span class="pre">codes</span></code> it will be counted towards the categorical +case data of the new variable.</p> +<hr class="docutils" /> +<p><strong>New:</strong> <code class="docutils literal"><span class="pre">DataSet.uncode(target,</span> <span class="pre">mapper,</span> <span class="pre">default=None,</span> <span class="pre">intersect=None,</span> <span class="pre">inplace=True)</span></code></p> +<p>Remove codes from the <code class="docutils literal"><span class="pre">target</span></code> variable’s data component if a logical +condition is satisfied.</p> +<hr class="docutils" /> +<p><strong>New:</strong> <code class="docutils literal"><span class="pre">DataSet.text(var,</span> <span class="pre">text_key=None)</span></code></p> +<p>Returns the question text label (per <code class="docutils literal"><span class="pre">text_key</span></code>) of a variable.</p> +<hr class="docutils" /> +<p><strong>New:</strong> <code class="docutils literal"><span class="pre">DataSet.unroll(varlist,</span> <span class="pre">keep=None,</span> <span class="pre">both=None)</span></code></p> +<p>Replaces <code class="docutils literal"><span class="pre">masks</span></code> names inside <code class="docutils literal"><span class="pre">varlist</span></code> with their <code class="docutils literal"><span class="pre">items</span></code>. Optionally, +individual <code class="docutils literal"><span class="pre">masks</span></code> can be excluded or kept inside the list.</p> +<hr class="docutils" /> +<p><strong>New:</strong> <code class="docutils literal"><span class="pre">DataSet.from_stack(stack,</span> <span class="pre">datakey=None)</span></code></p> +<p>Create a <code class="docutils literal"><span class="pre">quantipy.DataSet</span></code> from the <code class="docutils literal"><span class="pre">meta</span></code>, <code class="docutils literal"><span class="pre">data</span></code>, <code class="docutils literal"><span class="pre">data_key</span></code> and +<code class="docutils literal"><span class="pre">filter</span></code> definition of a <code class="docutils literal"><span class="pre">quantipy.Stack</span></code> instance.</p> +</div> +<hr class="docutils" /> +<div class="section" id="sd-8-12-2016"> +<h2>sd (8/12/2016)<a class="headerlink" href="#sd-8-12-2016" title="Permalink to this headline">¶</a></h2> +<p><strong>New:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.from_excel(path_xlsx,</span> <span class="pre">merge=True,</span> <span class="pre">unique_key='identity')</span></code></p> +<p>Returns a new <code class="docutils literal"><span class="pre">DataSet</span></code> instance with <code class="docutils literal"><span class="pre">data</span></code> from <code class="docutils literal"><span class="pre">excel</span></code>. The <code class="docutils literal"><span class="pre">meta</span></code> +for all variables contains <code class="docutils literal"><span class="pre">type='int'</span></code>.</p> +<p>Example: <code class="docutils literal"><span class="pre">new_ds</span> <span class="pre">=</span> <span class="pre">dataset.from_excel(path,</span> <span class="pre">True,</span> <span class="pre">'identity')</span></code></p> +<p>The function is able to modify <code class="docutils literal"><span class="pre">dataset</span></code> inplace by merging <code class="docutils literal"><span class="pre">new_ds</span></code> on +<code class="docutils literal"><span class="pre">identity</span></code>.</p> +<hr class="docutils" /> +<p><strong>Update:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.copy(...,</span> <span class="pre">slicer=None)</span></code></p> +<p>It is now possible to filter the data that statisfies the logical condition +provided in the <code class="docutils literal"><span class="pre">slicer</span></code>. +Example:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="s1">'q1'</span><span class="p">,</span> <span class="s1">'rec'</span><span class="p">,</span> <span class="kc">True</span><span class="p">,</span> <span class="p">{</span><span class="s1">'q1'</span><span class="p">:</span> <span class="n">not_any</span><span class="p">([</span><span class="mi">99</span><span class="p">])})</span> +</pre></div> +</div> +</div> +<hr class="docutils" /> +<div class="section" id="sd-23-11-2016"> +<h2>sd (23/11/2016)<a class="headerlink" href="#sd-23-11-2016" title="Permalink to this headline">¶</a></h2> +<p><strong>Update:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.rename(name,</span> <span class="pre">new_name=None,</span> <span class="pre">array_item=None)</span></code></p> +<p>The function is able to rename <code class="docutils literal"><span class="pre">columns</span></code>, <code class="docutils literal"><span class="pre">masks</span></code> or <code class="docutils literal"><span class="pre">mask</span> <span class="pre">items</span></code>. +<code class="docutils literal"><span class="pre">maks</span> <span class="pre">items</span></code> are changed by position.</p> +<hr class="docutils" /> +<p><strong>Update:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.categorize(...,</span> <span class="pre">categorized_name=None)</span></code></p> +<p>Provide a custom name string for <code class="docutils literal"><span class="pre">categorized_name</span></code> will change the default +name of the categorized variable from <code class="docutils literal"><span class="pre">OLD_NAME#</span></code> to the passed string.</p> +</div> +<hr class="docutils" /> +<div class="section" id="sd-16-11-2016"> +<h2>sd (16/11/2016)<a class="headerlink" href="#sd-16-11-2016" title="Permalink to this headline">¶</a></h2> +<p><strong>New:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.check_dupe(name='identity')</span></code></p> +<p>Returns a list with duplicated values for the variable provided via <code class="docutils literal"><span class="pre">name</span></code>. +Identifies for example duplicated identities.</p> +<hr class="docutils" /> +<p><strong>New:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.start_meta(text_key=None)</span></code></p> +<p>Creates an empty QP meta data document blueprint to add variable definitions to.</p> +<hr class="docutils" /> +<p><strong>Update:</strong></p> +<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">DataSet</span><span class="o">.</span><span class="n">create_set</span><span class="p">(</span><span class="n">setname</span><span class="o">=</span><span class="s1">'new_set'</span><span class="p">,</span> <span class="n">based_on</span><span class="o">=</span><span class="s1">'data file'</span><span class="p">,</span> <span class="n">included</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> +<span class="o">...</span> <span class="n">excluded</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">strings</span><span class="o">=</span><span class="s1">'keep'</span><span class="p">,</span> <span class="n">arrays</span><span class="o">=</span><span class="s1">'both'</span><span class="p">,</span> <span class="n">replace</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> +<span class="o">...</span> <span class="n">overwrite</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span> +</pre></div> +</div> +<p>Add a new <code class="docutils literal"><span class="pre">set</span></code> to the <code class="docutils literal"><span class="pre">meta['sets']</span></code> object. Variables from an existing +<code class="docutils literal"><span class="pre">set</span></code> (<code class="docutils literal"><span class="pre">based_on</span></code>) can be <code class="docutils literal"><span class="pre">included</span></code> to <code class="docutils literal"><span class="pre">new_set</span></code> or varibles can be +<code class="docutils literal"><span class="pre">excluded</span></code> from <code class="docutils literal"><span class="pre">based_on</span></code> with customized lists of variables. +Control <code class="docutils literal"><span class="pre">string</span></code> variables and <code class="docutils literal"><span class="pre">masks</span></code> with the <code class="docutils literal"><span class="pre">kwargs</span></code> <code class="docutils literal"><span class="pre">strings</span></code> and +<code class="docutils literal"><span class="pre">arrays</span></code>. <code class="docutils literal"><span class="pre">replace</span></code> single variables in <code class="docutils literal"><span class="pre">new_set</span></code> with a <code class="docutils literal"><span class="pre">dict</span></code> .</p> +<hr class="docutils" /> +<p><strong>Update:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.from_components(...,</span> <span class="pre">text_key=None)</span></code></p> +<p>Will now accept a <code class="docutils literal"><span class="pre">text_key</span></code> in the method call. If querying a <code class="docutils literal"><span class="pre">text_key</span></code> +from the meta component fails, the method will no longer crash, but raise a +<code class="docutils literal"><span class="pre">warning</span></code> and set the <code class="docutils literal"><span class="pre">text_key</span></code> to <code class="docutils literal"><span class="pre">None</span></code>.</p> +<hr class="docutils" /> +<p><strong>Update:</strong></p> +<div class="line-block"> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.as_float()</span></code></div> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.as_int()</span></code></div> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.as_single()</span></code></div> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.as_delimited_set()</span></code></div> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.as_string()</span></code></div> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.band_numerical()</span></code></div> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.derive_categorical()</span></code></div> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.set_mask_text()</span></code></div> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.set_column_text()</span></code></div> +</div> +<p>These methods will now print a <code class="docutils literal"><span class="pre">UserWarning</span></code> to prepare for the soon to +come removal of them.</p> +<hr class="docutils" /> +<p><strong>Bugfix:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.__setitem__()</span></code></p> +<p>Trying to set <code class="docutils literal"><span class="pre">np.NaN</span></code> was failing the test against meta data for categorical +variables and was raising a <code class="docutils literal"><span class="pre">ValueError</span></code> then. This is fixed now.</p> +</div> +<hr class="docutils" /> +<div class="section" id="sd-11-11-2016"> +<h2>sd (11/11/2016)<a class="headerlink" href="#sd-11-11-2016" title="Permalink to this headline">¶</a></h2> +<p><strong>New:</strong></p> +<div class="line-block"> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.columns</span></code></div> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.masks</span></code></div> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.sets</span></code></div> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.singles</span></code></div> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.delimited_sets</span></code></div> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.ints</span></code></div> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.floats</span></code></div> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.dates</span></code></div> +<div class="line"><code class="docutils literal"><span class="pre">DataSet.strings</span></code></div> +</div> +<p>New <code class="docutils literal"><span class="pre">DataSet</span></code> instance attributes to quickly return the list of <code class="docutils literal"><span class="pre">columns</span></code>, +<code class="docutils literal"><span class="pre">masks</span></code> and <code class="docutils literal"><span class="pre">sets</span></code> objects from the meta or query the variables by +<code class="docutils literal"><span class="pre">type</span></code>. Use this to check for variables, iteration, inspection, ect.</p> +<hr class="docutils" /> +<p><strong>New:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.categorize(name)</span></code></p> +<p>Create a categorized version of <code class="docutils literal"><span class="pre">int/string/date</span></code> variables. New variables +will be named as per <code class="docutils literal"><span class="pre">OLD_NAME#</span></code></p> +<hr class="docutils" /> +<p><strong>New:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.convert(name,</span> <span class="pre">to)</span></code></p> +<p>Wraps the individual <code class="docutils literal"><span class="pre">as_TYPE()</span></code> conversion methods. <code class="docutils literal"><span class="pre">to</span></code> must be one of +<code class="docutils literal"><span class="pre">'int',</span> <span class="pre">'float',</span> <span class="pre">'string',</span> <span class="pre">'single',</span> <span class="pre">'delimited</span> <span class="pre">set'</span></code>.</p> +<hr class="docutils" /> +<p><strong>New:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.as_string(name)</span></code></p> +<p>Only for completeness: Use <code class="docutils literal"><span class="pre">DataSet.convert(name,</span> <span class="pre">to='string')</span></code> instead.</p> +<p>Converts <code class="docutils literal"><span class="pre">int/float/single/date</span></code> typed variables into a <code class="docutils literal"><span class="pre">string</span></code> and +removes all categorical metadata.</p> +<hr class="docutils" /> +<p><strong>Update:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.add_meta()</span></code></p> +<p>Can now add <code class="docutils literal"><span class="pre">date</span></code> and <code class="docutils literal"><span class="pre">text</span></code> type meta data.</p> +<hr class="docutils" /> +<p><strong>Bugfix:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.vmerge()</span></code></p> +<p>If <code class="docutils literal"><span class="pre">masks</span></code> in the right <code class="docutils literal"><span class="pre">dataset</span></code>, that also exist in the left <code class="docutils literal"><span class="pre">dataset</span></code>, +have new <code class="docutils literal"><span class="pre">items</span></code> or <code class="docutils literal"><span class="pre">values</span></code>, they are added to <code class="docutils literal"><span class="pre">meta['masks']</span></code>, +<code class="docutils literal"><span class="pre">meta['lib']</span></code> and <code class="docutils literal"><span class="pre">meta['sets']</span></code>.</p> +</div> +<hr class="docutils" /> +<div class="section" id="sd-09-11-2016"> +<h2>sd (09/11/2016)<a class="headerlink" href="#sd-09-11-2016" title="Permalink to this headline">¶</a></h2> +<p><strong>New:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.as_float(name)</span></code></p> +<p>Converts <code class="docutils literal"><span class="pre">int/single</span></code> typed variables into a <code class="docutils literal"><span class="pre">float</span></code> and removes +all categorical metadata.</p> +<hr class="docutils" /> +<p><strong>New:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.as_int(name)</span></code></p> +<p>Converts <code class="docutils literal"><span class="pre">single</span></code> typed variables into a <code class="docutils literal"><span class="pre">int</span></code> and removes +all categorical metadata.</p> +<hr class="docutils" /> +<p><strong>New:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.as_single(name)</span></code></p> +<p>Converts <code class="docutils literal"><span class="pre">int</span></code> typed variables into a <code class="docutils literal"><span class="pre">single</span></code> and adds numeric values as +categorical metadata.</p> +<hr class="docutils" /> +<p><strong>New:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.create_set(name,</span> <span class="pre">variables,</span> <span class="pre">blacklist=None)</span></code></p> +<p>Adds a new <code class="docutils literal"><span class="pre">set</span></code> to <code class="docutils literal"><span class="pre">meta['sets']</span></code> object. Create easily <code class="docutils literal"><span class="pre">sets</span></code> from +other <code class="docutils literal"><span class="pre">sets</span></code> while using customised <code class="docutils literal"><span class="pre">blacklist</span></code>.</p> +<hr class="docutils" /> +<p><strong>New:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.drop(name,</span> <span class="pre">ignore_items=False)</span></code></p> +<p>Removes all metadata and data referenced to the variable. When passing an +<code class="docutils literal"><span class="pre">array</span> <span class="pre">mask</span></code>, <code class="docutils literal"><span class="pre">ignore_items</span></code> can be ste to <code class="docutils literal"><span class="pre">True</span></code> to keep the <code class="docutils literal"><span class="pre">item</span> +<span class="pre">columns</span></code> incl. their metadata.</p> +<hr class="docutils" /> +<p><strong>New:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.compare(dataset=None,</span> <span class="pre">variables=None)</span></code></p> +<p>Compare the metadata definition between the current and another <code class="docutils literal"><span class="pre">dataset</span></code>, +optionally restricting to a pair of variables.</p> +<hr class="docutils" /> +<p><strong>Update:</strong></p> +<p><code class="docutils literal"><span class="pre">DataSet.__setitem__()</span></code></p> +<p><code class="docutils literal"><span class="pre">[..]</span></code>-Indexer now checks scalars against categorical meta.</p> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="03_how_to_snippets.html" class="btn btn-neutral float-right" title="How-to-snippets" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="01_latest.html" class="btn btn-neutral" title="Latest (01/10/2018)" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../_static/jquery.js"></script> + <script type="text/javascript" src="../../_static/underscore.js"></script> + <script type="text/javascript" src="../../_static/doctools.js"></script> + <script type="text/javascript" src="../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/release_notes/03_how_to_snippets.html b/docs/API/_build/html/sites/release_notes/03_how_to_snippets.html new file mode 100644 index 000000000..d8eeee405 --- /dev/null +++ b/docs/API/_build/html/sites/release_notes/03_how_to_snippets.html @@ -0,0 +1,444 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>How-to-snippets — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../genindex.html"/> + <link rel="search" title="Search" href="../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../index.html"/> + <link rel="up" title="Release notes" href="00_overview.html"/> + <link rel="next" title="DataSet Dimensions compatibility" href="how_to_snippets/dimensions_comp.html"/> + <link rel="prev" title="Archived release notes" href="02_archive.html"/> + + + <script src="../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="00_overview.html">Release notes</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2 current"><a class="current reference internal" href="#">How-to-snippets</a><ul> +<li class="toctree-l3"><a class="reference internal" href="how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../lib_doc/builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../lib_doc/builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../lib_doc/builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../lib_doc/builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../index.html">Docs</a> »</li> + + <li><a href="00_overview.html">Release notes</a> »</li> + + <li>How-to-snippets</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../_sources/sites/release_notes/03_how_to_snippets.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="section" id="how-to-snippets"> +<h1>How-to-snippets<a class="headerlink" href="#how-to-snippets" title="Permalink to this headline">¶</a></h1> +<div class="toctree-wrapper compound"> +<ul> +<li class="toctree-l1"><a class="reference internal" href="how_to_snippets/dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l2"><a class="reference internal" href="how_to_snippets/dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l2"><a class="reference internal" href="how_to_snippets/dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="how_to_snippets/create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l1"><a class="reference internal" href="how_to_snippets/derotate.html">Derotation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="how_to_snippets/derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l2"><a class="reference internal" href="how_to_snippets/derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l2"><a class="reference internal" href="how_to_snippets/derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="how_to_snippets/dimensions_comp.html" class="btn btn-neutral float-right" title="DataSet Dimensions compatibility" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="02_archive.html" class="btn btn-neutral" title="Archived release notes" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../_static/jquery.js"></script> + <script type="text/javascript" src="../../_static/underscore.js"></script> + <script type="text/javascript" src="../../_static/doctools.js"></script> + <script type="text/javascript" src="../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/release_notes/how_to_snippets/create_categorical_meta.html b/docs/API/_build/html/sites/release_notes/how_to_snippets/create_categorical_meta.html new file mode 100644 index 000000000..e9c422c5e --- /dev/null +++ b/docs/API/_build/html/sites/release_notes/how_to_snippets/create_categorical_meta.html @@ -0,0 +1,492 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Different ways of creating categorical values — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="How-to-snippets" href="../03_how_to_snippets.html"/> + <link rel="next" title="Derotation" href="derotate.html"/> + <link rel="prev" title="DataSet Dimensions compatibility" href="dimensions_comp.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="../00_overview.html">Release notes</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2 current"><a class="reference internal" href="../03_how_to_snippets.html">How-to-snippets</a><ul class="current"> +<li class="toctree-l3"><a class="reference internal" href="dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3 current"><a class="current reference internal" href="#">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../lib_doc/dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../lib_doc/batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../lib_doc/engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../lib_doc/builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="../00_overview.html">Release notes</a> »</li> + + <li><a href="../03_how_to_snippets.html">How-to-snippets</a> »</li> + + <li>Different ways of creating categorical values</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/release_notes/how_to_snippets/create_categorical_meta.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="different-ways-of-creating-categorical-values"> +<h1>Different ways of creating categorical values<a class="headerlink" href="#different-ways-of-creating-categorical-values" title="Permalink to this headline">¶</a></h1> +<p>The <code class="docutils literal"><span class="pre">DataSet</span></code> methods <code class="docutils literal"><span class="pre">add_meta()</span></code>, <code class="docutils literal"><span class="pre">extend_values()</span></code> and <code class="docutils literal"><span class="pre">derive()</span></code> +offer three alternatives for specifying the categorical values of <code class="docutils literal"><span class="pre">'single'</span></code> +and <code class="docutils literal"><span class="pre">'delimited</span> <span class="pre">set'</span></code> typed variables. The approaches differ with respect to +how the mapping of numerical value codes to value text labels is handled.</p> +<p><strong>(1) Providing a list of text labels</strong></p> +<p>By providing the category labels only as a list of <code class="docutils literal"><span class="pre">str</span></code>, <code class="docutils literal"><span class="pre">DataSet</span></code> +is going to create the numerical codes by simple enumeration:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">name</span><span class="p">,</span> <span class="n">qtype</span><span class="p">,</span> <span class="n">label</span> <span class="o">=</span> <span class="s1">'test_var'</span><span class="p">,</span> <span class="s1">'single'</span><span class="p">,</span> <span class="s1">'The test variable label'</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">cats</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'test_cat_1'</span><span class="p">,</span> <span class="s1">'test_cat_2'</span><span class="p">,</span> <span class="s1">'test_cat_3'</span><span class="p">]</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">add_meta</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">qtype</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">cats</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'test_var'</span><span class="p">)</span> +<span class="go">single codes texts missing</span> +<span class="go">test_var: The test variable label</span> +<span class="go">1 1 test_cat_1 None</span> +<span class="go">2 2 test_cat_2 None</span> +<span class="go">3 3 test_cat_3 None</span> +</pre></div> +</div> +<p><strong>(2) Providing a list of numerical codes</strong></p> +<p>If only the desired numerical codes are provided, the label information for all +categories consequently will appear blank. In such a case the user will, however, +get reminded to add the <code class="docutils literal"><span class="pre">'text'</span></code> meta in a separate step:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">cats</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">98</span><span class="p">]</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">add_meta</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">qtype</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">cats</span><span class="p">)</span> +<span class="go">...\\quantipy\core\dataset.py:1287: UserWarning: 'text' label information missing,</span> +<span class="go">only numerical codes created for the values object. Remember to add value 'text' metadata manually!</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'test_var'</span><span class="p">)</span> +<span class="go">single codes texts missing</span> +<span class="go">test_var: The test variable label</span> +<span class="go">1 1 None</span> +<span class="go">2 2 None</span> +<span class="go">3 98 None</span> +</pre></div> +</div> +<p><strong>(3) Pairing numerical codes with text labels</strong></p> +<p>To explicitly assign codes to corresponding labels, categories can also be +defined as a list of tuples of codes and labels:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">cats</span> <span class="o">=</span> <span class="p">[(</span><span class="mi">1</span><span class="p">,</span> <span class="s1">'test_cat_1'</span><span class="p">)</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="s1">'test_cat_2'</span><span class="p">),</span> <span class="p">(</span><span class="mi">98</span><span class="p">,</span> <span class="s1">'Don</span><span class="se">\'</span><span class="s1">t know'</span><span class="p">)]</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">add_meta</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">qtype</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">cats</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'test_var'</span><span class="p">)</span> +<span class="go">single codes texts missing</span> +<span class="go">test_var: The test variable label</span> +<span class="go">1 1 test_cat_1 None</span> +<span class="go">2 2 test_cat_2 None</span> +<span class="go">3 98 Don't know None</span> +</pre></div> +</div> +<div class="admonition note"> +<p class="first admonition-title">Note</p> +<p class="last">All three approaches are also valid for defining the <code class="docutils literal"><span class="pre">items</span></code> object for +<code class="docutils literal"><span class="pre">array</span></code>-typed <code class="docutils literal"><span class="pre">masks</span></code>.</p> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="derotate.html" class="btn btn-neutral float-right" title="Derotation" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="dimensions_comp.html" class="btn btn-neutral" title="DataSet Dimensions compatibility" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/release_notes/how_to_snippets/derotate.html b/docs/API/_build/html/sites/release_notes/how_to_snippets/derotate.html new file mode 100644 index 000000000..b6f86d4a6 --- /dev/null +++ b/docs/API/_build/html/sites/release_notes/how_to_snippets/derotate.html @@ -0,0 +1,677 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Derotation — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="How-to-snippets" href="../03_how_to_snippets.html"/> + <link rel="next" title="Data processing" href="../../lib_doc/dataprocessing/00_overview.html"/> + <link rel="prev" title="Different ways of creating categorical values" href="create_categorical_meta.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="../00_overview.html">Release notes</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2 current"><a class="reference internal" href="../03_how_to_snippets.html">How-to-snippets</a><ul class="current"> +<li class="toctree-l3"><a class="reference internal" href="dimensions_comp.html"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="dimensions_comp.html#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="dimensions_comp.html#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3 current"><a class="current reference internal" href="#">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../lib_doc/dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../lib_doc/batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../lib_doc/engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../lib_doc/builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="../00_overview.html">Release notes</a> »</li> + + <li><a href="../03_how_to_snippets.html">How-to-snippets</a> »</li> + + <li>Derotation</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/release_notes/how_to_snippets/derotate.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="derotation"> +<h1>Derotation<a class="headerlink" href="#derotation" title="Permalink to this headline">¶</a></h1> +<div class="section" id="what-is-derotation"> +<h2>What is derotation<a class="headerlink" href="#what-is-derotation" title="Permalink to this headline">¶</a></h2> +<p>Derotation of <code class="docutils literal"><span class="pre">data</span></code> is necessary if brands, products or something similar +(<strong>levels</strong>) are assessed and each respondent (case) rates a different +selection of that levels. So each <strong>case</strong> has several <strong>responses</strong>. +Derotation now means, that the <code class="docutils literal"><span class="pre">data</span></code> is switched from case-level to +responses-level.</p> +<p><strong>Example</strong>: <code class="docutils literal"><span class="pre">q1_1/q1_2</span></code>: On a scale from 1 to 10, how much do you like the +following drinks?</p> +<div class="line-block"> +<div class="line">1: water</div> +<div class="line">2: cola</div> +<div class="line">3: lemonade</div> +<div class="line">4: beer</div> +<div class="line"><br /></div> +</div> +<p><strong>``data``</strong></p> +<table border="1" class="docutils"> +<colgroup> +<col width="16%" /> +<col width="20%" /> +<col width="20%" /> +<col width="13%" /> +<col width="13%" /> +<col width="18%" /> +</colgroup> +<tbody valign="top"> +<tr class="row-odd"><td>id</td> +<td>drink_1</td> +<td>drink_2</td> +<td>q1_1</td> +<td>q1_2</td> +<td>gender</td> +</tr> +<tr class="row-even"><td>case1</td> +<td>1</td> +<td>3</td> +<td>2</td> +<td>8</td> +<td>1</td> +</tr> +<tr class="row-odd"><td>case2</td> +<td>1</td> +<td>4</td> +<td>9</td> +<td>5</td> +<td>2</td> +</tr> +<tr class="row-even"><td>case3</td> +<td>2</td> +<td>4</td> +<td>6</td> +<td>10</td> +<td>1</td> +</tr> +</tbody> +</table> +<p><strong>derotated ``data``</strong></p> +<table border="1" class="docutils"> +<colgroup> +<col width="17%" /> +<col width="17%" /> +<col width="38%" /> +<col width="10%" /> +<col width="19%" /> +</colgroup> +<tbody valign="top"> +<tr class="row-odd"><td> </td> +<td>drink</td> +<td>drink_levelled</td> +<td>q1</td> +<td>gender</td> +</tr> +<tr class="row-even"><td>case1</td> +<td>1</td> +<td>1</td> +<td>2</td> +<td>1</td> +</tr> +<tr class="row-odd"><td>case1</td> +<td>2</td> +<td>3</td> +<td>8</td> +<td>1</td> +</tr> +<tr class="row-even"><td>case2</td> +<td>1</td> +<td>1</td> +<td>9</td> +<td>2</td> +</tr> +<tr class="row-odd"><td>case2</td> +<td>2</td> +<td>4</td> +<td>5</td> +<td>2</td> +</tr> +<tr class="row-even"><td>case3</td> +<td>1</td> +<td>2</td> +<td>6</td> +<td>1</td> +</tr> +<tr class="row-odd"><td>case3</td> +<td>2</td> +<td>4</td> +<td>10</td> +<td>1</td> +</tr> +</tbody> +</table> +<p>To identify which case rates which levels, some key-/level-variables are +included in the <code class="docutils literal"><span class="pre">data</span></code>, in this example <code class="docutils literal"><span class="pre">drink_1</span></code> and <code class="docutils literal"><span class="pre">drink_2</span></code>. +Variables (for example <code class="docutils literal"><span class="pre">gender</span></code>) that are not included to this loop can also +be added.</p> +</div> +<div class="section" id="how-to-use-dataset-derotate"> +<h2>How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code><a class="headerlink" href="#how-to-use-dataset-derotate" title="Permalink to this headline">¶</a></h2> +<p>The <code class="docutils literal"><span class="pre">DataSet</span></code> method takes a few parameters:</p> +<ul> +<li><p class="first"><code class="docutils literal"><span class="pre">levels</span></code>: <code class="docutils literal"><span class="pre">dict</span></code> of <code class="docutils literal"><span class="pre">list</span></code></p> +<p>Contains all key-/level-variables and the name for the new levelled variable. +All key-/level-variables must have the same <code class="docutils literal"><span class="pre">value_map</span></code>.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">levels</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'drink'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'drink_1'</span><span class="p">,</span> <span class="s1">'drink_2'</span><span class="p">]}</span> +</pre></div> +</div> +</li> +</ul> +<div class="line-block"> +<div class="line"><br /></div> +</div> +<ul> +<li><p class="first"><code class="docutils literal"><span class="pre">mapper</span></code>: <code class="docutils literal"><span class="pre">list</span></code> of <code class="docutils literal"><span class="pre">dicts</span></code> of <code class="docutils literal"><span class="pre">list</span></code></p> +<p>Contains the looped questions and the new <code class="docutils literal"><span class="pre">column</span></code> name to which the +looped questions will be combinded.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">mapper</span> <span class="o">=</span> <span class="p">[{</span><span class="s1">'q1'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q1_1'</span><span class="p">,</span> <span class="s1">'q1_2'</span><span class="p">]}]</span> +</pre></div> +</div> +</li> +</ul> +<div class="line-block"> +<div class="line"><br /></div> +</div> +<ul> +<li><p class="first"><code class="docutils literal"><span class="pre">other</span></code>: <code class="docutils literal"><span class="pre">str</span></code> or <code class="docutils literal"><span class="pre">list</span></code> of <code class="docutils literal"><span class="pre">str</span></code></p> +<p>Contains all variables that should be assumed to the derotated <code class="docutils literal"><span class="pre">data</span></code>, but +which are not included in the loop.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">other</span> <span class="o">=</span> <span class="s1">'gender'</span> +</pre></div> +</div> +</li> +</ul> +<div class="line-block"> +<div class="line"><br /></div> +</div> +<ul> +<li><p class="first"><code class="docutils literal"><span class="pre">unique_key</span></code>: <code class="docutils literal"><span class="pre">str</span></code></p> +<p>Name of varibale that identifies cases in the initial <code class="docutils literal"><span class="pre">data</span></code>.</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">unique_key</span> <span class="o">=</span> <span class="s1">'id'</span> +</pre></div> +</div> +</li> +</ul> +<div class="line-block"> +<div class="line"><br /></div> +</div> +<ul> +<li><p class="first"><code class="docutils literal"><span class="pre">dropna</span></code>: <code class="docutils literal"><span class="pre">bool</span></code>, default <code class="docutils literal"><span class="pre">True</span></code></p> +<p>If a case rates less then the possible counts of levels, these responses +will be droped.</p> +</li> +</ul> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ds</span> <span class="o">=</span> <span class="n">dataset</span><span class="o">.</span><span class="n">derotate</span><span class="p">(</span><span class="n">levels</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'drink'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'drink_1'</span><span class="p">,</span> <span class="s1">'drink_2'</span><span class="p">]},</span> +<span class="gp">... </span> <span class="n">mapper</span> <span class="o">=</span> <span class="p">[{</span><span class="s1">'q1'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q1_1'</span><span class="p">,</span> <span class="s1">'q1_2'</span><span class="p">]}],</span> +<span class="gp">... </span> <span class="n">other</span> <span class="o">=</span> <span class="s1">'gender'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">unique_key</span> <span class="o">=</span> <span class="s1">'id'</span><span class="p">,</span> +<span class="gp">... </span> <span class="n">dropna</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> +</pre></div> +</div> +</div> +<div class="section" id="what-about-arrays"> +<h2>What about <code class="docutils literal"><span class="pre">arrays</span></code>?<a class="headerlink" href="#what-about-arrays" title="Permalink to this headline">¶</a></h2> +<p>It is possible that also <code class="docutils literal"><span class="pre">arrays</span></code> are looped. In this case a mapper can look +like this:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">mapper</span> <span class="o">=</span> <span class="p">[{</span><span class="s1">'q12_1'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q12a[</span><span class="si">{q12a_1}</span><span class="s1">].q12a_grid'</span><span class="p">,</span> <span class="s1">'q12b[</span><span class="si">{q12b_1}</span><span class="s1">].q12b_grid'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'q12c[</span><span class="si">{q12c_1}</span><span class="s1">].q12c_grid'</span><span class="p">,</span> <span class="s1">'q12d[</span><span class="si">{q12d_1}</span><span class="s1">].q12d_grid'</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_2'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q12a[</span><span class="si">{q12a_2}</span><span class="s1">].q12a_grid'</span><span class="p">,</span> <span class="s1">'q12b[</span><span class="si">{q12b_2}</span><span class="s1">].q12b_grid'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'q12c[</span><span class="si">{q12c_2}</span><span class="s1">].q12c_grid'</span><span class="p">,</span> <span class="s1">'q12d[</span><span class="si">{q12d_2}</span><span class="s1">].q12d_grid'</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_3'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q12a[</span><span class="si">{q12a_3}</span><span class="s1">].q12a_grid'</span><span class="p">,</span> <span class="s1">'q12b[</span><span class="si">{q12b_3}</span><span class="s1">].q12b_grid'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'q12c[</span><span class="si">{q12c_3}</span><span class="s1">].q12c_grid'</span><span class="p">,</span> <span class="s1">'q12d[</span><span class="si">{q12d_3}</span><span class="s1">].q12d_grid'</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_4'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q12a[</span><span class="si">{q12a_4}</span><span class="s1">].q12a_grid'</span><span class="p">,</span> <span class="s1">'q12b[</span><span class="si">{q12b_4}</span><span class="s1">].q12b_grid'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'q12c[</span><span class="si">{q12c_4}</span><span class="s1">].q12c_grid'</span><span class="p">,</span> <span class="s1">'q12d[</span><span class="si">{q12d_4}</span><span class="s1">].q12d_grid'</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_5'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q12a[</span><span class="si">{q12a_5}</span><span class="s1">].q12a_grid'</span><span class="p">,</span> <span class="s1">'q12b[</span><span class="si">{q12b_5}</span><span class="s1">].q12b_grid'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'q12c[</span><span class="si">{q12c_5}</span><span class="s1">].q12c_grid'</span><span class="p">,</span> <span class="s1">'q12d[</span><span class="si">{q12d_5}</span><span class="s1">].q12d_grid'</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_6'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q12a[</span><span class="si">{q12a_6}</span><span class="s1">].q12a_grid'</span><span class="p">,</span> <span class="s1">'q12b[</span><span class="si">{q12b_6}</span><span class="s1">].q12b_grid'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'q12c[</span><span class="si">{q12c_6}</span><span class="s1">].q12c_grid'</span><span class="p">,</span> <span class="s1">'q12d[</span><span class="si">{q12d_6}</span><span class="s1">].q12d_grid'</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_7'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q12a[</span><span class="si">{q12a_7}</span><span class="s1">].q12a_grid'</span><span class="p">,</span> <span class="s1">'q12b[</span><span class="si">{q12b_7}</span><span class="s1">].q12b_grid'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'q12c[</span><span class="si">{q12c_7}</span><span class="s1">].q12c_grid'</span><span class="p">,</span> <span class="s1">'q12d[</span><span class="si">{q12d_7}</span><span class="s1">].q12d_grid'</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_8'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q12a[</span><span class="si">{q12a_8}</span><span class="s1">].q12a_grid'</span><span class="p">,</span> <span class="s1">'q12b[</span><span class="si">{q12b_8}</span><span class="s1">].q12b_grid'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'q12c[</span><span class="si">{q12c_8}</span><span class="s1">].q12c_grid'</span><span class="p">,</span> <span class="s1">'q12d[</span><span class="si">{q12d_8}</span><span class="s1">].q12d_grid'</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_9'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q12a[</span><span class="si">{q12a_9}</span><span class="s1">].q12a_grid'</span><span class="p">,</span> <span class="s1">'q12b[</span><span class="si">{q12b_9}</span><span class="s1">].q12b_grid'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'q12c[</span><span class="si">{q12c_9}</span><span class="s1">].q12c_grid'</span><span class="p">,</span> <span class="s1">'q12d[</span><span class="si">{q12d_9}</span><span class="s1">].q12d_grid'</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_10'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q12a[</span><span class="si">{q12a_10}</span><span class="s1">].q12a_grid'</span><span class="p">,</span> <span class="s1">'q12b[</span><span class="si">{q12b_10}</span><span class="s1">].q12b_grid'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'q12c[</span><span class="si">{q12c_10}</span><span class="s1">].q12c_grid'</span><span class="p">,</span> <span class="s1">'q12d[</span><span class="si">{q12d_10}</span><span class="s1">].q12d_grid'</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_11'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q12a[</span><span class="si">{q12a_11}</span><span class="s1">].q12a_grid'</span><span class="p">,</span> <span class="s1">'q12b[</span><span class="si">{q12b_11}</span><span class="s1">].q12b_grid'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'q12c[</span><span class="si">{q12c_11}</span><span class="s1">].q12c_grid'</span><span class="p">,</span> <span class="s1">'q12d[</span><span class="si">{q12d_11}</span><span class="s1">].q12d_grid'</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_12'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q12a[</span><span class="si">{q12a_12}</span><span class="s1">].q12a_grid'</span><span class="p">,</span> <span class="s1">'q12b[</span><span class="si">{q12b_12}</span><span class="s1">].q12b_grid'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'q12c[</span><span class="si">{q12c_12}</span><span class="s1">].q12c_grid'</span><span class="p">,</span> <span class="s1">'q12d[</span><span class="si">{q12d_12}</span><span class="s1">].q12d_grid'</span><span class="p">]},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_13'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'q12a[</span><span class="si">{q12a_13}</span><span class="s1">].q12a_grid'</span><span class="p">,</span> <span class="s1">'q12b[</span><span class="si">{q12b_13}</span><span class="s1">].q12b_grid'</span><span class="p">,</span> +<span class="gp">... </span> <span class="s1">'q12c[</span><span class="si">{q12c_13}</span><span class="s1">].q12c_grid'</span><span class="p">,</span> <span class="s1">'q12d[</span><span class="si">{q12d_13}</span><span class="s1">].q12d_grid'</span><span class="p">]}]]</span> +</pre></div> +</div> +<p>Can be also writen like this:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">for</span> <span class="n">y</span> <span class="ow">in</span> <span class="n">frange</span><span class="p">(</span><span class="s1">'1-13'</span><span class="p">):</span> +<span class="gp">... </span> <span class="n">q_group</span> <span class="o">=</span> <span class="p">[]</span> +<span class="gp">... </span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">'a'</span><span class="p">,</span> <span class="s1">'b'</span><span class="p">,</span> <span class="s1">'c'</span><span class="p">,</span> <span class="s1">'d'</span><span class="p">]:</span> +<span class="gp">... </span> <span class="n">var</span> <span class="o">=</span> <span class="s1">'q12</span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> +<span class="gp">... </span> <span class="n">var_grid</span> <span class="o">=</span> <span class="n">var</span> <span class="o">+</span> <span class="s1">'[{'</span> <span class="o">+</span> <span class="n">var</span> <span class="o">+</span> <span class="s1">'_</span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">y</span><span class="p">)</span> <span class="o">+</span> <span class="s1">'}].'</span> <span class="o">+</span> <span class="n">var</span> <span class="o">+</span> <span class="s1">'_grid'</span> +<span class="gp">... </span> <span class="n">q_group</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">var_grid</span><span class="p">)</span> +<span class="gp">... </span> <span class="n">mapper</span><span class="o">.</span><span class="n">append</span><span class="p">({</span><span class="s1">'q12_</span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">y</span><span class="p">):</span> <span class="n">q_group</span><span class="p">})</span> +</pre></div> +</div> +<p>So the derotated <code class="docutils literal"><span class="pre">dataset</span></code> will lose its <code class="docutils literal"><span class="pre">meta</span></code> information about the +<code class="docutils literal"><span class="pre">mask</span></code> and only the <code class="docutils literal"><span class="pre">columns</span></code> <code class="docutils literal"><span class="pre">q12_1</span></code> to <code class="docutils literal"><span class="pre">q12_13</span></code> will be added. To +receive back the <code class="docutils literal"><span class="pre">mask</span></code> structure, use the method <code class="docutils literal"><span class="pre">dataset.to_array()</span></code>:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">variables</span> <span class="o">=</span> <span class="p">[{</span><span class="s1">'q12_1'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'label 1'</span><span class="p">},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_2'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'label 2'</span><span class="p">},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_3'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'label 3'</span><span class="p">},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_4'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'label 4'</span><span class="p">},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_5'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'label 5'</span><span class="p">},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_6'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'label 6'</span><span class="p">},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_7'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'label 7'</span><span class="p">},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_8'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'label 8'</span><span class="p">},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_9'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'label 9'</span><span class="p">},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_10'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'label 10'</span><span class="p">},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_11'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'label 11'</span><span class="p">},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_12'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'label 12'</span><span class="p">},</span> +<span class="gp">... </span> <span class="p">{</span><span class="s1">'q12_13'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'label 13'</span><span class="p">}]</span> +<span class="gp">>>> </span><span class="n">ds</span><span class="o">.</span><span class="n">to_array</span><span class="p">(</span><span class="s1">'qTP'</span><span class="p">,</span> <span class="n">variables</span><span class="p">,</span> <span class="s1">'Var_name'</span><span class="p">)</span> +</pre></div> +</div> +<p><code class="docutils literal"><span class="pre">variables</span></code> can also be a list of variable-names, then the <code class="docutils literal"><span class="pre">mask-items</span></code> +will be named by its belonging <code class="docutils literal"><span class="pre">columns</span></code>.</p> +<p><code class="docutils literal"><span class="pre">arrays</span></code> included in <code class="docutils literal"><span class="pre">other</span></code> will keep their <code class="docutils literal"><span class="pre">meta</span></code> structure.</p> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="../../lib_doc/dataprocessing/00_overview.html" class="btn btn-neutral float-right" title="Data processing" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="create_categorical_meta.html" class="btn btn-neutral" title="Different ways of creating categorical values" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/_build/html/sites/release_notes/how_to_snippets/dimensions_comp.html b/docs/API/_build/html/sites/release_notes/how_to_snippets/dimensions_comp.html new file mode 100644 index 000000000..7d8170f02 --- /dev/null +++ b/docs/API/_build/html/sites/release_notes/how_to_snippets/dimensions_comp.html @@ -0,0 +1,538 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>DataSet Dimensions compatibility — Quantipy 0.1.3 documentation</title> + + + + + + + + + + + + + + + + <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" /> + + + + <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" /> + + + + <link rel="index" title="Index" + href="../../../genindex.html"/> + <link rel="search" title="Search" href="../../../search.html"/> + <link rel="top" title="Quantipy 0.1.3 documentation" href="../../../index.html"/> + <link rel="up" title="How-to-snippets" href="../03_how_to_snippets.html"/> + <link rel="next" title="Different ways of creating categorical values" href="create_categorical_meta.html"/> + <link rel="prev" title="How-to-snippets" href="../03_how_to_snippets.html"/> + + + <script src="../../../_static/js/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-scroll"> + <div class="wy-side-nav-search"> + + + + <a href="../../../index.html" class="icon icon-home"> Quantipy + + + + </a> + + + + + <div class="version"> + 0.1.3 + </div> + + + + +<div id="searchbox" style="display: none" role="search"> + <h3>Quick search</h3> + <form class="search" action="../../../search.html" method="get"> + <div><input type="text" name="q" /></div> + <div><input type="submit" value="Go" /></div> + <input type="hidden" name="check_keywords" value="yes" /> + <input type="hidden" name="area" value="default" /> + </form> +</div> +<script type="text/javascript">$('#searchbox').show(0);</script> + + + </div> + + <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> + + + + <ul class="current"> +<li class="toctree-l1 current"><a class="reference internal" href="../00_overview.html">Release notes</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../01_latest.html">Upcoming (September)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../01_latest.html#latest-04-06-2018">Latest (04/06/2018)</a></li> +<li class="toctree-l2"><a class="reference internal" href="../02_archive.html">Archived release notes</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-04-04-2018">sd (04/04/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-27-02-2018">sd (27/02/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-12-01-2018">sd (12/01/2018)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-18-12-2017">sd (18/12/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-28-11-2017">sd (28/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-13-11-2017">sd (13/11/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-17-10-2017">sd (17/10/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-15-09-2017">sd (15/09/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-31-08-2017">sd (31/08/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-24-07-2017">sd (24/07/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-08-06-2017">sd (08/06/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-17-05-2017">sd (17/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-04-05-2017">sd (04/05/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-24-04-2017">sd (24/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-06-04-2017">sd (06/04/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-29-03-2017">sd (29/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-20-03-2017">sd (20/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-07-03-2017">sd (07/03/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-24-02-2017">sd (24/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-16-02-2017">sd (16/02/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-04-01-2017">sd (04/01/2017)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-8-12-2016">sd (8/12/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-23-11-2016">sd (23/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-16-11-2016">sd (16/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-11-11-2016">sd (11/11/2016)</a></li> +<li class="toctree-l3"><a class="reference internal" href="../02_archive.html#sd-09-11-2016">sd (09/11/2016)</a></li> +</ul> +</li> +<li class="toctree-l2 current"><a class="reference internal" href="../03_how_to_snippets.html">How-to-snippets</a><ul class="current"> +<li class="toctree-l3 current"><a class="current reference internal" href="#"><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</a><ul> +<li class="toctree-l4"><a class="reference internal" href="#the-compatibility-mode">The compatibility mode</a></li> +<li class="toctree-l4"><a class="reference internal" href="#accessing-and-creating-array-data">Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="create_categorical_meta.html">Different ways of creating categorical values</a></li> +<li class="toctree-l3"><a class="reference internal" href="derotate.html">Derotation</a><ul> +<li class="toctree-l4"><a class="reference internal" href="derotate.html#what-is-derotation">What is derotation</a></li> +<li class="toctree-l4"><a class="reference internal" href="derotate.html#how-to-use-dataset-derotate">How to use <code class="docutils literal"><span class="pre">DataSet.derotate()</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="derotate.html#what-about-arrays">What about <code class="docutils literal"><span class="pre">arrays</span></code>?</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../lib_doc/dataprocessing/00_overview.html">Data processing</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html">DataSet components</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html#case-and-meta-data">Case and meta data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html#columns-and-masks-objects"><code class="docutils literal"><span class="pre">columns</span></code> and <code class="docutils literal"><span class="pre">masks</span></code> objects</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html#languages-text-and-text-key-mappings">Languages: <code class="docutils literal"><span class="pre">text</span></code> and <code class="docutils literal"><span class="pre">text_key</span></code> mappings</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html#categorical-values-object">Categorical <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/01_components.html#the-array-type">The <code class="docutils literal"><span class="pre">array</span></code> type</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html">I/O</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#starting-from-native-components">Starting from native components</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#using-a-standalone-pd-dataframe">Using a standalone <code class="docutils literal"><span class="pre">pd.DataFrame</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#csv-json-pairs"><code class="docutils literal"><span class="pre">.csv</span></code> / <code class="docutils literal"><span class="pre">.json</span></code> pairs</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#third-party-conversions">Third party conversions</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#supported-conversions">Supported conversions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#spss-statistics">SPSS Statistics</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#dimensions">Dimensions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#decipher">Decipher</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02_io.html#ascribe">Ascribe</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html">DataSet management</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#setting-the-variable-order">Setting the variable order</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#cloning-filtering-and-subsetting">Cloning, filtering and subsetting</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#merging">Merging</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#vertical-cases-rows-merging">Vertical (cases/rows) merging</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#horizontal-variables-columns-merging">Horizontal (variables/columns) merging</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/02a_management.html#savepoints-and-state-rollback">Savepoints and state rollback</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/03_inspection.html">Inspecting variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/03_inspection.html#querying-and-slicing-case-data">Querying and slicing case data</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/03_inspection.html#variable-and-value-existence">Variable and value existence</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/03_inspection.html#variable-types">Variable types</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/03_inspection.html#slicing-dicing-metadata-objects">Slicing & dicing metadata objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html">Editing metadata</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#creating-meta-from-scratch">Creating meta from scratch</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#renaming">Renaming</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#changing-adding-text-info">Changing & adding <code class="docutils literal"><span class="pre">text</span></code> info</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#extending-the-values-object">Extending the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#reordering-the-values-object">Reordering the <code class="docutils literal"><span class="pre">values</span></code> object</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/04_editing.html#removing-dataset-objects">Removing <code class="docutils literal"><span class="pre">DataSet</span></code> objects</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/05_transforming.html">Transforming variables</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/05_transforming.html#copying">Copying</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/05_transforming.html#inplace-type-conversion">Inplace type conversion</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/05_transforming.html#banding-and-categorization">Banding and categorization</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/05_transforming.html#array-transformations">Array transformations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html">Logic and set operaters</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#ranges">Ranges</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#complex-logic">Complex logic</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#union"><code class="docutils literal"><span class="pre">union</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#intersection"><code class="docutils literal"><span class="pre">intersection</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#list-logic">“List” logic</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#has-any"><code class="docutils literal"><span class="pre">has_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#not-any"><code class="docutils literal"><span class="pre">not_any</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#has-all"><code class="docutils literal"><span class="pre">has_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#not-all"><code class="docutils literal"><span class="pre">not_all</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#has-count"><code class="docutils literal"><span class="pre">has_count</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#not-count"><code class="docutils literal"><span class="pre">not_count</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/06_logics.html#boolean-slicers-and-code-existence">Boolean slicers and code existence</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html">Custom data recoding</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#the-recode-method-in-detail">The <code class="docutils literal"><span class="pre">recode()</span></code> method in detail</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#target"><code class="docutils literal"><span class="pre">target</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#mapper"><code class="docutils literal"><span class="pre">mapper</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#default"><code class="docutils literal"><span class="pre">default</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#append"><code class="docutils literal"><span class="pre">append</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#intersect"><code class="docutils literal"><span class="pre">intersect</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#initialize"><code class="docutils literal"><span class="pre">initialize</span></code></a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#fillna"><code class="docutils literal"><span class="pre">fillna</span></code></a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#custom-recode-examples">Custom recode examples</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#building-a-net-code">Building a net code</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#create-and-fill">Create-and-fill</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#numerical-banding">Numerical banding</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#complicated-segmentation">Complicated segmentation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#variable-creation">Variable creation</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#adding-derived-variables">Adding derived variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#interlocking-variables">Interlocking variables</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/dataprocessing/07_custom_recoding.html#condition-based-code-removal">Condition-based code removal</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../lib_doc/batch/00_overview.html"><code class="docutils literal"><span class="pre">Batch</span></code></a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/batch/01_create_load.html">Creating/ Loading a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/batch/02_variables.html">Adding variables to a <code class="docutils literal"><span class="pre">qp.Batch</span></code> instance</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/02_variables.html#x-keys-and-y-keys">x-keys and y-keys</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/02_variables.html#arrays">Arrays</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/02_variables.html#verbatims-open-ends">Verbatims/ open ends</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/02_variables.html#special-aggregations">Special aggregations</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/batch/03_properties.html">Set properties of a <code class="docutils literal"><span class="pre">qp.Batch</span></code></a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/03_properties.html#filter-weights-and-significance-testing">Filter, weights and significance testing</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/batch/03_properties.html#cell-items-and-language">Cell items and language</a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/batch/04_subclass.html">Inherited <code class="docutils literal"><span class="pre">qp.DataSet</span></code> methods</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../lib_doc/engine/00_overview.html">Analysis & aggregation</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/engine/01_links_stacks.html">Collecting aggregations</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/01_links_stacks.html#what-is-a-qp-link">What is a <code class="docutils literal"><span class="pre">qp.Link?</span></code></a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/01_links_stacks.html#populating-a-qp-stack">Populating a <code class="docutils literal"><span class="pre">qp.Stack</span></code></a></li> +</ul> +</li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/engine/02_quantity.html">The computational engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/engine/03_test.html">Significance testing</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html">View aggregation</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#basic-views">Basic views</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#non-categorical-variables">Non-categorical variables</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#descriptive-statistics">Descriptive statistics</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#nets">Nets</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#net-definitions">Net definitions</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#calculations">Calculations</a></li> +</ul> +</li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#cumulative-sums">Cumulative sums</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/engine/04_agg_methods.html#significance-tests">Significance tests</a></li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../lib_doc/builds/00_overview.html">Builds</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../lib_doc/builds/01_chains.html">Combining results</a><ul> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/builds/01_chains.html#organizing-view-aggregations">Organizing <code class="docutils literal"><span class="pre">View</span></code> aggregations</a></li> +<li class="toctree-l3"><a class="reference internal" href="../../lib_doc/builds/01_chains.html#creating-chain-aggregations">Creating <code class="docutils literal"><span class="pre">Chain</span></code> aggregations</a><ul> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/builds/01_chains.html#what-is-a-chain">What is a <code class="docutils literal"><span class="pre">Chain</span></code>?</a></li> +<li class="toctree-l4"><a class="reference internal" href="../../lib_doc/builds/01_chains.html#customizing-results">Customizing results</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../../api_ref/00overview.html">API references</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Chain.html">Chain</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Cluster.html">Cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/DataSet.html">DataSet</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/quantify_engine.html">quantify.engine</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/QuantipyViews.html">QuantipyViews</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/Rim_scheme.html">Rim</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/View.html">View</a></li> +<li class="toctree-l2"><a class="reference internal" href="../../api_ref/ViewMapper.html">ViewMapper</a></li> +</ul> +</li> +</ul> + + + + </div> + </div> + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../../../index.html">Quantipy</a> + </nav> + + + + <div class="wy-nav-content"> + <div class="rst-content"> + + + + + + +<div role="navigation" aria-label="breadcrumbs navigation"> + <ul class="wy-breadcrumbs"> + <li><a href="../../../index.html">Docs</a> »</li> + + <li><a href="../00_overview.html">Release notes</a> »</li> + + <li><a href="../03_how_to_snippets.html">How-to-snippets</a> »</li> + + <li><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility</li> + <li class="wy-breadcrumbs-aside"> + + + <a href="../../../_sources/sites/release_notes/how_to_snippets/dimensions_comp.rst.txt" rel="nofollow"> View page source</a> + + + </li> + </ul> + <hr/> +</div> + <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> + <div itemprop="articleBody"> + + <div class="toctree-wrapper compound"> +</div> +<div class="section" id="dataset-dimensions-compatibility"> +<h1><code class="docutils literal"><span class="pre">DataSet</span></code> Dimensions compatibility<a class="headerlink" href="#dataset-dimensions-compatibility" title="Permalink to this headline">¶</a></h1> +<p>DTO-downloaded and Dimensions converted variable naming conventions are following +specific rules for <code class="docutils literal"><span class="pre">array</span></code> names and corresponding <code class="docutils literal"><span class="pre">ìtems</span></code>. <code class="docutils literal"><span class="pre">DataSet</span></code> +offers a compatibility mode for Dimensions scenarios and handles the proper +renaming automatically. Here is what you should know…</p> +<div class="section" id="the-compatibility-mode"> +<h2>The compatibility mode<a class="headerlink" href="#the-compatibility-mode" title="Permalink to this headline">¶</a></h2> +<p>A <code class="docutils literal"><span class="pre">DataSet</span></code> will (by default) support Dimensions-like <code class="docutils literal"><span class="pre">array</span></code> naming for its connected data files when constructed. An <code class="docutils literal"><span class="pre">array</span></code> <code class="docutils literal"><span class="pre">masks</span></code> meta defintition +of a variable called <code class="docutils literal"><span class="pre">q5</span></code> looking like this…:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="p">{</span><span class="sa">u</span><span class="s1">'items'</span><span class="p">:</span> <span class="p">[{</span><span class="sa">u</span><span class="s1">'source'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'columns@q5_1'</span><span class="p">,</span> <span class="sa">u</span><span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="sa">u</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'Surfing'</span><span class="p">}},</span> + <span class="p">{</span><span class="sa">u</span><span class="s1">'source'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'columns@q5_2'</span><span class="p">,</span> <span class="sa">u</span><span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="sa">u</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'Snowboarding'</span><span class="p">}},</span> + <span class="p">{</span><span class="sa">u</span><span class="s1">'source'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'columns@q5_3'</span><span class="p">,</span> <span class="sa">u</span><span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="sa">u</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'Kite boarding'</span><span class="p">}},</span> + <span class="p">{</span><span class="sa">u</span><span class="s1">'source'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'columns@q5_4'</span><span class="p">,</span> <span class="sa">u</span><span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="sa">u</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'Parachuting'</span><span class="p">}},</span> + <span class="p">{</span><span class="sa">u</span><span class="s1">'source'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'columns@q5_5'</span><span class="p">,</span> <span class="sa">u</span><span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="sa">u</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'Cave diving'</span><span class="p">}},</span> + <span class="p">{</span><span class="sa">u</span><span class="s1">'source'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'columns@q5_6'</span><span class="p">,</span> <span class="sa">u</span><span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="sa">u</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'Windsurfing'</span><span class="p">}}],</span> + <span class="sa">u</span><span class="s1">'subtype'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'single'</span><span class="p">,</span> + <span class="sa">u</span><span class="s1">'text'</span><span class="p">:</span> <span class="p">{</span><span class="sa">u</span><span class="s1">'en-GB'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'How likely are you to do each of the following in the next year?'</span><span class="p">},</span> + <span class="sa">u</span><span class="s1">'type'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'array'</span><span class="p">,</span> + <span class="sa">u</span><span class="s1">'values'</span><span class="p">:</span> <span class="sa">u</span><span class="s1">'lib@values@q5'</span><span class="p">}</span> +</pre></div> +</div> +<p>…will be converted into its “Dimensions equivalent” as per:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span> <span class="o">=</span> <span class="n">qp</span><span class="o">.</span><span class="n">DataSet</span><span class="p">(</span><span class="n">name_data</span><span class="p">,</span> <span class="n">dimensions_comp</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">read_quantipy</span><span class="p">(</span><span class="n">path_data</span><span class="o">+</span><span class="n">name_data</span><span class="p">,</span> <span class="n">path_data</span><span class="o">+</span><span class="n">name_data</span><span class="p">)</span> +<span class="go">DataSet: ../Data/Quantipy/Example Data (A)</span> +<span class="go">rows: 8255 - columns: 75</span> +<span class="go">Dimensions compatibilty mode: True</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">masks</span><span class="p">()</span> +<span class="go">['q5.q5_grid', 'q6.q6_grid', 'q7.q7_grid']</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">_meta</span><span class="p">[</span><span class="s1">'masks'</span><span class="p">][</span><span class="s1">'q5.q5_grid'</span><span class="p">]</span> +<span class="go">{u'items': [{u'source': 'columns@q5[{q5_1}].q5_grid',</span> +<span class="go"> u'text': {u'en-GB': u'Surfing'}},</span> +<span class="go"> {u'source': 'columns@q5[{q5_2}].q5_grid',</span> +<span class="go"> u'text': {u'en-GB': u'Snowboarding'}},</span> +<span class="go"> {u'source': 'columns@q5[{q5_3}].q5_grid',</span> +<span class="go"> u'text': {u'en-GB': u'Kite boarding'}},</span> +<span class="go"> {u'source': 'columns@q5[{q5_4}].q5_grid',</span> +<span class="go"> u'text': {u'en-GB': u'Parachuting'}},</span> +<span class="go"> {u'source': 'columns@q5[{q5_5}].q5_grid',</span> +<span class="go"> u'text': {u'en-GB': u'Cave diving'}},</span> +<span class="go"> {u'source': 'columns@q5[{q5_6}].q5_grid',</span> +<span class="go"> u'text': {u'en-GB': u'Windsurfing'}}],</span> +<span class="go"> 'name': 'q5.q5_grid',</span> +<span class="go"> u'subtype': u'single',</span> +<span class="go"> u'text': {u'en-GB': u'How likely are you to do each of the following in the next year?'},</span> +<span class="go"> u'type': u'array',</span> +<span class="go"> u'values': 'lib@values@q5.q5_grid'}</span> +</pre></div> +</div> +</div> +<div class="section" id="accessing-and-creating-array-data"> +<h2>Accessing and creating <code class="docutils literal"><span class="pre">array</span></code> data<a class="headerlink" href="#accessing-and-creating-array-data" title="Permalink to this headline">¶</a></h2> +<p>Since new names are converted automatically by <code class="docutils literal"><span class="pre">DataSet</span></code> methods, there is +no need to write down the full (DTO-like) Dimensions <code class="docutils literal"><span class="pre">array</span></code> name when adding +new metadata. However, querying variables is always requiring the proper name:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">name</span><span class="p">,</span> <span class="n">qtype</span><span class="p">,</span> <span class="n">label</span> <span class="o">=</span> <span class="s1">'array_var'</span><span class="p">,</span> <span class="s1">'single'</span><span class="p">,</span> <span class="s1">'ARRAY LABEL'</span> +<span class="gp">>>> </span><span class="n">cats</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'A'</span><span class="p">,</span> <span class="s1">'B'</span><span class="p">,</span> <span class="s1">'C'</span><span class="p">]</span> +<span class="gp">>>> </span><span class="n">items</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'1'</span><span class="p">,</span> <span class="s1">'2'</span><span class="p">,</span> <span class="s1">'3'</span><span class="p">]</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">add_meta</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">qtype</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">cats</span><span class="p">,</span> <span class="n">items</span><span class="p">)</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">masks</span><span class="p">()</span> +<span class="go">['q5.q5_grid', 'array_var.array_var_grid', 'q6.q6_grid', 'q7.q7_grid']</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">meta</span><span class="p">(</span><span class="s1">'array_var.array_var_grid'</span><span class="p">)</span> +<span class="go">single items item texts codes texts missing</span> +<span class="go">array_var.array_var_grid: ARRAY LABEL</span> +<span class="go">1 array_var[{array_var_1}].array_var_grid 1 1 A None</span> +<span class="go">2 array_var[{array_var_2}].array_var_grid 2 2 B None</span> +<span class="go">3 array_var[{array_var_3}].array_var_grid 3 3 C None</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="p">[</span><span class="s1">'array_var.array_var_grid'</span><span class="p">]</span><span class="o">.</span><span class="n">head</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span> +<span class="go"> array_var[{array_var_1}].array_var_grid array_var[{array_var_2}].array_var_grid array_var[{array_var_3}].array_var_grid</span> +<span class="go">0 NaN NaN NaN</span> +<span class="go">1 NaN NaN NaN</span> +<span class="go">2 NaN NaN NaN</span> +<span class="go">3 NaN NaN NaN</span> +<span class="go">4 NaN NaN NaN</span> +</pre></div> +</div> +<p>As can been seen above, both the <code class="docutils literal"><span class="pre">masks</span></code> name as well as the <code class="docutils literal"><span class="pre">array</span></code> item +elements are being properly converted to match DTO/Dimensions +conventions.</p> +<p>When using <code class="docutils literal"><span class="pre">rename()</span></code>, <code class="docutils literal"><span class="pre">copy()</span></code> or <code class="docutils literal"><span class="pre">transpose()</span></code>, the same behaviour +applies:</p> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">rename</span><span class="p">(</span><span class="s1">'q6.q6_grid'</span><span class="p">,</span> <span class="s1">'q6new'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">masks</span><span class="p">()</span> +<span class="go">['q5.q5_grid', 'array_var.array_var_grid', 'q6new.q6new_grid', 'q7.q7_grid']</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="s1">'q6new.q6new_grid'</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s1">'q6copy'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">masks</span><span class="p">()</span> +<span class="go">['q5.q5_grid', 'q6new_q6copy.q6new_q6copy_grid', 'array_var.array_var_grid', 'q6new.q6new_grid', 'q7.q7_grid']</span> +</pre></div> +</div> +<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">transpose</span><span class="p">(</span><span class="s1">'q6new_q6copy.q6new_q6copy_grid'</span><span class="p">)</span> +<span class="gp">>>> </span><span class="n">dataset</span><span class="o">.</span><span class="n">masks</span><span class="p">()</span> +<span class="go">['q5.q5_grid', 'q6new_q6copy_trans.q6new_q6copy_trans_grid', 'q6new_q6copy.q6new_q6copy_grid', 'array_var.array_var_grid', 'q6new.q6new_grid', 'q7.q7_grid']</span> +</pre></div> +</div> +</div> +</div> + + + </div> + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="create_categorical_meta.html" class="btn btn-neutral float-right" title="Different ways of creating categorical values" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="../03_how_to_snippets.html" class="btn btn-neutral" title="How-to-snippets" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2017, Quantipy dev team. + + </p> + </div> + Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. + +</footer> + + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../../../', + VERSION:'0.1.3', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../../../_static/jquery.js"></script> + <script type="text/javascript" src="../../../_static/underscore.js"></script> + <script type="text/javascript" src="../../../_static/doctools.js"></script> + <script type="text/javascript" src="../../../_static/custom.js"></script> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + + + + + + <script type="text/javascript" src="../../../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file diff --git a/docs/API/conf.py b/docs/API/conf.py index 9cab38b36..3187a551f 100644 --- a/docs/API/conf.py +++ b/docs/API/conf.py @@ -19,6 +19,8 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, "C:\\Users\\alt\\AppData\\Local\\Continuum\\Anaconda\\Lib\\site-packages\\quantipy") +sys.path.insert(0, "C:\\Users\\kmue\\Desktop\\quantipy") + # -- General configuration ------------------------------------------------ diff --git a/docs/API/sites/lib_doc/overview.rst b/docs/API/sites/lib_doc/overview.rst deleted file mode 100644 index 59bfd62e5..000000000 --- a/docs/API/sites/lib_doc/overview.rst +++ /dev/null @@ -1,14 +0,0 @@ -============= -Documentation -============= - -.. toctree:: - :maxdepth: 5 - :hidden: - - dataset/overview - batch/overview - engine/overview - builds/overview - - diff --git a/docs/API/sites/release_notes/01_latest.rst b/docs/API/sites/release_notes/01_latest.rst index 3de4401c4..4eb81c383 100644 --- a/docs/API/sites/release_notes/01_latest.rst +++ b/docs/API/sites/release_notes/01_latest.rst @@ -2,62 +2,133 @@ :maxdepth: 5 :includehidden: -================== -Upcoming (October) -================== - =================== -Latest (15/09/2017) +Latest (01/10/2018) =================== -**New**: ``DataSet.save()`` and ``DataSet.revert()`` +**New**: "rewrite" of Rules module (affecting sorting): + +**sorting "normal" columns**: + +* ``sort_on`` always '@' +* ``fix`` any categories +* ``sort_by_weight`` default is unweighted (None), but each weight (included +in data) can be used + +If sort_by_weight and the view-weight differ, a warning is shown. + +**sorting "expanded net" columns**: + +* ``sort_on`` always '@' +* ``fix`` any categories +* sorting ``within`` or ``between`` net groups is available +* ``sort_by_weight``: as default the weight of the first found +expanded-net-view is taken. Only weights of aggregated net-views are possible + +**sorting "array summaries"**: + +* ``sort_on`` can be any desc ('median', 'stddev', 'sem', 'max', 'min', +'mean', 'upper_q', 'lower_q') or nets ('net_1', 'net_2', .... enumerated +by the net_def) +* ``sort_by_weight``: as default the weight of the first found desc/net-view +is taken. Only weights of aggregated desc/net-views are possible +* ``sort_on`` can also be any category, here each weight can be used to sort_on + +"""" + +**New**: ``DataSet.min_value_count()`` + +A new wrapper for ``DataSet.hiding()`` is included. All values are hidden, +that have less counts than the included number ``min``. +The used data can be weighted or filtered using the parameters ``weight`` and +``condition``. + +Usage as Batch method: +``Batch.min_value_count()`` without the parameters ``weight`` and +``condition`` automatically grabs ``Batch.weights[0]`` and ``Batch.filter`` +to calculate low value counts. + +"""" + +**New**: Prevent weak duplicated in data -These two new methods are useful in interactive sessions like **Ipython** or -**Jupyter** notebooks. ``save()`` will make a temporary (only im memory, not -written to disk) copy of the ``DataSet`` and store its current state. You can -then use ``revert()`` to rollback to that snapshot of the data at a later -stage (e.g. a complex recode operation went wrong, reloading from the physical files takes -too long...). +As Python is case sensitive it is possible to have two or more variables with +the same name, but in lower- and uppercases. Most other software do not support +that, so a warning is shown if a weak dupe is created. Additionally +``Dataset.write_dimensions()`` performs auto-renaming is weak dupes are detected. """" -**New**: ``DataSet.meta_to_json(key=None, collection=None)`` +**New**: Prevent single-cat delimited sets -The new method allows saving parts of the metadata as a json file. The parameters -``key`` and ``collection`` define the metaobject which will be saved. +``DataSet.add_meta(..., qtype='delimited set', categories=[...], ...)`` +automatically switches ``qtype`` to single if only one category is defined. +``DataSet.convert(name, 'single')`` allows conversion from ``delimited set`` to +``single`` if the variable has only one category. +``DataSet.repair()`` and ``DataSt.remove_values()`` convert delimited sets +automatically to singles if only one category is included. """" -**New**: ``DataSet.by_type(types=None)`` +**Update**: merge warnings + merging delimites sets + +Warnings in ``hmerge()`` and ``vmerge()`` are updated. If a column exists in +the left and the right dataset, the type is compared. Some type inconsistencies +are allowed, but return a warning, while others end up in a raise. + +delimited sets in ``vmerge()``: + +If a column is a delimited set in the left dataset, but a single, int or float +in the right dataset, the data of the right column is converted into a delimited +set. + +delimited sets in ``hmerge(...merge_existing=None)``: + +For the hmerge a new parameter ``merge_existing`` is included, which can be +``None``, a list of variable-names or ``'all'``. -The ``by_type()`` method is replacing the soon to be deprecated implementation -of ``variables()`` (see below). It provides the same functionality -(``pd.DataFrame`` summary of variable types) as the latter. +If delimited sets are included in left and right dataset: +* ``merge_existing=None``: Only meta is adjusted. Data is untouched (left data +is taken). +* ``merge_existing='all'``: Meta and data are merged for all delimited sets, +that are included in both datasets. +* ``merge_existing=[variable-names]``: Meta and data are merged for all +delimited sets, that are listed and included in both datasets. """" -**Update**: ``DataSet.variables()`` absorbs ``list_variables()`` and ``variables_from_set()`` +**Update**: encoding in ``DataSet.get_batch(name)`` -In conjunction with the addition of ``by_type()``, ``variables()`` is -replacing the related ``list_variables()`` and ``variables_from_set()`` methods in order to offer a unified solution for querying the ``DataSet``\'s (main) variable collection. +The method is not that encoding sensitive anymore. It returns the depending +``Batch``, no matter if ``'...'``, ``u'...'`` or ``'...'.decode('utf8')`` is +included as name. """" -**Update**: ``Batch.as_addition()`` +**Update**: warning in weight engine -The possibility to add multiple cell item iterations of one ``Batch`` definition -via that method has been reintroduced (it was working by accident in previous -versions with subtle side effects and then removed). Have fun! +Missing codes in the sample are only alerted, if the belonging target is not 0. + +"""" + +**Update**: ``DataSet.to_array(..., variables, ...)`` + +Duplicated vars in ``variables`` are not allowed anymore, these were causing +problems in the ChainManager class. """" **Update**: ``Batch.add_open_ends()`` -The method will now raise an ``Exception`` if called on a ``Batch`` that has -been added to a parent one via ``as_addition()`` to warn the user and prevent -errors at the build stage:: +Method raises an error if no vars are included in ``oe`` and ``break_by``. The +empty dataframe was causing issues in the ChainManager class. + +"""" + +**Update**: ``Batch.extend_x()`` - NotImplementedError: Cannot add open end DataFrames to as_addition()-Batches! +The method automatically checks if the included variables are arrays and adds +them to ``Batch.summaries`` if they are included yet. """" diff --git a/docs/API/sites/release_notes/02_archive.rst b/docs/API/sites/release_notes/02_archive.rst index 7fd1b57e8..d2099d199 100644 --- a/docs/API/sites/release_notes/02_archive.rst +++ b/docs/API/sites/release_notes/02_archive.rst @@ -8,9 +8,608 @@ Archived release notes ====================== -------------------- -Latest (31/08/2017) -------------------- +--------------- +sd (04/06/2018) +--------------- + + + +**New**: Additional variable (names) "getter"-like and resolver methods + +* ``DataSet.created()`` +* ``DataSet.find(str_tags=None, suffixed=False)`` +* ``DataSet.names()`` +* ``DataSet.resolve_name()`` + +A bunch of new methods enhancing the options of finding and testing for variable +names have been added. ``created()`` will list all variables that have been added +to a dataset using core functions, i.e. ``add_meta()`` and ``derive()``, resp. +all helper methods that use them internally (as ``band()`` or ``categorize()`` do +for instance). + +The ``find()`` method is returning all variable names that contain any of the +provided substrings in ``str_tags``. To only consider names that end with these +strings, set ``suffixed=True``. If no ``str_tags`` are passed, the method will +use a default list of tags including ``['_rc', '_net', ' (categories', ' (NET', '_rec']``. + +Sometimes a dataset might contain "semi-duplicated" names, variables that differ +in respect to case sensitivity but have otherwise identical names. Calling +``names()`` will report such cases in a ``pd.DataFrame`` that lists all name +variants under the respective ``str.lower()`` version. If no semi-duplicates +are found, ``names()`` will simply return ``DataSet.variables()``. + +Lastly, ``resolve_name()`` can be used to return the "proper", existing representation(s) of a given variable name's spelling. + +"""" + +**New**: ``Batch.remove()`` + +Not needed batches can be removed from ``meta``, so they are not aggregated +anymore. + +"""" + +**New**: ``Batch.rename(new_name)`` + +Sometimes standard batches have long/ complex names. They can now be changed +into a custom name. Please take into account, that for most hubs the name of +omnibus batches should look like 'client ~ topic'. + +"""" + +**Update**: Handling verbatims in ``qp.Batch`` + +Instead of holding the well prepared open-end dataframe in ``batch.verbatims``, +the attribute is now filled by ``batch.add_open_ends()`` with instructions to +create the open-end dataframe. It is easier to to modify/ overwrite existing +verbatims. Therefore also a new parameter is included ``overwrite=True``. + +"""" + +**Update**: ``Batch.copy(..., b_filter=None, as_addition=False)`` + +It is now possible to define an additional filter for a copied batch and also +to set it as addition to the master batch. + +"""" + +**Update**: Regrouping the variable list using ``DataSet.order(..., regroup=True)`` + +A new parameter called ``regroup`` will instruct reordering all newly created +variables into their logical position of the dataset's main variable order, i.e. +attempting to place *derived* variables after the *originating* ones. + +"""" + +**Bugfix**: ``add_meta()`` and duplicated categorical ``values`` codes + +Providing duplicated numerical codes while attempting to create new metadata +using ``add_meta()`` will now correctly raise a ``ValueError`` to prevent +corrupting the ``DataSet``. + +>>> cats = [(1, 'A'), (2, 'B'), (3, 'C'), (3, 'D'), (2, 'AA')] +>>> dataset.add_meta('test_var', 'single', 'test label', cats) +ValueError: Cannot resolve category definition due to code duplicates: [2, 3] + + + +--------------- +sd (04/04/2018) +--------------- + + +**New**: Emptiness handlers in ``DataSet`` and ``Batch`` classes + +* ``DataSet.empty(name, condition=None)`` +* ``DataSet.empty_items(name, condition=None, by_name=True)`` +* ``DataSet.hide_empty_items(condition=None, arrays=None)`` +* ``Batch.hide_empty(xks=True, summaries=True)`` + +``empty()`` is used to test if regular variables are completely empty, +``empty_items()`` checks the same for the items of an array mask definition. +Both can be run on lists of variables. If a single variable is tested, the former +returns simply boolean, the latter will list all empty items. If lists are checked, +``empty()`` returns the sublist of empty variables, ``empty_items()`` is mapping +the list of empty items per array name. The ``condition`` parameter of these +methods takes a ``Quantipy logic`` expression to restrict the test to a subset +of the data, i.e. to check if variables will be empty if the dataset is filtered +a certain way. A very simple example: + +>>> dataset.add_meta('test_var', 'int', 'Variable is empty') +>>> dataset.empty('test_var') +True + +>>> dataset[dataset.take({'gender': 1}), 'test_var'] = 1 +>>> dataset.empty('test_var') +False + +>>> dataset.empty('test_var', {'gender': 2}) +True + + +The ``DataSet`` method ``hide_empty_items()`` uses the emptiness tests to +automatically apply a **hiding rule** on all empty items found in the dataset. +To restrict this to specific arrays only, their names can be provided via the +``arrays`` argument. ``Batch.hide_empty()`` takes into account the current +``Batch.filter`` setup and by drops/hides *all* relevant empty variables from the +``xks`` list and summary aggregations by default. Summaries that would end up without valid +items because of this are automatically removed from the ``summaries`` collection +and the user is warned. + +"""" + +**New**: ``qp.set_option('fast_stack_filters', True)`` + +A new option to enable a more efficient test for already existing filters +inside the ``qp.Stack`` object has been added. Set the ``'fast_stack_filters'`` +option to ``True`` to use it, the default is ``False`` to ensure compatibility +in different versions of production DP template workspaces. + +"""" + +**Update**: ``Stack.add_stats(..., factor_labels=True, ...)`` + +The parameter ``factor_labels`` is now also able to take the string ``'()'``, +then factors are written in the normal brackets next to the label (instead +of ``[]``). + +In the new version factor_labels are also just added if there are none included +before, except new scales are used. + +"""" + +**Bugfix**: ``DataSet`` ``np.NaN`` insertion to ``delimited_set`` variables + +``np.NaN`` was incorrectly transformed when inserted into ``delimited_set`` +before, leading to either ``numpy`` type conflicts or type casting exceptions. +This is now fixed. + + + +--------------- +sd (27/02/2018) +--------------- + +**New**: ``DataSet._dimensions_suffix`` + +``DataSet`` has a new attribute ``_dimensions_suffix``, which is used as mask +suffix while running ``DataSet.dimensionize()``. The default is ``_grid`` and +it can be modified with ``DataSet.set_dim_suffix()``. + +"""" + +**Update**: ``Stack._get_chain()`` (old chain) + +The method is speeded-up. If a filter is already included in the Stack, it is +not calculated from scratch anymore. Additionally the method has a new parameter +``described``, which takes a describing dataframe of the Stack, so it no longer +needs to be calculated in each loop. + +"""" +**Update**: ``Stack.add_nets()`` (recoded ``Views``) + +Nets that are applied on array variables will now also create a new recoded +array that reflects the net definitions if ``recoded`` is used. The +method has been creating only the item versions before. + +"""" + +**Update**: ``Stack.add_stats()`` + +The method will now create a new metadata property called ``'factor'`` for each +variable it is applied on. You can only have one factor assigned to one +categorical value, so for multiple statistic definitions (exclusions, etc.) +it will get overwritten. + +"""" + +**Update**: ``DataSet.from_batch()`` (``additions`` parameter) + +The ``additions`` parameter has been updated to also be able to create recoded +variables from existing "additional" Batches that are attached to a parent one. +Filter variables will get the new meta ``'properties'`` tag ``'recoded_filter'`` +and only have one category (``1``, ``'active'``). They are named simply +``'filter_1'``, ``'filter_2'`` and so on. The new possible values of the +parameters are now: + + * ``None``: ``as_addition()``-Batches are not considered. + * ``'variables'``: Only cross- and downbreak variables are considered. + * ``'filters'``: Only filters are recoded. + * ``'full'``: ``'variables'`` + ``'filters'`` + +"""" + +**Bugfix**: ``ViewManager._request_views()`` + +Cumulative sums are only requested if they are included in the belonging +``Stack``. Additionally the correct related sig-tests are now taken for +cumulative sums. + +--------------- +sd (12/01/2018) +--------------- + +**New**: ``Audit`` + +``Audit`` is a new class which takes ``DataSet`` instances, compares and aligns +them. + +The class compares/ reports/ aligns the following aspects: + + * datasets are valid (``DataSet.validate()``) + * mismatches (variables are not included in all datasets) + * different types (variables are in more than one dataset, but have different types) + * labels (variables are in more than one dataset, but have different labels for the same text_key) + * value codes (variables are in more than one dataset, but have different value codes) + * value texts (variables are in more than one dataset, but have different value texts) + * array items (arrays are in more than one dataset, but have different items) + * item labels (arrays are in more than one dataset, but their items have different labels) + +This is the first draft of the class, so it will need some testing and probably +adjustments. + +"""" + +**New**: ``DataSet.reorder_items(name, new_order)`` + +The new method reorders the items of the included array. The ints in the +``new_order`` list match up to the number of the items +(``DataSet.item_no('item_name')``), not to the position. + +"""" + +**New**: ``DataSet.valid_tks``, Arabic + +Arabic (``ar-AR``) is included as default valid text-key. + +"""" + +**New**: ``DataSet.extend_items(name, ext_items, text_key=None)`` + +The new method extends the items of an existing array. + +"""" + +**Update**: ``DataSet.set_missings()`` + +The method is now limited to ``DataSet``, ``Batch`` does not inherit it. + +"""" + +**Update**: ``DataSet`` + +The whole class is reordered and cleaned up. Some new deprecation warnings +will appear. + +"""" + +**Update**: ``DataSet.add_meta()`` / ``DataSet.derive()`` + +Both methods will now raise a ``ValueError: Duplicated codes provided. Value codes must be unique!`` +if categorical ``values`` definitions try to apply duplicated codes. + +"""" + +--------------- +sd (18/12/2017) +--------------- + + +**New**: ``Batch.remove_filter()`` + +Removes all defined (global + extended) filters from a Batch instance. + +"""" + +**Update**: ``Batch.add_filter()`` + +It's now possible to extend the global filter of a Batch instance. These options +are possible. + +Add first filter:: + + >>> batch.filter, batch.filter_names + 'no_filter', ['no_filter'] + >>> batch.add_filter('filter1', logic1) + >>> batch.filter, batch.filter_names + {'filter1': logic1}, ['filter1'] + +Extend filter:: + + >>> batch.filter, batch.filter_names + {'filter1': logic}, ['filter1'] + >>> batch.add_filter('filter2', logic2) + >>> batch.filter, batch.filter_names + {'filter1' + 'filter2': intersection([logic1, logic2])}, ['filter1' + 'filter2'] + +Replace filter:: + + >>> batch.filter, batch.filter_names + {'filter1': logic}, ['filter1'] + >>> batch.add_filter('filter1', logic2) + >>> batch.filter, batch.filter_names + {'filter1': logic2}, ['filter1'] + +"""" + +**Update**: ``Stack.add_stats(..., recode)`` + +The new parameter ``recode`` defines if a new numerical variable is created which +satisfies the stat definitions. + +"""" + +**Update**: ``DataSet.populate()`` + +A progress tracker is added to this method. + +"""" + +**Bugfix**: ``Batch.add_open_ends()`` + +``=`` is removed from all responsess in the included variables, as it causes +errors in the Excel-Painter. + +"""" + +**Bugfix**: ``Batch.extend_x()`` and ``Batch.extend_y()`` + +Check if included variables exist and unroll included masks. + +"""" + +**Bugfix**: ``Stack.add_nets(..., calc)`` + +If the operator in calc is ``div``/ ``/``, the calculation is now performed +correctly. + +"""" + +--------------- +sd (28/11/2017) +--------------- + +**New** ``DataSet.from_batch()`` + +Creates a new ``DataSet`` instance out of ``Batch`` definitions (xks, yks, +filter, weight, language, additions, edits). + +"""" + +**New**: ``Batch.add_total()`` + +Defines if total column ``@`` should be included in the downbreaks (yks). + +"""" + +**New**: ``Batch.set_unwgt_counts()`` + +If cellitems are ``cp`` and a weight is provided, it is possible to request +unweighted count views (percentages are still weighted). + +"""" + +**Update**: ``Batch.add_y_on_y(name, y_filter=None, main_filter='extend')`` + +Multiple ``y_on_y`` aggregations can now be added to a ``Batch`` instance +and each can have an own filter. The y_on_y-filter can ``extend`` or ``replace`` +the main_filter of the ``Batch``. + +"""" + +**Update**: ``Stack.add_nets(..., recode)`` + +The new parameter ``recode`` defines if a new variable is created which +satisfies the net definitions. Different options for ``recode`` are: + + * ``'extend_codes'``: The new variable contains all codes of the original + variable and all nets as new categories. + * ``'drop_codes'``: The new variable contains only all nets as new categories. + * ``'collect_codes'`` or ``'collect_codes@cat_name'``: The new variable contains + all nets as new categories and another new category which sums all cases that + are not in any net. The new category text can be defined by adding ``@cat_name`` + to ``collect_codes``. If none is provided ``Other`` is used as default. + +"""" + +**Update**: ``Stack.add_nets()`` + +If a variable in the ``Stack`` already has a net_view, it gets overwritten +if a new net is added. + +"""" + +**Update**: ``DataSet.set_missings(..., missing_map)`` + +The parameter ``missing_map`` can also handle lists now. All included +codes are be flagged as ``'exclude'``. + +"""" + +**Update**: ``request_views(..., sums='mid')`` (``ViewManager``/``query.py``) + +Allow different positions for sums in the view-order. They can be placed in +the middle (``'mid'``) between the basics/ nets and the stats or at the +``'bottom'`` after the stats. + +"""" + +**Update/ New**: ``write_dimensions()`` + +Converting qp data to mdd and ddf files by using ``write_dimensions()`` is +updated now. A bug regarding encoding texts is fixed and additionally all +included ``text_keys`` in the meta are transferred into the mdd. Therefore +two new classes are included: ``DimLabels`` and ``DimLabel``. + +--------------- +sd (13/11/2017) +--------------- + +**New** ``DataSet.to_delimited_set(name, label, variables, + from_dichotomous=True, codes_from_name=True)`` + +Creates a new delimited set variable out of other variables. If the input- +variables are dichotomous (``from_dichotomous``), the new value-codes can be +taken from the variable-names or from the order of the variables +(``codes_from_name``). + +"""" + +**Update** ``Stack.aggregate(..., bases={})`` + +A dictionary in form of:: + + bases = { + 'cbase': { + 'wgt': True, + 'unwgt': False}, + 'cbase_gross': { + 'wgt': True, + 'unwgt': True}, + 'ebase': { + 'wgt': False, + 'unwgt': False} + } + +defines what kind of bases will be aggregated. If ``bases`` is provided the +old parameter ``unweighted_base`` and any bases in the parameter ``views`` +will be ignored. If bases is not provided and any base is included in ``views``, +a dictionary is automatically created out of ``views`` and ``unweighted_base``. + +--------------- +sd (17/10/2017) +--------------- + + +**New**: ``del DataSet['var_name']`` and ``'var_name' in DataSet`` syntax support + +It is now possible to test membership of a variable name simply using the ``in`` +operator instead of ``DataSet.var_exists('var_name')`` and delete a variable definition +from ``DataSet`` using the ``del`` keyword inplace of the ``drop('var_name')`` +method. + +"""" + +**New**: ``DataSet.is_single(name)``, ``.is_delimited_set(name)``, ``.is_int(name)``, ``.is_float(name)``, ``.is_string(name)``, ``.is_date(name)``, ``.is_array(name)`` + +These new methods make testing a variable's type easy. + +"""" + +**Update**: ``DataSet.singles(array_items=True)`` and all other non-``array`` type iterators + +It is now possible to exclude ``array`` items from ``singles()``, ``delimited_sets()``, +``ints()`` and ``floats()`` variable lists by setting the new ``array_items`` +parameter to ``False``. + +"""" + +**Update**: ``Batch.set_sigtests(..., flags=None, test_total=None)``, ``Batch.sigproperties`` + +The significancetest-settings for flagging and testing against total, can now +be modified by the two parameters ``flags`` and ``test_total``. The ``Batch`` +attribute ``siglevels`` is removed, instead all sig-settings are stored +in ``Batch.sigproperties``. + +"""" + +**Update**: ``Batch.make_summaries(..., exclusive=False)``, ``Batch.skip_items`` + +The new parameter ``exclusive`` can take a list of arrays or a boolean. If a list +is included, these arrays are added to ``Batch.skip_items``, if it is True all +variables from ``Batch.summaries`` are added to ``Batch.skip_items`` + +"""" + +**Update**: ``quantipy.sandbox.sandbox.Chain.paint(..., totalize=True)`` + +If ``totalize`` is ``True``, ``@``-Total columns of a (x-oriented) ``Chain.dataframe`` +will be painted as ``'Total'`` instead of showing the corresponsing ``x``-variables +question text. + +"""" + +**Update**: ``quantipy.core.weights.Rim.Rake`` + +The weighting algorithm's ``generate_report()`` method can be caught up in a +``MemoryError`` for complex weight schemes run on very large sample sizes. This +is now prevented to ensure the weight factors are computed with priority and +the algorithm is able to terminate correctly. A warning is raised:: + + UserWarning: OOM: Could not finish writing report... + +"""" + +**Update**: ``Batch.replace_y()`` + +Conditional replacements of y-variables of a ``Batch`` will now always also +automatically add the ``@``-Total indicator if not provided. + +"""" + +**Bugfix**: ``DataSet.force_texts(..., overwrite=True)`` + +Forced overwriting of existing ``text_key`` meta data was failing for ``array`` +``mask`` objects. This is now solved. + +"""" + +--------------- +sd (15/09/2017) +--------------- + +**New**: ``DataSet.meta_to_json(key=None, collection=None)`` + +The new method allows saving parts of the metadata as a json file. The parameters +``key`` and ``collection`` define the metaobject which will be saved. + +"""" + +**New**: ``DataSet.save()`` and ``DataSet.revert()`` + +These two new methods are useful in interactive sessions like **Ipython** or +**Jupyter** notebooks. ``save()`` will make a temporary (only im memory, not +written to disk) copy of the ``DataSet`` and store its current state. You can +then use ``revert()`` to rollback to that snapshot of the data at a later +stage (e.g. a complex recode operation went wrong, reloading from the physical files takes +too long...). + +"""" + +**New**: ``DataSet.by_type(types=None)`` + +The ``by_type()`` method is replacing the soon to be deprecated implementation +of ``variables()`` (see below). It provides the same functionality +(``pd.DataFrame`` summary of variable types) as the latter. + +"""" + +**Update**: ``DataSet.variables()`` absorbs ``list_variables()`` and ``variables_from_set()`` + +In conjunction with the addition of ``by_type()``, ``variables()`` is +replacing the related ``list_variables()`` and ``variables_from_set()`` methods in order to offer a unified solution for querying the ``DataSet``\'s (main) variable collection. + +"""" + +**Update**: ``Batch.as_addition()`` + +The possibility to add multiple cell item iterations of one ``Batch`` definition +via that method has been reintroduced (it was working by accident in previous +versions with subtle side effects and then removed). Have fun! + +"""" + +**Update**: ``Batch.add_open_ends()`` + +The method will now raise an ``Exception`` if called on a ``Batch`` that has +been added to a parent one via ``as_addition()`` to warn the user and prevent +errors at the build stage:: + + NotImplementedError: Cannot add open end DataFrames to as_addition()-Batches! + +--------------- +sd (31/08/2017) +--------------- **New**: ``DataSet.code_from_label(..., exact=True)`` @@ -54,7 +653,7 @@ of the additional ``yks``. """" -**Update**: ``Batch.add_open_ends(... replacements)`` +**Update**: ``Batch.add_open_ends(..., replacements)`` The new parameter ``replacements`` is implemented. The method loops over the whole pd.DataFrame and replaces all keys of the included ``dict`` diff --git a/qplogo_invert.png b/qplogo_invert.png deleted file mode 100644 index ae0b728c3..000000000 Binary files a/qplogo_invert.png and /dev/null differ diff --git a/quantipy/__init__.py b/quantipy/__init__.py index fd50ca3f3..50480928f 100644 --- a/quantipy/__init__.py +++ b/quantipy/__init__.py @@ -12,6 +12,7 @@ from quantipy.core.view_generators.view_mapper import ViewMapper from quantipy.core.view_generators.view_maps import QuantipyViews from quantipy.core.view_generators.view_specs import (net, calc, ViewManager) +from quantipy.core.helpers.functions import parrot import quantipy.core.helpers.functions as helpers import quantipy.core.tools.dp as dp import quantipy.core.tools.view as v @@ -31,4 +32,5 @@ from quantipy.core.builds.powerpoint.pptx_painter import PowerPointPainter -from quantipy.version import version as __version__ \ No newline at end of file +from quantipy.version import version as __version__ + diff --git a/quantipy/core/batch.py b/quantipy/core/batch.py index 6799eaa74..907e428e6 100644 --- a/quantipy/core/batch.py +++ b/quantipy/core/batch.py @@ -17,7 +17,7 @@ not_any, not_all, not_count, is_lt, is_ne, is_gt, is_le, is_eq, is_ge, - union, intersection) + union, intersection, get_logic_index) def meta_editor(self, dataset_func): """ @@ -28,8 +28,23 @@ def edit(*args, **kwargs): name = args[0] if args else kwargs['name'] if not isinstance(name, list): name = [name] # create DataSet clone to leave global meta data untouched - ds_clone = self.clone() + if self.edits_ds is None: + self.edits_ds = qp.DataSet.clone(self) + ds_clone = self.edits_ds var_edits = [] + # args/ kwargs for min_value_count + if dataset_func.func_name == 'min_value_count': + if len(args) < 3 and not 'weight' in kwargs: + kwargs['weight'] = self.weights[0] + + if len(args) < 4 and not 'condition' in kwargs: + if self.filter: + kwargs['condition'] = self.filter.values()[0] + # args/ kwargs for sorting + elif dataset_func.func_name == 'sorting': + if len(args) < 7 and not 'sort_by_weight' in kwargs: + kwargs['sort_by_weight'] = self.weights[0] + for n in name: is_array = self.is_array(n) is_array_item = self._is_array_item(n) @@ -54,7 +69,7 @@ def edit(*args, **kwargs): # use qp.DataSet method to apply the edit dataset_func(ds_clone, *args, **kwargs) # grab edited meta data and collect via Batch.meta_edits attribute - for n in name: + for n in self.unroll(name, both='all'): if not self.is_array(n): meta = ds_clone._meta['columns'][n] text_edits = ['set_col_text_edit', 'set_val_text_edit'] @@ -67,6 +82,8 @@ def edit(*args, **kwargs): if ds_clone._has_categorical_data(n): self.meta_edits['lib'][n] = ds_clone._meta['lib']['values'][n] self.meta_edits[n] = meta + if dataset_func.func_name in ['hiding', 'slicing', 'min_value_count', 'sorting']: + self._update() return edit def not_implemented(dataset_func): @@ -91,12 +108,17 @@ def __init__(self, dataset, name, ci=['c', 'p'], weights=None, tests=None): self.name = name meta, data = dataset.split() self._meta = meta - self._data = data.copy() + self._data = data + self.edits_ds = None self.valid_tks = dataset.valid_tks self.text_key = dataset.text_key self.sample_size = None self._verbose_errors = dataset._verbose_errors self._verbose_infos = dataset._verbose_infos + self._dimensions_comp = dataset._dimensions_comp + + # RENAMED DataSet methods + self._dsfilter = qp.DataSet.filter.__func__ if sets['batches'].get(name): if self._verbose_infos: @@ -106,85 +128,93 @@ def __init__(self, dataset, name, ci=['c', 'p'], weights=None, tests=None): sets['batches'][name] = {'name': name, 'additions': []} self.xks = [] self.yks = ['@'] + self._variables = [] + self._section_starts = {} self.total = True - self.extended_yks_global = None self.extended_yks_per_x = {} self.exclusive_yks_per_x = {} self.extended_filters_per_x = {} - self.filter = 'no_filter' - self.filter_names = ['no_filter'] + self.filter = None + self.filter_names = [] self.x_y_map = None self.x_filter_map = None self.y_on_y = [] self.y_on_y_filter = {} - self.y_filter_map = None + self.y_filter_map = {} self.forced_names = {} - self.summaries = [] - self.transposed_arrays = {} + self.transposed = [] + self.leveled = {} + # self.summaries = [] + # self.transposed_arrays = {} self.skip_items = [] - self.verbatims = OrderedDict() - self.verbatim_names = [] + self.verbatims = [] + # self.verbatim_names = [] self.set_cell_items(ci) # self.cell_items self.unwgt_counts = False self.set_weights(weights) # self.weights self.set_sigtests(tests) # self.sigproperties self.additional = False self.meta_edits = {'lib': {}} + self.build_info = {} self.set_language(dataset.text_key) # self.language self._update() # DECORATED / OVERWRITTEN DataSet methods # self.hide_empty_items = meta_editor(self, qp.DataSet.hide_empty_items.__func__) self.hiding = meta_editor(self, qp.DataSet.hiding.__func__) + self.min_value_count = meta_editor(self, qp.DataSet.min_value_count.__func__) self.sorting = meta_editor(self, qp.DataSet.sorting.__func__) self.slicing = meta_editor(self, qp.DataSet.slicing.__func__) self.set_variable_text = meta_editor(self, qp.DataSet.set_variable_text.__func__) self.set_value_texts = meta_editor(self, qp.DataSet.set_value_texts.__func__) self.set_property = meta_editor(self, qp.DataSet.set_property.__func__) - # RENAMED DataSet methods - self._dsfilter = qp.DataSet.filter.__func__ # UNALLOWED DataSet methods - self.add_meta = not_implemented(qp.DataSet.add_meta.__func__) + # self.add_meta = not_implemented(qp.DataSet.add_meta.__func__) self.derive = not_implemented(qp.DataSet.derive.__func__) self.remove_items = not_implemented(qp.DataSet.remove_items.__func__) self.set_missings = not_implemented(qp.DataSet.set_missings.__func__) - def _update(self): """ Update Batch metadata with Batch attributes. """ self._map_x_to_y() self._map_x_to_filter() - self._map_y_main_filter() + self._split_level_arrays() + self._map_y_on_y_filter() self._samplesize_from_batch_filter() - for attr in ['xks', 'yks', 'filter', 'filter_names', - 'x_y_map', 'x_filter_map', 'y_on_y', - 'forced_names', 'summaries', 'transposed_arrays', 'verbatims', - 'verbatim_names', 'extended_yks_global', 'extended_yks_per_x', + attrs = self.__dict__ + for attr in ['xks', 'yks', '_variables', 'filter', 'filter_names', + 'x_y_map', 'x_filter_map', 'y_on_y', 'y_on_y_filter', + 'forced_names', 'transposed', 'leveled', 'verbatims', + 'extended_yks_per_x', 'exclusive_yks_per_x', 'extended_filters_per_x', 'meta_edits', 'cell_items', 'weights', 'sigproperties', 'additional', 'sample_size', 'language', 'name', 'skip_items', 'total', - 'unwgt_counts', 'y_on_y_filter', 'y_filter_map']: - attr_update = {attr: self.__dict__.get(attr)} + 'unwgt_counts', 'y_filter_map', 'build_info', + '_section_starts' + ]: + attr_update = {attr: attrs.get(attr, attrs.get('_{}'.format(attr)))} self._meta['sets']['batches'][self.name].update(attr_update) def _load_batch(self): """ Fill batch attributes with information from meta. """ - for attr in ['xks', 'yks', 'filter', 'filter_names', - 'x_y_map', 'x_filter_map', 'y_on_y', - 'forced_names', 'summaries', 'transposed_arrays', 'verbatims', - 'verbatim_names', 'extended_yks_global', 'extended_yks_per_x', + bdefs = self._meta['sets']['batches'][self.name] + for attr in ['xks', 'yks', '_variables', 'filter', 'filter_names', + 'x_y_map', 'x_filter_map', 'y_on_y', 'y_on_y_filter', + 'forced_names', 'transposed', 'leveled', 'verbatims', + 'extended_yks_per_x', 'exclusive_yks_per_x', 'extended_filters_per_x', 'meta_edits', 'cell_items', 'weights', 'sigproperties', 'additional', 'sample_size', 'language', 'skip_items', 'total', 'unwgt_counts', - 'y_on_y_filter', 'y_filter_map']: - attr_load = {attr: self._meta['sets']['batches'][self.name].get(attr)} + 'y_filter_map', 'build_info', '_section_starts' + ]: + attr_load = {attr: bdefs.get(attr, bdefs.get('_{}'.format(attr)))} self.__dict__.update(attr_load) - def copy(self, name): + def clone(self, name, b_filter=None, as_addition=False): """ Create a copy of Batch instance. @@ -192,6 +222,11 @@ def copy(self, name): ---------- name: str Name of the Batch instance that is copied. + b_filter: tuple (str, dict/ complex logic) + Filter logic which is applied on the new batch. + (filtername, filterlogic) + as_addition: bool, default False + If True, the new batch is added as addition to the master batch. Returns ------- @@ -205,18 +240,59 @@ def copy(self, name): batch_copy = self.get_batch(name) self.set_verbose_infomsg(verbose) batch_copy.set_verbose_infomsg(verbose) - if len(batch_copy.verbatims): - batch_copy.verbatims = {} - batch_copy.verbatim_names = [] - if self._verbose_infos: - warning = ("Copied Batch '{}' contains open end data summaries...\n" - "Any filters added to the copy will not persist " - "on verbatims so they have been removed! " - "Please add them again!") - warnings.warn(warning.format(name)) + if b_filter: + batch_copy.add_filter(b_filter[0], b_filter[1]) + if batch_copy.verbatims and b_filter and not as_addition: + for oe in batch_copy.verbatims: + oe["filter"] = batch_copy.filter + if as_addition: + batch_copy.as_addition(self.name) batch_copy._update() return batch_copy + def remove(self): + """ + Remove instance from meta object. + """ + name = self.name + adds = self._meta['sets']['batches'][name]['additions'] + if adds: + for bname, bdef in self._meta['sets']['batches'].items(): + if bname == name: continue + for add in adds[:]: + if add in bdef['additions']: + adds.remove(add) + for add in adds: + self._meta['sets']['batches'][add]['additional'] = False + + del(self._meta['sets']['batches'][name]) + if self._verbose_infos: + print "Batch '%s' is removed from meta-object." % name + self = None + return None + + def _rename_in_additions(self, find_bname, new_name): + for bname, bdef in self._meta['sets']['batches'].items(): + if find_bname in bdef['additions']: + adds = bdef['additions'] + adds[adds.index(find_bname)] = new_name + bdef['additions'] = adds + return None + + def rename(self, new_name): + """ + Rename instance, updating ``DataSet`` references to the definiton, too. + """ + if new_name in self._meta['sets']['batches']: + raise KeyError("'%s' is already included!" % new_name) + batches = self._meta['sets']['batches'] + org_name = self.name + batches[new_name] = batches.pop(org_name) + self._rename_in_additions(org_name, new_name) + self.name = new_name + self._update() + return None + @modify(to_list='ci') def set_cell_items(self, ci): """ @@ -336,8 +412,7 @@ def as_addition(self, batch_name): """ self._meta['sets']['batches'][batch_name]['additions'].append(self.name) self.additional = True - self.verbatims = {} - self.verbatim_names = [] + self.verbatims = [] self.y_on_y = [] self.y_on_y_filter = {} if self._verbose_infos: @@ -347,14 +422,62 @@ def as_addition(self, batch_name): self._update() return None - @modify(to_list='xks') - def add_x(self, xks): + def as_main(self, keep=True): """ - Set the x (downbreak) variables of the Batch. + Transform additional ``Batch`` definitions into regular (parent/main) ones. Parameters ---------- - xks: str, list of str, dict, list of dict + keep : bool, default True + ``False`` will drop the original related parent Batch, while the + default is to keep it. + + Returns + ------- + None + """ + if not self.additional: return None + self.additional = False + bmeta = self._meta['sets']['batches'] + parent = self._adds_per_mains(True)[self.name] + for p in parent: + if not keep: + del bmeta[p] + else: + bmeta[p]['additions'].remove(self.name) + self._update() + + @modify(to_list='varlist') + def add_variables(self, varlist): + """ + Text + + Parameters + ---------- + varlist : list + A list of variable names. + + Returns + ------- + None + """ + self._variables = [] + if '@' in varlist: varlist.remove('@') + if '@1' in varlist: varlist.remove('@1') + for v in varlist: + if not v in self._variables: + self._variables.append(v) + self._update() + return None + + @modify(to_list='dbrk') + def add_downbreak(self, dbrk): + """ + Set the downbreak (x) variables of the Batch. + + Parameters + ---------- + dbrk: str, list of str, dict, list of dict Names of variables that are used as downbreaks. Forced names for Excel outputs can be given in a dict, for example: xks = ['q1', {'q2': 'forced name for q2'}, 'q3', ....] @@ -363,13 +486,22 @@ def add_x(self, xks): ------- None """ - clean_xks = self._check_forced_names(xks) + clean_xks = self._check_forced_names(dbrk) self.xks = self.unroll(clean_xks, both='all') self._update() - masks = [x for x in self.xks if x in self.masks()] - self.make_summaries(masks, []) return None + @modify(to_list='xks') + def add_x(self, xks): + """ + Deprecated! Set the x (downbreak) variables of the Batch. + + """ + w = ("'add_x()' will be deprecated in a future version. " + "Please use 'add_downbreak()' instead!") + warnings.warn(w) + self.add_downbreak(xks) + @modify(to_list=['ext_xks']) def extend_x(self, ext_xks): """ @@ -393,91 +525,193 @@ def extend_x(self, ext_xks): for x in ext_xks: if isinstance(x, dict): for pos, var in x.items(): + if pos not in self: + raise KeyError('{} is not included.'.format(pos)) + elif self._is_array_item(pos): + msg = '{}: Cannot use an array item as position' + raise ValueError(msg.format(pos)) if not isinstance(var, list): var = [var] - var = self.unroll(var, both='all') - for v in var: - if not self.var_exists(pos): - raise KeyError('{} is not included.'.format(pos)) - elif not v in self.xks: - self.xks.insert(self.xks.index(pos), v) - elif not self.var_exists(x): - raise KeyError('{} is not included.'.format(x)) - elif x not in self.xks: - self.xks.extend(self.unroll(x, both='all')) + for v in self.unroll(var, both="all"): + if v in self.xks: + msg = '{} is already included as downbreak.' + raise ValueError(msg.format(v)) + self.xks.insert(self.xks.index(pos), v) + else: + for var in self.unroll(x, both="all"): + if var not in self: + raise KeyError('{} is not included.'.format(var)) + self.xks.append(var) + self._update() + return None + + def add_section(self, x_anchor, section): + """ + """ + if not isinstance(section, (unicode, str)): + raise TypeError("'section' must be a string.") + if x_anchor in self.xks: + self._section_starts[x_anchor] = section self._update() return None - @modify(to_list=['arrays']) - @verify(variables={'arrays': 'masks'}) - def make_summaries(self, arrays, exclusive=False): + @property + def sections(self): """ - Summary tables are created for defined arrays. + """ + if not self._section_starts: return None + sects = self._section_starts + full_sections = OrderedDict() + rev_full_sections = OrderedDict() + last_group = None + for x in self.xks: + if x in sects: + full_sections[x] = sects[x] + last_group = sects[x] + else: + full_sections[x] = last_group + for k, v in full_sections.items(): + if v in rev_full_sections: + rev_full_sections[v].append(k) + else: + rev_full_sections[v] = [k] + if None in rev_full_sections.keys(): + del rev_full_sections[None] + return rev_full_sections + + @verify(variables={'name': 'columns'}, categorical='name') + def codes_in_data(self, name): + """ + Get a list of codes that exist in (batch filtered) data. + """ + slicer = self.manifest_filter(self.filter) + data = self._data.copy().ix[slicer, name] + if self.is_delimited_set(name): + if not data.dropna().empty: + data_codes = data.str.get_dummies(';').columns.tolist() + data_codes = [int(c) for c in data_codes] + else: + data_codes = [] + else: + data_codes = pd.get_dummies(data).columns.tolist() + return data_codes + + def hide_empty(self, xks=True, summaries=True): + """ + Drop empty variables and hide array items from summaries. + + Parametes + --------- + xks : bool, default True + Controls dropping "regular" variables and array items due to being + empty. + summaries : bool, default True + Controls whether or not empty array items are hidden (by applying + rules) in summary aggregations. Summaries that would end up with + no valid items are automatically dropped altogether. - Parameters - ---------- - arrays: str/ list of str - List of arrays for which summary tables are created. Summary tables - can only be created for arrays that are included in ``self.xks``. - exclusive: bool/ list, default False - If True only summaries are created and items skipped. ``exclusive`` - parameter can be provided for a selection of arrays. Example:: - >>> b.make_summaries(['array1', 'array2'], exclusive = ['array2']) Returns ------- None """ - if any(a not in self.xks for a in arrays): - msg = '{} not defined as xks.'.format([a for a in arrays if not a in self.xks]) - raise ValueError(msg) - self.summaries = arrays - if exclusive: - if isinstance(exclusive, bool): - self.skip_items = arrays - else: - self.skip_items = [a for a in exclusive if a in arrays] - else: - self.skip_items = [] - if arrays: - msg = 'Array summaries setup: Creating {}.'.format(arrays) - else: - msg = 'Array summaries setup: Creating no summaries!' - if self._verbose_infos: - print msg - for t_array in self.transposed_arrays.keys(): - if not t_array in arrays: - self.transposed_arrays.pop(t_array) + cond = {self.filter: 0} if self.filter else None + removed_sum = [] + for x in self.xks[:]: + if self.is_array(x): + e_items = self.empty_items(x, cond, False) + if not e_items: continue + sources = self.sources(x) + if summaries: + self.hiding(x, e_items, axis='x', hide_values=False) + if len(e_items) == len(sources): + if x in self.xks: self.xks.remove(x) + removed_sum.append(x) + if xks: + for i in e_items: + if sources[i-1] in self.xks: + self.xks.remove(sources[i-1]) + elif not self._is_array_item(x): + if cond: + s = self[self.take(cond), x] + else: + s = self[x] + if s.count() == 0: + self.xks.remove(x) + if removed_sum: + msg = "Dropping summaries for {} - all items hidden!" + warnings.warn(msg.format(removed_sum)) + self._update() + return None + + def make_summaries(self, arrays, exclusive=False, _verbose=None): + """ + Deprecated! Summary tables are created for defined arrays. + """ + msg = ("Depricated! `make_summaries()` is not available anymore, please" + " use `exclusive_arrays()` to skip items.") + raise NotImplementedError(msg) + + def transpose_arrays(self, arrays, replace=False): + """ + Deprecated! Transposed summary tables are created for defined arrays. + """ + msg = ("Depricated! `transpose_arrays()` is not available anymore, " + "please use `transpose()` instead.") + raise NotImplementedError(msg) + + @modify(to_list=['array']) + @verify(variables={'array': 'masks'}) + def exclusive_arrays(self, array): + """ + For defined arrays only summary tables are produced. Items get ignored. + """ + not_valid = [a for a in array if a not in self.xks] + if not_valid: + raise ValueError('{} not defined as xks.'.format(not_valid)) + self.skip_items = array + self._update() + return None + + @modify(to_list='name') + @verify(variables={'name': 'both'}) + def transpose(self, name): + """ + Create transposed aggregations for the requested variables. + + Parameters + ---------- + name: str/ list of str + Name of variable(s) for which transposed aggregations will be + created. + """ + not_valid = [n for n in name if n not in self.xks] + if not_valid: + raise ValueError('{} not defined as xks.'.format(not_valid)) + self.transposed = name self._update() return None - @modify(to_list='arrays') - @verify(variables={'arrays': 'masks'}) - def transpose_arrays(self, arrays, replace=True): + @modify(to_list='array') + @verify(variables={'array': 'masks'}) + def level(self, array): """ - Transposed summary tables are created for defined arrays. + Produce leveled (a flat view of all item reponses) array aggregations. Parameters ---------- - arrays: str/ list of str - List of arrays for which transposed summary tables are created. - Transposed summary tables can only be created for arrays that are - included in ``self.xks``. - replace: bool, default True - If True only the transposed table is created, if False transposed - and normal summary tables are created. + array: str/ list of str + Names of the arrays to add the levels to. Returns ------- None """ - if any(a not in self.xks for a in arrays): - msg = '{} not defined as xks.'.format([a for a in arrays if not a in self.xks]) - raise ValueError(msg) - if any(a not in self.summaries for a in arrays): - ar = list(set(self.summaries + arrays)) - a = [v for v in self.xks if v in ar] - self.make_summaries(a, []) - for array in arrays: - self.transposed_arrays[array] = replace + not_valid = [a for a in array if a not in self.xks] + if not_valid: + raise ValueError('{} not defined as xks.'.format(not_valid)) + for a in array: + self.leveled[a] = self.yks + if not '{}_level'.format(a) in self: + self._level(a) self._update() return None @@ -490,18 +724,18 @@ def add_total(self, total=True): if self._verbose_infos: print 'sigtests are removed from batch.' self.total = total - self.add_y(self.yks) + self.add_crossbreak(self.yks) return None - @modify(to_list='yks') - @verify(variables={'yks': 'both'}, categorical='yks') - def add_y(self, yks): + @modify(to_list='xbrk') + @verify(variables={'xbrk': 'both_nested'}, categorical='xbrk') + def add_crossbreak(self, xbrk): """ Set the y (crossbreak/banner) variables of the Batch. Parameters ---------- - yks: str, list of str + xbrk: str, list of str Variables that are added as crossbreaks. '@'/ total is added automatically. @@ -509,7 +743,7 @@ def add_y(self, yks): ------- None """ - yks = [y for y in yks if not y=='@'] + yks = [y for y in xbrk if not y=='@'] yks = self.unroll(yks) if self.total: yks = ['@'] + yks @@ -517,23 +751,18 @@ def add_y(self, yks): self._update() return None - def add_x_per_y(self, x_on_y_map): + @modify(to_list='yks') + @verify(variables={'yks': 'both_nested'}, categorical='yks') + def add_y(self, yks): """ - Add individual combinations of x and y variables to the Batch. - - !!! Currently not implemented !!! + Deprecated! Set the y (crossbreak/banner) variables of the Batch. """ - raise NotImplementedError('NOT YET SUPPPORTED') - if not isinstance(x_on_y_map, list): x_on_y_maps = [x_on_y_map] - if not isinstance(x_on_y_maps[0], dict): - raise TypeError('Must pass a (list of) dicts!') - for x_on_y_map in x_on_y_maps: - for x, y in x_on_y_map.items(): - if not isinstance(y, list): y = [y] - if isinstance(x, tuple): x = {x[0]: x[1]} - return None + w = ("'add_y()' will be deprecated in a future version. Please use" + " 'add_crossbreak()' instead!") + warnings.warn(w) + self.add_crossbreak(yks) - def add_filter(self, filter_name, filter_logic): + def add_filter(self, filter_name, filter_logic=None, overwrite=False): """ Apply a (global) filter to all the variables found in the Batch. @@ -548,17 +777,21 @@ def add_filter(self, filter_name, filter_logic): ------- None """ - filter_name = filter_name.encode('utf-8', errors='ignore') - if not (filter_name in self.filter_names or self.filter == 'no_filter'): - old_name = self.filter.keys()[0] - n_filter = old_name + ' - ' + filter_name - n_logic = intersection([self.filter.values()[0], filter_logic]) - self.filter = {n_filter: n_logic} - self.filter_names.remove(old_name) - self.filter_names.append(n_filter) + name = self._verify_filter_name(filter_name, None) + if self.is_filter(name): + if not (filter_logic is None or overwrite): + raise ValueError("'{}' is already a filter-variable. Cannot " + "apply a new logic.".format(name)) + elif overwrite: + self.drop(name) + print 'Overwrite filter var: {}'.format(name) + self.add_filter_var(name, filter_logic, overwrite) + else: - self.filter = {filter_name: filter_logic} - self.filter_names = [filter_name] + self.add_filter_var(name, filter_logic, overwrite) + self.filter = name + if not name in self.filter_names: + self.filter_names.append(name) self._update() return None @@ -566,18 +799,19 @@ def remove_filter(self): """ Remove all defined (global + extended) filters from Batch. """ - self.filter = 'no_filter' - self.filter_names = ['no_filter'] + self.filter = None + self.filter_names = [] self.extended_filters_per_x = {} + self.y_on_y_filter = {} + self.y_filter_map = {} self._update() return None - @modify(to_list=['oe', 'break_by', 'title']) @verify(variables={'oe': 'columns', 'break_by': 'columns'}) def add_open_ends(self, oe, break_by=None, drop_empty=True, incl_nan=False, replacements=None, split=False, title='open ends', - filter_by=None): + filter_by=None, overwrite=True): """ Create respondent level based listings of open-ended text data. @@ -604,6 +838,9 @@ def add_open_ends(self, oe, break_by=None, drop_empty=True, incl_nan=False, An additional logical filter that should be applied to the case data. Any ``filter`` provided by a ``batch`` will be respected automatically. + overwrite : bool, default False + If True and used title is already existing in self.verbatims, then + it gets overwritten Returns ------- @@ -612,49 +849,71 @@ def add_open_ends(self, oe, break_by=None, drop_empty=True, incl_nan=False, if self.additional: err_msg = "Cannot add open end DataFrames to as_addition()-Batches!" raise NotImplementedError(err_msg) - def _add_oe(oe, break_by, title, drop_empty, incl_nan, filter_by): - columns = break_by + oe - oe_data = self._data.copy() - if self.filter != 'no_filter': - ds = qp.DataSet('open_ends') - ds.from_components(oe_data, self._meta, reset=False) - slicer = ds.take(self.filter.values()[0]) - oe_data = oe_data.loc[slicer, :] + dupes = [v for v in oe if v in break_by] + if dupes: + raise ValueError("'{}' included in oe and break_by.".format("', '".join(dupes))) + def _add_oe(oe, break_by, title, drop_empty, incl_nan, filter_by, overwrite, repl): if filter_by: - ds = qp.DataSet('open_ends') - ds.from_components(oe_data, self._meta, reset=False) - slicer = ds.take(filter_by) - oe_data = oe_data.loc[slicer, :] - oe_data = oe_data[columns] - if replacements: - for target, repl in replacements.items(): - oe_data.replace(target, repl, inplace=True) - for col in columns: - oe_data[col] = oe_data[col].map(lambda x: - x if isinstance(x, (int, long, float)) else - str(x).replace('=','')) - if drop_empty: - oe_data.dropna(subset=oe, how='all', inplace=True) - if not incl_nan: - for col in oe: - oe_data[col].replace(np.NaN, '', inplace=True) - self.verbatims[title] = oe_data - self.verbatim_names.extend(oe) + f_name = title if not self.filter else '%s_%s' % (self.filter, title) + f_name = self._verify_filter_name(f_name, number=True) + logic = {'label': title, 'logic': filter_by} + if self.filter: + suffix = f_name[len(self.filter)+1:] + self.extend_filter_var(self.filter, logic, suffix) + else: + self.add_filter_var(f_name, logic) + slicer = f_name + else: + slicer = self.filter + if any(oe['title'] == title for oe in self.verbatims) and not overwrite: + return None + oe = { + 'title': title, + 'filter': slicer, + 'columns': oe, + 'break_by': break_by, + 'incl_nan': incl_nan, + 'drop_empty': drop_empty, + 'replace': repl} + if any(o['title'] == title for o in self.verbatims): + for x, o in enumerate(self.verbatims): + if o['title'] == title: + self.verbatims[x] = oe + else: + self.verbatims.append(oe) + + def _check_replacements(repl): + if not repl: + return None + elif not isinstance(repl, dict): + raise ValueError("replacements must be a dict.") + else: + if all(isinstance(v, dict) for v in repl.values()): + if self.language not in repl: + raise KeyError("batch.language is not included in replacements.") + else: + return repl[self.language] + else: + return repl + + repl = _check_replacements(replacements) + if len(oe) + len(break_by) == 0: + raise ValueError("Please add any variables as 'oe' or 'break_by'.") if split: if not len(oe) == len(title): msg = "Cannot derive verbatim DataFrame 'title' with more than 1 'oe'" raise ValueError(msg) for t, open_end in zip(title, oe): open_end = [open_end] - _add_oe(open_end, break_by, t, drop_empty, incl_nan, filter_by) + _add_oe(open_end, break_by, t, drop_empty, incl_nan, filter_by, overwrite, repl) else: - _add_oe(oe, break_by, title[0], drop_empty, incl_nan, filter_by) + _add_oe(oe, break_by, title[0], drop_empty, incl_nan, filter_by, overwrite, repl) self._update() return None @modify(to_list=['ext_yks', 'on']) - @verify(variables={'ext_yks': 'columns'}) + @verify(variables={'ext_yks': 'both_nested'}) def extend_y(self, ext_yks, on=None): """ Add y (crossbreak/banner) variables to specific x (downbreak) variables. @@ -677,27 +936,22 @@ def extend_y(self, ext_yks, on=None): ------- None """ - ext_yks = [e for e in ext_yks if not e in self.yks] if not on: - self.yks.extend(ext_yks) - if not self.extended_yks_global: - self.extended_yks_global = ext_yks - else: - self.extended_yks_global.extend(ext_yks) + self.add_crossbreak(self.yks + ext_yks) else: - if any(o not in self.xks for o in on): - msg = '{} not defined as xks.'.format([o for o in on if not o in self.xks]) + not_valid = [o for o in on if not o in self.xks] + if not_valid: + msg = '{} not defined as xks.'.format(not_valid) raise ValueError(msg) - on = self.unroll(on, both='all') + on = self.unroll(on) for x in on: - x_ext_yks = [e for e in ext_yks - if not e in self.extended_yks_per_x.get(x, [])] - self.extended_yks_per_x.update({x: x_ext_yks}) - self._update() + x_ext = self.unroll(self.extended_yks_per_x.get(x, []) + ext_yks) + self.extended_yks_per_x.update({x: x_ext}) + self._update() return None @modify(to_list=['new_yks', 'on']) - @verify(variables={'new_yks': 'both', 'on': 'both'}) + @verify(variables={'new_yks': 'both_nested', 'on': 'both'}) def replace_y(self, new_yks, on): """ Replace y (crossbreak/banner) variables on specific x (downbreak) variables. @@ -714,11 +968,13 @@ def replace_y(self, new_yks, on): ------- None """ - if any(o not in self.xks for o in on): - msg = '{} not defined as xks.'.format([o for o in on if not o in self.xks]) + not_valid = [o for o in on if not o in self.xks] + if not_valid: + msg = '{} not defined as xks.'.format(not_valid) raise ValueError(msg) - on = self.unroll(on, both='all') - if not '@' in new_yks: new_yks = ['@'] + new_yks + on = self.unroll(on) + if not '@' in new_yks and self.total: + new_yks = ['@'] + new_yks for x in on: self.exclusive_yks_per_x.update({x: new_yks}) self._update() @@ -740,19 +996,17 @@ def extend_filter(self, ext_filters): None """ for variables, logic in ext_filters.items(): - if not isinstance(variables, tuple) or len(variables) == 1: + if not isinstance(variables, (list, tuple)): variables = [variables] for v in variables: - new_filter = self._combine_filters({v: logic}) - if not new_filter.keys()[0] in self.filter_names: - self.filter_names.append(new_filter.keys()[0]) - self.extended_filters_per_x.update({v: new_filter}) - if self.is_array(v): - for s in self.sources(v): - new_filter = self._combine_filters({s: logic}) - if not new_filter.keys()[0] in self.filter_names: - self.filter_names.append(new_filter.keys()[0]) - self.extended_filters_per_x.update({s: new_filter}) + if self.filter: + log = {'label': v, 'logic': logic} + f_name = '{}_{}'.format(self.filter, v) + self.extend_filter_var(self.filter, log, v) + else: + f_name = '{}_f'.format(v) + self.add_filter_var(f_name, logic) + self.extended_filters_per_x.update({v: f_name}) self._update() return None @@ -764,27 +1018,36 @@ def add_y_on_y(self, name, y_filter=None, main_filter='extend'): ---------- name: str key name for the y on y aggregation. - y_filter: dict (complex logic), default None + y_filter: str (filter var name) or dict (complex logic), default None Add a filter for the y on y aggregation. If None is provided - the main batch filter is taken. + the main batch filter is taken ('extend') or no filter logic is + applied ('replace'). main_filter: {'extend', 'replace'}, default 'extend' Defines if the main batch filter is extended or replaced by the y_on_y filter. - In order to remove all filters from the y on y aggregation set - ``y_filter='no_filter'`` and ``main_filter='replace'``. + Note: + If the y_filter is provided as a str (filter var name), + main_filter is automatically set to 'replace'. Returns ------- None """ - if not isinstance(name, str): + if not isinstance(name, basestring): raise TypeError("'name' attribute for add_y_on_y must be a str!") elif not main_filter in ['extend', 'replace'] or main_filter is None: - raise ValueError("'main_filter' mus be either 'extend' or 'replace'.") + raise ValueError("'main_filter' must be either 'extend' or 'replace'.") if not name in self.y_on_y: self.y_on_y.append(name) - self.y_on_y_filter[name] = {main_filter: y_filter} + if isinstance(y_filter, basestring): + if not self.is_filter(y_filter): + raise ValueError('{} is not a valid filter var.'.format(y_filter)) + else: + main_filter = 'replace' + self.y_on_y_filter[name] = (main_filter, y_filter) + if name in self.y_filter_map: + del self.y_filter_map[name] self._update() return None @@ -821,20 +1084,39 @@ def _get_yks(x): mapping = [] for x in self.xks: if self.is_array(x): - if x in self.summaries and not self.transposed_arrays.get(x): - mapping.append((x, ['@'])) + mapping.append((x, self.leveled.get(x, ['@']))) if not x in self.skip_items: + try: + hiding = self.meta_edits[x]['rules']['x']['dropx']['values'] + except: + hiding = self._get_rules(x).get('dropx', {}).get('values', []) for x2 in self.sources(x): - mapping.append((x2, _get_yks(x2))) - if x in self.transposed_arrays: - mapping.append(('@', [x])) + if x2 in hiding: + continue + elif x2 in self.xks: + mapping.append((x2, _get_yks(x2))) elif self._is_array_item(x) and self._maskname_from_item(x) in self.xks: continue else: mapping.append((x, _get_yks(x))) + if x in self.transposed: + mapping.append(('@', [x])) self.x_y_map = mapping return None + def _split_level_arrays(self): + _x_y_map = [] + for x, y in self.x_y_map: + if x in self.leveled.keys(): + lvl_name = '{}_level'.format(x) + _x_y_map.append((x, ['@'])) + _x_y_map.append((lvl_name, y)) + self.x_filter_map[lvl_name] = self.x_filter_map[x] + else: + _x_y_map.append((x, y)) + self.x_y_map = _x_y_map + return None + def _map_x_to_filter(self): """ Combine all defined downbreaks with its beloning filter in a map. @@ -843,47 +1125,53 @@ def _map_x_to_filter(self): ------- None """ - mapping = OrderedDict() + mapping = {} for x in self.xks: - mapping[x] = org_copy.deepcopy(self.filter) - if x in self.extended_filters_per_x: - mapping[x] = self.extended_filters_per_x[x] - if x in self._meta['masks']: - xks = self.sources(x) - for x2 in xks: - mapping[x2] = org_copy.deepcopy(self.filter) - if x2 in self.extended_filters_per_x: - mapping[x2] = self.extended_filters_per_x[x2] + if self._is_array_item(x): + continue + name = self.extended_filters_per_x.get(x, self.filter) + mapping[x] = name + if self.is_array(x): + for x2 in self.sources(x): + if x2 in self.xks: + mapping[x2] = name + if name and not name in self.filter_names: + self.filter_names.append(name) self.x_filter_map = mapping return None - def _map_y_main_filter(self): + def _map_y_on_y_filter(self): """ Get all y_on_y filters and map them with the main filter. - Returns ------- None """ - mapping = {} for y_on_y in self.y_on_y: - ext_rep, y_f = self.y_on_y_filter[y_on_y].items()[0] - if not y_f: - f = self.filter - elif ext_rep == 'extend' and y_f == 'no_filter': - f = self.filter - elif ext_rep == 'replace' and y_f == 'no_filter': - f = 'no_filter' - elif ext_rep == 'extend': - if self.filter == 'no_filter': + if y_on_y in self.y_filter_map: + continue + ext_rep, y_f = self.y_on_y_filter[y_on_y] + logic = {'label': y_on_y, 'logic': y_f} + if ext_rep == 'replace': + if not y_f: + f = None + elif isinstance(y_f, basestring): f = y_f else: - f = intersection([self.filter.values()[0], y_f]) - f = {y_on_y: f} - elif ext_rep == 'replace': - f = {y_on_y: y_f} - mapping[y_on_y] = f - self.y_filter_map = mapping + f = self._verify_filter_name(y_on_y, number=True) + self.add_filter_var(f, logic) + elif ext_rep == 'extend': + if not y_f: + f = self.filter + elif not self.filter: + f = self._verify_filter_name(y_on_y, number=True) + self.add_filter_var(f, logic) + else: + f = '{}_{}'.format(self.filter, y_on_y) + f = self._verify_filter_name(f, number=True) + suf = f[len(self.filter)+1:] + self.extend_filter_var(self.filter, logic, suf) + self.y_filter_map[y_on_y] = f return None def _check_forced_names(self, variables): @@ -917,43 +1205,176 @@ def _check_forced_names(self, variables): self.forced_names = renames return xks - def _combine_filters(self, ext_filters): + def _samplesize_from_batch_filter(self): """ - Combines existing filter in ``self.filter`` with additional filters. - - Parameters - ---------- - ext_filters: dict - dict with variable name as key, str or tupel of str, and logic - as value. For example: - ext_filters = {'q1': {'gender': 1}} - - Returns - ------- - new_filter: dict {'new_filter_name': intersection([old_logic, new_logic])} + Calculates sample_size from existing filter. """ - old_filter = self.filter - no_global_filter = old_filter == 'no_filter' - if no_global_filter: - combined_name = '(no_filter)+({})'.format(ext_filters.keys()[0]) - new_filter = {combined_name: ext_filters.values()[0]} + if self.filter: + idx = self.manifest_filter(self.filter) else: - old_filter_name = old_filter.keys()[0] - old_filter_logic = old_filter.values()[0] - new_filter_name = ext_filters.keys()[0] - new_filter_logic = ext_filters.values()[0] - combined_name = '({})+({})'.format(old_filter_name, new_filter_name) - combined_logic = intersection([old_filter_logic, new_filter_logic]) - new_filter = {combined_name: combined_logic} - return new_filter + idx = self._data.index + self.sample_size = len(idx) + return None - def _samplesize_from_batch_filter(self): + @modify(to_list=["mode", "misc"]) + def to_dataset(self, mode=None, from_set="data file", additions="sort_within", + manifest_edits="keep", integrate_rc=(["_rc", "_rb"], True), + misc=["RecordNo", "caseid", "identity"]): """ - Calculates sample_size from existing filter. + Create a qp.DataSet instance out of the batch settings. + + Parameters + ---------- + mode: list of str {'x', 'y', 'v', 'oe', 'w', 'f'} + Variables to keep. + from_set: str or list of str, default None + Set name or a list of variables to sort against. + additions: str {'sort_within, sort_between', False} + Add variables from additional batches. + manifest_edits: str {'keep', 'apply', False} + Keep meta from edits or apply rules. """ + batches = self._meta['sets']['batches'] + adds = batches[self.name]['additions'] + + # prepare variable list + if not mode: + mode = ['x', 'y', 'v', 'oe', 'w', 'f'] + vlist = self._get_vlist(batches[self.name], mode) + if additions == "sort_between": + for add in adds: + vlist += self._get_vlist(batches[add], mode) + if not from_set: + from_set = vlist + vlist = self.align_order(vlist, from_set, integrate_rc, fix=misc) + if additions == "sort_within": + for add in adds: + add_list = self._get_vlist(batches[add], mode) + add_list = self.align_order(add_list, from_set, integrate_rc, + fix=misc) + vlist += add_list + vlist = self.de_duplicate(vlist) + vlist = self.roll_up(vlist) + + # handle filters + merge_f = False f = self.filter - if f == 'no_filter': - self.sample_size = len(self._data.index) - else: - self.sample_size = len(self._dsfilter(self, 'sample', f.values()[0])._data.index) - return None \ No newline at end of file + if adds: + filters = [self.filter] + [batches[add]['filter'] for add in adds] + filters = [fi for fi in filters if fi] + if len(filters) == 1: + f = filters[0] + elif not self.compare_filter(filters[0], filters[1:]): + f = "merge_filter" + merge_f = filters + else: + f = filters[0] + + # create ds + ds = qp.DataSet(self.name, self._dimensions_comp) + ds.from_components(self._data.copy(), org_copy.deepcopy(self._meta), + True, self.language) + for b in ds.batches(): + if not (b in adds or b == ds.name): + del ds._meta['sets']['batches'][b] + + if merge_f: + ds.merge_filter(f, filters) + if f: + ds.filter(self.name, {f: 0}, True) + if merge_f: + ds.drop(f) + + ds.create_set(str(self.name), included=vlist, overwrite=True) + ds.subset(from_set=self.name, inplace=True) + ds.order(vlist) + + # manifest edits + if manifest_edits in ['apply', 'keep']: + b_meta = batches[self.name]['meta_edits'] + for v in ds.variables(): + if ds.is_array(v) and b_meta.get(v): + ds._meta['masks'][v] = b_meta[v] + try: + ds._meta['lib']['values'][v] = b_meta['lib'][v] + except: + pass + elif b_meta.get(v): + ds._meta['columns'][v] = b_meta[v] + if manifest_edits == "apply" and not ds._is_array_item(v): + for axis in ['x', 'y']: + if all(rule in ds._get_rules(v, axis) + for rule in ['dropx', 'slicex']): + drops = ds._get_rules(v, axis)['dropx']['values'] + slicer = ds._get_rules(v, axis)['slicex']['values'] + elif 'dropx' in ds._get_rules(v, axis): + drops = ds._get_rules(v, axis)['dropx']['values'] + slicer = ds.codes(v) + elif 'slicex' in ds._get_rules(v, axis): + drops = [] + slicer = ds._get_rules(v, axis)['slicex']['values'] + else: + drops = slicer = [] + if drops or slicer: + if not all(isinstance(c, int) for c in drops): + item_no = [ds.item_no(d) for d in drops] + ds.remove_items(v, item_no) + else: + codes = ds.codes(v) + n_codes = [c for c in slicer if not c in drops] + if not len(n_codes) == len(codes): + remove = [c for c in codes + if not c in n_codes] + ds.remove_values(v, remove) + ds.reorder_values(v, n_codes) + if ds.is_array(v): + ds._meta['masks'][v].pop('rules') + else: + ds._meta['columns'][v].pop('rules') + ds.set_text_key(self.language) + if "oe" in mode: + self._apply_oe_replacements(ds) + return ds + + def _get_vlist(self, batch, mode): + match = { + "x": "xks", + "y": "yks", + "v": "_variables", + "w": "weights", + "f": "filter", + "oe": "verbatims" + } + vlist = [] + for key in mode: + var = batch[match[key]] + if key == "oe": + oes = [] + for oe in var[:]: + if 'f' in mode: + oes += oe["columns"] + [oe["filter"]] + else: + oes += oe['columns'] + var = oes + if key == "f": + var = batch["filter_names"] + batch["y_filter_map"].values() + if not isinstance(var, list): var = [var] + for v in var: + if v and v in self and v not in vlist: + vlist.append(v) + return vlist + + def _apply_oe_replacements(self, dataset): + numerical = ["int", "single", "is_delimited_set"] + for oe in self.verbatims: + if oe['replace']: + data = dataset._data[oe["columns"]].copy() + for target, repl in oe['replace'].items(): + if not repl: + repl = np.NaN + data.replace(target, repl, inplace=True) + dataset._data[oe["columns"]] = data + if not oe['incl_nan']: + for col in oe['columns']: + if self._get_type(col) not in numerical: + dataset._data[col].replace(np.NaN, '', inplace=True) \ No newline at end of file diff --git a/quantipy/core/builds/excel/excel_painter.py b/quantipy/core/builds/excel/excel_painter.py index ba24bd460..f9c13757f 100644 --- a/quantipy/core/builds/excel/excel_painter.py +++ b/quantipy/core/builds/excel/excel_painter.py @@ -1955,8 +1955,11 @@ def ExcelPainter(path_excel, bool(testcol_maps), len_chain_annotations]) position = coordmap['x'][x_name][fullname][0] - if re.sub('\[.+?\]', '', x_name) in mask_label.keys(): - position -= 1 + if x_name in meta['columns']: + if meta['columns'][x_name].get('parent'): + parent = meta['columns'][x_name]['parent'].keys()[0].split('@')[1] + if parent in mask_label.keys(): + position -= 1 if position == first_row: #write column label(s) - multi-column y subaxis total_text = helpers.translate(['@'], text_key_chosen['y'])[0] @@ -2023,8 +2026,11 @@ def ExcelPainter(path_excel, bool(testcol_maps), len_chain_annotations]) position = coordmap['x'][x_name][fullname][0] - if re.sub('\[.+?\]', '', x_name) in mask_label.keys(): - position -= 1 + if x_name in meta['columns']: + if meta['columns'][x_name].get('parent'): + parent = meta['columns'][x_name]['parent'].keys()[0].split('@')[1] + if parent in mask_label.keys(): + position -= 1 if position == first_row: labels = helpers.get_unique_level_values(df.columns) labels[1] = helpers.translate(labels[1], text_key_chosen['y']) diff --git a/quantipy/core/builds/powerpoint/add_shapes.py b/quantipy/core/builds/powerpoint/add_shapes.py index 6c25e44c5..f5c1697ef 100644 --- a/quantipy/core/builds/powerpoint/add_shapes.py +++ b/quantipy/core/builds/powerpoint/add_shapes.py @@ -507,7 +507,10 @@ def add_bar_chart( series_line_width=None, #Excel table - excel_num_format='0.00%' + excel_num_format='0.00%', + + #Color for separator + separator_color=(255,255,255) ): #------------------------------------------------------------------------- """Adds single or multi series bar chart to a given slide and set it's properties. @@ -712,6 +715,48 @@ def add_bar_chart( data_labels.number_format = data_labels_num_format data_labels.number_format_is_linked = data_labels_num_format_is_linked + # Show Net settings + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + net_separator = ['net_separator'] + category_labels = [i.label for i in chart_data.categories] + if net_separator[0] in category_labels: + pos_net_separator = [category_labels.index(i) for i in net_separator] + # Delete the net separator text + category_labels[pos_net_separator[0]] = '' + chart_data.categories = category_labels + chart.replace_data(chart_data) + + # Add fill to the separator + bar = chart.series[0].points + for x in pos_net_separator: + + point = bar[x] + fill = point.format.fill + fill.solid() + fill.fore_color.rgb = RGBColor(*separator_color) + + # Hide data label + chart_values = get_chart_values(chart) + + for s, series in enumerate(chart_values): + values = [ + value for value in series.values()[0] + ] + + for v, value in enumerate(values): + point = chart.series[s].points[v] + #point.format.line.color.rgb = RGBColor(0,0,0) + frame = point.data_label.text_frame + frame.text = '' if value == 1.01 else str(int(round(float(value) * 100))) + "%" + run = frame.paragraphs[0].runs + for point_label in run: + point_label.font.size = Pt(data_labels_font_size) + point_label.font.name = data_labels_font_name + point_label.font.bold = data_labels_font_bold + point_label.font.italic = data_labels_font_italic + point_label.font.color.rgb = RGBColor(*data_labels_font_color) + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + if series_color_order and len(dataframe.columns) > 1: ser_colors_list = color_setter(len(dataframe.columns), series_color_order) @@ -1551,6 +1596,149 @@ def add_table( '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' +def add_net( + slide, + df, + left=Cm(27.55), top=Cm(3.69), width=Cm(1.8), # width for 1 column + height=Cm(10.68), + margin_left=0.0, + margin_right=0.0, + margin_top=0.0, + margin_bottom=0.0, + + # side_member_font_size=8, + # side_member_font_name='Trebuchet MS', + # side_member_font_bold=False, + # side_member_font_italic=False, + # side_member_font_color=(109,111,113), + # side_member_font_para_alignment=PP_ALIGN.LEFT, + # side_member_vert_alignment=MSO_ANCHOR.MIDDLE, + # sidemember_shading=True, + # sidemember_shading_color=(255,255,255), + + top_member_font_size=8, + top_member_font_name='Trebuchet MS', + top_member_font_bold=False, + top_member_font_italic=False, + top_member_font_color=(0,0,0), + top_member_font_para_alignment=PP_ALIGN.CENTER, + top_member_vert_alignment=MSO_ANCHOR.MIDDLE, + top_member_shading=True, + top_member_shading_color=(255,255,255), + + values_font_size=8, + values_font_name='Trebuchet MS', + values_font_bold=False, + values_font_italic=False, + values_font_color=(0,0,0), + values_font_para_alignment=PP_ALIGN.CENTER, + values_vert_alignment=MSO_ANCHOR.TOP, + values_shading=True, + values_shading_shading_color=(255,255,255), + ): + #------------------------------------------------------------------------- + + rows = len(df.index) + cols = len(df.columns) + + # Height of table and rows + header_row_height = Cm(1.7) + if rows == 1: + top = top + int(round(height * (0.3 / rows)) - header_row_height) + else: + top = top + int(round(height* (0.45/rows)) - header_row_height) + plot_area = int(round(height * 0.9)) - Cm(0.4) + value_row_height = int(round(plot_area / rows)) + height = header_row_height + rows * value_row_height + + # Width of table + width = width * cols + + shapes = slide.shapes + table = shapes.add_table(rows+1, cols, left, top, width, height).table + table.horz_banding = True + #isolate seperate sections of a table + row_labels = list(df.index) + col_labels = list(df.columns) + table_values = df.values + #question_label = df.index.get_level_values(level=0)[0] + + #table specific properties + for i in range(0, rows + 1): + if i == 0: + table.rows[i].height = header_row_height + else: + table.rows[i].height = value_row_height + + for x in range(0, cols): + + cell = table.cell(i, x) + + cell.margin_left= Cm(margin_left) + cell.margin_right = Cm(margin_right) + cell.margin_top = Cm(margin_top) + cell.margin_bottom = Cm(margin_bottom) + + #add col labels + for idx, col_label in enumerate(col_labels): + + #table.columns[0].width = Emu(first_column_width) + + cell = table.cell(0, idx) + cell.vertical_anchor = top_member_vert_alignment + + if top_member_shading: + if top_member_shading_color == "No fill": + fill = cell.fill + fill.background() + else: + cfill = cell.fill + cfill.solid() + cfill.fore_color.rgb = RGBColor(*top_member_shading_color) + #cfill.fore_color.brightness = textbox_color_brightness + + textframe = cell.text_frame + paragraph = textframe.paragraphs[0] + paragraph.font.size = Pt(top_member_font_size) + paragraph.font.name = top_member_font_name + paragraph.font.bold = top_member_font_bold + paragraph.font.italic = top_member_font_italic + paragraph.font.color.rgb = RGBColor(*top_member_font_color) + paragraph.alignment = top_member_font_para_alignment + + cell.text = col_label + + #add values + for i, val in enumerate(table_values): + for x, subval in enumerate(val): + + cell = table.cell(i+1, x) + cell.vertical_anchor = values_vert_alignment + cell.margin_top = Cm(0.1) + + if values_shading: + if values_shading_shading_color == "No fill": + fill = cell.fill + fill.background() + else: + cfill = cell.fill + cfill.solid() + cfill.fore_color.rgb = RGBColor(*values_shading_shading_color) + + textframe = cell.text_frame + paragraph = textframe.paragraphs[0] + paragraph.font.size = Pt(values_font_size) + paragraph.font.name = values_font_name + paragraph.font.bold = values_font_bold + paragraph.font.italic = values_font_italic + paragraph.font.color.rgb = RGBColor(*values_font_color) + paragraph.alignment = values_font_para_alignment + #paragraph.line_spacing = Pt(6) + cell.text = str(subval) + +'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' +'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + def add_picture( slide, img_path, diff --git a/quantipy/core/builds/powerpoint/pptx_painter.py b/quantipy/core/builds/powerpoint/pptx_painter.py index 921e49340..99373714a 100644 --- a/quantipy/core/builds/powerpoint/pptx_painter.py +++ b/quantipy/core/builds/powerpoint/pptx_painter.py @@ -21,7 +21,8 @@ from quantipy.core.builds.powerpoint.add_shapes import( chart_selector, add_stacked_bar_chart, - add_textbox) + add_textbox, + add_net) from quantipy.core.builds.powerpoint.transformations import( is_grid_element, get_base, @@ -31,9 +32,25 @@ strip_html_tags, rename_label, df_splitter, - auto_sort) + auto_sort, + round_df_cells) from quantipy.core.builds.powerpoint.visual_editor import( return_slide_layout_by_name) +from pptx.enum.text import( + PP_ALIGN, + MSO_AUTO_SIZE, + MSO_ANCHOR + ) +from pptx.util import( + Emu, + Pt, + Cm, + Inches + ) +from quantipy.core.builds.powerpoint.add_shapes import ( + percentage_of_num, + get_cht_plot_height, + get_upper_cht_plot_gap) thisdir = path.split(__file__)[0] @@ -563,12 +580,17 @@ def PowerPointPainter( ('is_weighted', 'True'), ('is_sum', 'False')]) - # if include_nets == false + # Net settings + net_setup = shape_properties.get('net_setup', False) if not include_nets: chartdata_conditions.update({'is_net': 'False'}) chartdata_conditions_grid = copy.deepcopy(chartdata_conditions) elif include_nets == True: - chartdata_conditions_grid = copy.deepcopy(chartdata_conditions) + if net_setup: + chartdata_conditions.update({'is_net': 'False'}) + chartdata_conditions_grid = copy.deepcopy(chartdata_conditions) + else: + chartdata_conditions_grid = copy.deepcopy(chartdata_conditions) #elif include_net == 'partly': else: chartdata_conditions_grid = copy.deepcopy(chartdata_conditions) @@ -735,6 +757,16 @@ def PowerPointPainter( qname=grid, war_msg='')) + #extract df for net + if net_setup: + net_setup_stacked_bar = net_setup.get('stacked_bar', False) + if net_setup_stacked_bar: + df_grid_table_net = df_meta_filter( + merged_grid_df, + grped_g_meta, + {'is_net' : 'True'}, + index_key='label') + #extract df for chart df_grid_table = df_meta_filter( merged_grid_df, @@ -772,7 +804,8 @@ def PowerPointPainter( else: base_text = get_base( df_grid_base, - base_description) + base_description, + True) if base_repr and ('Base' in base_text): base_text = base_text.replace('Base', base_repr) @@ -817,6 +850,26 @@ def PowerPointPainter( **(shape_properties['header_shape'] if shape_properties else {})) + ''' net table ''' + if include_nets and net_setup: + save_width = shape_properties['chart_shape']['stacked_bar']['width'] + if net_setup_stacked_bar['show_table']: + if not df_grid_table_net.empty: + df_grid_table_net = round_df_cells(df_grid_table_net, + net_setup_stacked_bar['table_decimals']) + if net_setup_stacked_bar['add_percent_sign']: + df_grid_table_net = df_grid_table_net.astype(str) + '%' + cols = len(df_grid_table_net.T.columns) + shapes=shape_properties['chart_shape']['stacked_bar'] + shapes['legend_position']='bottom' + shapes['width'] -= net_setup_stacked_bar['table_column_width'] * cols + # Set net table size and position + height = shapes['height'] + top = shapes['top'] + left = shapes['left'] + shapes['width'] + width = net_setup_stacked_bar['table_column_width'] + net_table = add_net(slide, df_grid_table_net.T, height=height, width=width, top=top, left=left) + ''' chart shape ''' chart_shp = chart_selector( slide, @@ -825,6 +878,9 @@ def PowerPointPainter( **(shape_properties['chart_shape']['stacked_bar'] if shape_properties else {})) + if include_nets and net_setup: + shape_properties['chart_shape']['stacked_bar']['width'] = save_width + ''' footer shape ''' if base_text: base_text_shp = add_textbox( @@ -901,6 +957,16 @@ def PowerPointPainter( 'Total', orientation='Top') + # extract df for net + if net_setup: + df_table_net = df_meta_filter( + grped_df, + grped_meta, + {'is_net': 'True'}, + index_key='label') + # standardise table values + df_table_net = np.round(df_table_net.fillna(0.0) / 100, 4) + #extract df for chart df_table = df_meta_filter( grped_df, @@ -951,7 +1017,8 @@ def PowerPointPainter( if not df_base.empty: base_text = get_base( df_base, - base_description) + base_description, + False) else: raise Exception('Base dataframe empty for "{}".'.format(downbreak)) @@ -1044,13 +1111,27 @@ def PowerPointPainter( if 'has_legend' in shape_properties['chart_shape'][chart_type]: shape_properties['chart_shape'][chart_type]['has_legend'] = legend_switch + # Net settings + if include_nets and net_setup: + net_setup = net_setup.get(chart_type, False) + if not net_setup == False and net_setup['show_nets']: + if len(collection_of_dfs) == 1: + if not df_table_net.empty: + if net_setup['separator']: + df_table_slice = df_table_slice.T + df_table_slice.insert(len(df_table_slice.columns), 'net_separator', 1.01) + df_table_slice = df_table_slice.T + #df_table_slice.loc[len(df_table_slice)]=0 + df_table_slice = pd.concat([df_table_slice, df_table_net]) + shape_properties['chart_shape']['bar']['separator_color'] = net_setup['separator_color'] + chart = chart_selector( slide, df_table_slice, chart_type=chart_type, **(shape_properties['chart_shape'][chart_type] if shape_properties else {})) - + ''' footer shape ''' base_text_shp = add_textbox( slide, diff --git a/quantipy/core/builds/powerpoint/transformations.py b/quantipy/core/builds/powerpoint/transformations.py index 95cd9f60d..658e7dee1 100644 --- a/quantipy/core/builds/powerpoint/transformations.py +++ b/quantipy/core/builds/powerpoint/transformations.py @@ -38,8 +38,11 @@ def case_insensitive_matcher(check_these, against_this): performs the case-insensitive search of given list of items against df rows or columns and pulls out matched items from the df. ''' - - matched = [v for x,d in enumerate(check_these) for i,v in enumerate(against_this) if v.lower() == d.lower()] + matched = [v + for x,d in enumerate(check_these) + for i,v in enumerate(against_this) + if v.lower() == d.lower() + ] return matched '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' @@ -403,7 +406,7 @@ def validate_cluster_orientations(cluster): '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' -def get_base(df, base_description): +def get_base(df, base_description, is_mask): ''' Constructs base text for any kind of chart, single, multiple, grid. @@ -450,10 +453,12 @@ def get_base(df, base_description): # if all_same(base_values[0]): # base_text = base_text_format(base_description, base_values[0][0]) # else: - it = zip(top_members, base_values[0]) - base_texts = ', '.join([base_text_format(x, y) for x, y in it]) - base_text = ' - '.join([base_description, base_texts]) - + if not is_mask: + it = zip(top_members, base_values[0]) + base_texts = ', '.join([base_text_format(x, y) for x, y in it]) + base_text = ' - '.join([base_description, base_texts]) + else: + base_text = base_text_format(base_description, base_values[0][0]) return base_text diff --git a/quantipy/core/dataset.py b/quantipy/core/dataset.py index 160d64d3f..4085ddc2e 100644 --- a/quantipy/core/dataset.py +++ b/quantipy/core/dataset.py @@ -44,10 +44,20 @@ import re import time import sys +import os from itertools import product, chain -from collections import OrderedDict +from collections import OrderedDict, Counter -VALID_TKS = ['en-GB', 'da-DK', 'fi-FI', 'nb-NO', 'sv-SE', 'de-DE', 'fr-FR', 'ar-AR'] +VALID_TKS = [ + 'en-GB', 'da-DK', 'fi-FI', 'nb-NO', 'sv-SE', 'de-DE', 'fr-FR', 'ar-AR', + 'es-ES', 'it-IT', 'pl-PL'] + +VAR_SUFFIXES = [ + '_rc', '_net', ' (categories', ' (NET', '_rec'] + +BLACKLIST_VARIABLES = [ + 'batches', 'columns', 'info', 'items', 'lib', 'masks', 'name', 'parent', + 'properties', 'text', 'type', 'sets', 'subtype', 'values', 'filter'] class DataSet(object): """ @@ -103,7 +113,8 @@ def __setitem__(self, name, val): if not val in self.codes(name) and not np.isnan(val): msg = "{} is undefined for '{}'! Valid: {}" raise ValueError(msg.format(val, name, self.codes(name))) - if self._get_type(name) == 'delimited set' and scalar_insert: + if (self._get_type(name) == 'delimited set' and scalar_insert + and not np.isnan(val)): val = '{};'.format(val) if sliced_insert: self._data.loc[slicer, name] = val @@ -179,6 +190,74 @@ def dates(self): def strings(self): return self._get_columns('string') + def created(self): + return self._by_property('created') + + def filters(self): + return self._by_property('recoded_filter') + + def _stat_view_recodes(self): + return self._by_property('recoded_stat') + + def _net_view_recodes(self): + return self._by_property('recoded_net') + + def _by_property(self, prop): + return [v for v in self.variables() if self._get_property(v, prop)] + + @verify(variables={'name': 'both'}) + def missings(self, name=None): + if name: + return self._get_missing_map(name) + all_missings = {} + for v in self.variables(): + miss = self._get_missing_map(v) + if miss: all_missings[v] = miss + return all_missings + + def batches(self, main=True, add=True): + if not 'batches' in self._meta['sets'] or (not main and not add): + return [] + batches = self._meta['sets']['batches'].keys() + if main and add: + return batches + if main: + return self._typed_batches(batches, 'main') + if add: + return self._typed_batches(batches, 'add') + + def _typed_batches(self, all_batches, kind): + """ + """ + verbose = self._verbose_infos + self._verbose_infos = False + if kind == 'main': + typed_batches = [b for b in all_batches if not self.get_batch(b).additional] + elif kind == 'add': + typed_batches = [b for b in all_batches if self.get_batch(b).additional] + self._verbose_infos = verbose + return typed_batches + + def _adds_per_mains(self, reverse=False): + """ + """ + bmeta = self._meta['sets']['batches'] + adds_per_mains = {bname: bdef['additions'] for bname, bdef + in bmeta.items() if bdef['additions']} + if not reverse: + return adds_per_mains + else: + rev = {} + adds = self._typed_batches(bmeta.keys(), 'add') + for add in adds: + for m, a in adds_per_mains.items(): + if add in a: + if add in rev: + rev[add].append(m) + else: + rev[add] = [m] + return rev + def set_verbose_errmsg(self, verbose=True): """ """ @@ -237,7 +316,7 @@ def _clear_cache(self): def _get_type(self, var): if var in self._meta['masks'].keys(): return self._meta['masks'][var]['type'] - else: + if var in self._meta['columns'].keys(): return self._meta['columns'][var]['type'] def _get_subtype(self, name): @@ -347,6 +426,9 @@ def _is_delimited_set_mapper(self, mapper): else: return False + def is_filter(self, var): + return True if var in self and self.get_property(var, 'recoded_filter') else False + def _has_missings(self, var): if self.is_array(var): var = self.sources(var)[0] return self._meta['columns'][var].get('missings', False) @@ -433,6 +515,7 @@ def read_quantipy(self, path_meta, path_data, reset=True): self.set_dim_suffix() self.undimensionize() if d_comp is True: self.dimensionize() + self._rename_blacklist_vars() return None def read_dimensions(self, path_meta, path_data): @@ -465,6 +548,7 @@ def read_dimensions(self, path_meta, path_data): self.set_dim_suffix() self.undimensionize() if d_comp is True: self.dimensionize() + self._rename_blacklist_vars() return None @verify(text_keys='text_key') @@ -492,6 +576,7 @@ def read_ascribe(self, path_meta, path_data, text_key): if path_data.endswith('.txt'): path_data = path_data.replace('.txt', '') self._meta, self._data = r_ascribe(path_meta+'.xml', path_data+'.txt', text_key) self._set_file_info(path_data, path_meta) + self._rename_blacklist_vars() return None def read_spss(self, path_sav, **kwargs): @@ -514,11 +599,12 @@ def read_spss(self, path_sav, **kwargs): if path_sav.endswith('.sav'): path_sav = path_sav.replace('.sav', '') self._meta, self._data = r_spss(path_sav+'.sav', **kwargs) self._set_file_info(path_sav) + self._rename_blacklist_vars() return None @verify(text_keys='text_key') def write_dimensions(self, path_mdd=None, path_ddf=None, text_key=None, - date_format="DMY", run=True, clean_up=True): + run=True, clean_up=True): """ Build Dimensions/SPSS Base Professional .ddf/.mdd data pairs. @@ -556,29 +642,31 @@ def write_dimensions(self, path_mdd=None, path_ddf=None, text_key=None, """ ds_clone = self.clone() if not text_key: text_key = ds_clone.text_key - if not ds_clone._dimensions_comp: - msg = "Converting variable names into Dimensions equivalents..." - print msg - ds_clone.dimensionize() + if ds_clone._dimensions_comp: + ds_clone.undimensionize() + # check against weak dupes and rename automatically + ds_clone._rename_weak_dupes() + # naming rules for Dimensions are applied + ds_clone.dimensionize() meta, data = ds_clone._meta, ds_clone._data if path_ddf is None and path_mdd is None: path = ds_clone.path name = ds_clone.name - path_mdd = '{}/{}.mdd'.format(path, name) - path_ddf = '{}/{}.ddf'.format(path, name) + path_mdd = os.path.join(path, ''.join([name, '.mdd'])) + path_ddf = os.path.join(path, ''.join([name, '.ddf'])) elif path_ddf is not None and path_mdd is not None: if not path_mdd.endswith('.mdd'): - path_mdd = '{}.mdd'.format(path_mdd) + path_mdd = ''.join([path_mdd, '.mdd']) if not path_ddf.endswith('.ddf'): - path_ddf = '{}.ddf'.format(path_ddf) + path_ddf = ''.join([path_ddf, '.ddf']) else: msg = "Must either specify or omit both 'path_mdd' and 'path_ddf'!" raise ValueError(msg) path_mdd = path_mdd.replace('//', '/') path_ddf = path_ddf.replace('//', '/') w_dimensions(meta, data, path_mdd, path_ddf, text_key=text_key, - date_format=date_format, run=run, clean_up=clean_up) - file_msg = "\nSaved files to:\n{} and\n{}".format(path_mdd, path_ddf) + run=run, clean_up=clean_up) + file_msg = u"\nSaved files to:\n{} and\n{}".format(path_mdd, path_ddf) print file_msg return None @@ -609,13 +697,13 @@ def write_quantipy(self, path_meta=None, path_data=None): if path_data is None and path_meta is None: path = self.path name = self.name - path_meta = '{}/{}.json'.format(path, name) - path_data = '{}/{}.csv'.format(path, name) + path_meta = os.path.join(path, ''.join([name, '.json'])) + path_data = os.path.join(path, ''.join([name, '.csv'])) elif path_data is not None and path_meta is not None: if not path_meta.endswith('.json'): - path_meta = '{}.json'.format(path_meta) + path_meta = ''.join([path_meta, '.json']) if not path_data.endswith('.csv'): - path_data = '{}.csv'.format(path_data) + path_data = ''.join([path_data, '.csv']) else: msg = "Must either specify or omit both 'path_meta' and 'path_data'!" raise ValueError(msg) @@ -664,10 +752,10 @@ def write_spss(self, path_sav=None, index=True, text_key=None, meta, data = self._meta, self._data if not text_key: text_key = self.text_key if not path_sav: - path_sav = '{}/{}.sav'.format(self.path, self.name) + path_sav = os.path.join(self.path, ''.join([self.name, '.sav'])) else: if not path_sav.endswith('.sav'): - path_sav = '{}.sav'.format(path_sav) + path_sav = ''.join([path_sav, '.sav']) w_spss(path_sav, meta, data, index=index, text_key=text_key, mrset_tag_style=mrset_tag_style, drop_delimited=drop_delimited, from_set=from_set, verbose=verbose) @@ -712,10 +800,10 @@ def meta_to_json(self, key=None, collection=None): name = '{}{}'.format(collection, '_{}'.format(key.split('.')[0]) if key else '') ds_path = '../' if self.path == '/' else self.path - path = '{}{}_{}.json'.format(ds_path, self.name, name) + path = os.path.join(ds_path, ''.json([self.name, '_', name, '.json'])) with open(path, 'w') as file: json.dump(obj, file) - print 'create: {}'.format(path) + print u'create: {}'.format(path) return None @verify(text_keys='text_key') @@ -774,6 +862,7 @@ def from_components(self, data_df, meta_dict=None, reset=True, text_key=None): self.set_verbose_infomsg(False) self._set_file_info('', reset=reset) self.set_dim_suffix() + self._rename_blacklist_vars() return None def from_stack(self, stack, data_key=None, dk_filter=None, reset=True): @@ -821,6 +910,76 @@ def from_stack(self, stack, data_key=None, dk_filter=None, reset=True): return None + def _vars_from_batch(self, batchdef, mode='batch-full'): + """ + """ + xs = self.roll_up(batchdef['xks']) + ys = batchdef['yks'] + for add_y_coll in ['extended_yks_per_x', 'exclusive_yks_per_x']: + if batchdef[add_y_coll]: + for y in batchdef[add_y_coll].values: + if not y in ys: ys.append(y) + if '@' in ys: ys.remove('@') + oe = [] + for verbatim in batchdef['verbatims']: + oe += verbatim['columns'] + oe = list(set(oe)) + w = batchdef['weights'] + if None in w: + w.remove(None) + if mode in ['batch-full', 'batch-x']: + batch_vars = xs + if mode == 'batch-full': + for y in ys: + if not y in batch_vars: batch_vars.append(y) + for verbatim in oe: + if not oe in batch_vars: + batch_vars.append(verbatim) + if w: batch_vars.extend(w) + return batch_vars + + @modify(to_list=['text_key', 'include']) + @verify(text_keys='text_key', variables={'include': 'both'}) + def _from_batch(self, batch_name, include='identity', text_key=[], + apply_edits=True, additions='variables'): + """ + """ + # get the main batch definition to construct a dataset from... + batch_def = self._meta['sets']['batches'][batch_name] + # filter it if needed: + f = batch_def['filter'] + if f is None: + b_ds = self.clone() + elif isinstance(f, basestring): + b_ds = self.filter(batch_name, {f: 0}) + else: + b_ds = self.filter(batch_name, f.values()[0]) + # build the variable collection based in Batch setup & requirements: + main_variables = b_ds._vars_from_batch(batch_def, 'batch-full') + if additions in ['full', 'filters']: + if batch_def['additions']: + for add_batch in batch_def['additions']: + f = add_batch['filter'] + if not f is None and isinstance(f, basestring): + if not f in main_variables: + main_variables.append(f) + if additions in ['full', 'variables']: + if batch_def['additions']: + for add_batch in batch_def['additions']: + add_batch_def = b_ds._meta['sets']['batches'][add_batch] + add_vars = b_ds._vars_from_batch(add_batch_def) + add_vars = [v for v in add_vars if not v in main_variables] + main_variables.extend(add_vars) + # add any custom variables... + if include: + include = [v for v in include if not v in main_variables] + main_variables = include + main_variables + # subset the dataset variables... + b_ds.subset(main_variables, inplace=True) + b_ds.order(main_variables) + self._rename_blacklist_vars() + return b_ds + @modify(to_list=['text_key', 'include']) @verify(text_keys='text_key', variables={'include': 'both'}) def from_batch(self, batch_name, include='identity', text_key=[], @@ -841,7 +1000,7 @@ def from_batch(self, batch_name, include='identity', text_key=[], meta_edits and rules are used as/ applied on global meta of the new DataSet instance. additions: {'variables', 'filters', 'full', None} - Extend included variables by the xks, yks and open ends of the + Extend included variables by the xks, yks and weights of the additional batches if set to 'variables', 'filters' will create new 1/0-coded variables that reflect any filters defined. Selecting 'full' will do both, ``None`` will ignore additional Batches completely. @@ -889,28 +1048,6 @@ def _apply_edits_rules(ds, name, b_meta): ds._meta['columns'][name].pop('rules') return None - def _manifest_filters(ds, batch_name): - all_batches = ds._meta['sets']['batches'] - add_batches = ds._meta['sets']['batches'][batch_name]['additions'] - if not adds: return None - filters = [] - for add_batch in add_batches: - if all_batches[add_batch]['filter'] != 'no_filter': - filters.append((add_batch, all_batches[add_batch]['filter'])) - if not filters: return None - cats = [(1, 'active')] - fnames = [] - for no, f in enumerate(filters, start=1): - fname = 'filter_{}'.format(no) - fnames.append(fname) - source = f[0] - flogic = f[1].values()[0] - flabel = f[1].keys()[0] - ds.add_meta(fname, 'single', flabel, cats) - ds._meta['columns'][fname]['properties']['recoded_filter'] = source - ds[ds.take(flogic), fname] = 1 - return fnames - batches = self._meta['sets'].get('batches', {}) if not batch_name in batches: msg = 'No Batch named "{}" is included in DataSet.' @@ -922,37 +1059,35 @@ def _manifest_filters(ds, batch_name): msg = 'Batch-textkey {} is not included in {}.' raise ValueError(msg.format(batch['language'], text_key)) # Create a new instance by filtering or cloning - if batch['filter'] == 'no_filter': + f = batch['filter'] + if f is None: b_ds = self.clone() + elif isinstance(f, basestring): + b_ds = self.filter(batch_name, {f: 0}) else: - b_ds = self.filter(batch_name, batch['filter'].values()[0]) + b_ds = self.filter(batch_name, f.values()[0]) # Get a subset of variables (xks, yks, oe, weights) - if additions in ['full', 'variables']: - adds = batch['additions'] - else: - adds = [] - if additions in ['full', 'filters']: - filter_vars = _manifest_filters(b_ds, batch_name) - else: - filter_vars = [] - - variables = include + variables = ['@1'] + include[:] + adds = batch['additions'] if additions in ['full', 'variables'] else [] for b_name, ba in batches.items(): if not b_name in [batch_name] + adds: continue - variables += ba['xks'] + ba['yks'] + ba['verbatim_names'] + ba['weights'] + variables += ba['xks'] + ba['yks'] + ba['_variables'] + for oe in ba['verbatims']: + variables += oe['columns'] + variables += ba['weights'] for yks in ba['extended_yks_per_x'].values() + ba['exclusive_yks_per_x'].values(): variables += yks - if filter_vars: variables += filter_vars + if additions in ['full', 'filters']: + variables += ba['filter_names'] variables = list(set([v for v in variables if not v in ['@', None]])) + variables = b_ds.roll_up(variables) b_ds.subset(variables, inplace=True) # Modify meta of new instance b_ds.name = b_ds._meta['info']['name'] = batch_name b_ds.set_text_key(batch['language']) for b in b_ds._meta['sets']['batches'].keys(): if not b in [batch_name] + adds: b_ds._meta['sets']['batches'].pop(b) - b_ds._meta['sets']['batches'][batch_name]['filter'] = 'no_filter' - b_ds._meta['sets']['batches'][batch_name]['filter_names'] = ['no_filter'] # apply edits if apply_edits: b_edits = b_ds._meta['sets']['batches'][batch_name]['meta_edits'] @@ -962,6 +1097,7 @@ def _manifest_filters(ds, batch_name): # select text_keys if text_key: b_ds.select_text_keys(text_key) + self._rename_blacklist_vars() return b_ds @verify(variables={'unique_key': 'columns'}) @@ -1006,7 +1142,7 @@ def from_excel(self, path_xlsx, merge=True, unique_key='identity'): if merge: self.hmerge(new_ds, on=unique_key, verbose=False) - + self._rename_blacklist_vars() return new_ds def _set_file_info(self, path_data, path_meta=None, reset=True): @@ -1032,12 +1168,55 @@ def _set_file_info(self, path_data, path_meta=None, reset=True): return None def _show_file_info(self): - file_spec = ('DataSet: {}\nrows: {} - columns: {}\n' - 'Dimensions compatibility mode: {}') + file_spec = (u'DataSet: {}\nrows: {} - columns: {}\n' + u'Dimensions compatibility mode: {}') if not self.path: self.path = '/' - file_name = '{}{}'.format(self.path, self.name) - print file_spec.format(file_name, len(self._data.index), - len(self._data.columns)-1, self._dimensions_comp) + file_name = os.path.join(self.path, self.name) + print file_spec.format( + file_name, + len(self._data.index), + len(self._data.columns)-1, + self._dimensions_comp + ).encode('utf-8') + return None + + def _rename_weak_dupes(self): + dupes = self.names() + if isinstance(dupes, pd.DataFrame): + if len(dupes.index) > 2: + msg = 'More than two weak duplicates found for a variable. ' + msg += 'Auto-rename not possible. Please rename manually!\n' + dupes = '\n'.join([ + '{}: {}'.format(col, [c for c in dupes[col] if c]) + for col in dupes + ]) + msg += dupes + raise ValueError(msg) + for col in dupes: + first_d = dupes[col].values.tolist()[0] + new_name = '_{}'.format(first_d) + if self.resolve_name(new_name): + msg = 'Auto rename not possible: {} is already included!' + raise KeyError(msg.format(new_name)) + self.rename(first_d, new_name) + print "A weak duplicate has been renamed: '{}' to '{}'".format(first_d, new_name) + print '' + return None + + def _rename_blacklist_vars(self): + blacklist_txt = (u'Variables identified as part of a blacklist: {}. \n' + u'They have been renamed by adding "_" as prefix') + blacklist_var = [] + for var in BLACKLIST_VARIABLES: + n_var = '_%s' % var + if var in self and not n_var in self: + self.rename(var, u'_{}'.format(var)) + blacklist_var.append(var) + elif var in self: + w = "{} cannot be renamed because {} is already used".format(var, n_var) + warnings.warn(w) + if blacklist_var: + print blacklist_txt.format(blacklist_var).encode('utf-8') return None # ------------------------------------------------------------------------ @@ -1151,6 +1330,94 @@ def by_type(self, types=None): """ return self.describe(only_type=types) + def find(self, str_tags=None, suffixed=False): + """ + Find variables by searching their names for substrings. + + Parameters + ---------- + str_tags : (list of) str + The strings tags to look for in the variable names. If not provided, + the modules' default global list of substrings from VAR_SUFFIXES + will be used. + suffixed : bool, default False + If set to True, only variable names that end with a given string + sequence will qualify. + + Returns + ------- + found : list + The list of matching variable names. + """ + if not str_tags: + str_tags = VAR_SUFFIXES + else: + if not isinstance(str_tags, list): str_tags = [str_tags] + found = [] + variables = self.variables() + for v in variables: + for str_tag in str_tags: + if suffixed: + if v.endswith(str_tag): found.append(v) + else: + if str_tag in v: found.append(v) + return found + + def names(self, ignore_items=True): + """ + Find all weak-duplicate variable names that are different only by case. + + .. note:: Will return self.variables() if no weak-duplicates are found. + + Returns + ------- + weak_dupes : pd.DataFrame + An overview of case-sensitive spelling differences in otherwise + equal variable names. + """ + all_names = self.variables() + if not ignore_items: + all_names = self.unroll(all_names, both='all') + lower_names = [n.lower() for n in all_names] + multiple_names = [k for k, v in Counter(lower_names).items() if v > 1] + if not multiple_names: return self.variables() + weak_dupes = OrderedDict() + for name in all_names: + if name.lower() in multiple_names: + if not name.lower() in weak_dupes: + weak_dupes[name.lower()] = [name] + elif not name in weak_dupes[name.lower()]: + weak_dupes[name.lower()].append(name) + max_wd = max(len(v) for v in weak_dupes.values()) + for k, v in weak_dupes.items(): + while not len(v) == max_wd: + v.append(None) + weak_dupes[k] = v + + return pd.DataFrame(weak_dupes) + + def resolve_name(self, name): + """ + """ + multiples = isinstance(self.names(), pd.DataFrame) + in_multiples = multiples and name in self.names().keys() + if not name in self or in_multiples: + all_names = self.variables() + lowered = [v.lower() for v in all_names] + resolved = [] + if name.lower() in lowered: + offset = 0 + while name.lower() in lowered: + pos = lowered.index(name.lower(), offset) + lowered.pop(pos) + resolved.append(all_names[pos + offset]) + offset += 1 + return resolved if len(resolved) > 1 else resolved[0] + else: + return None + else: + return name + def describe(self, var=None, only_type=None, text_key=None, axis_edit=None): """ Inspect the DataSet's global or variable level structure. @@ -1229,9 +1496,9 @@ def text(self, name, shorten=True, text_key=None, axis_edit=None): def _text_from_textobj(textobj, text_key, axis_edit): if axis_edit: a_edit = '{} edits'.format(axis_edit) - return textobj.get(a_edit, {}).get(text_key, None) + return textobj.get(a_edit, {}).get(text_key, '') else: - return textobj.get(text_key, None) + return textobj.get(text_key, '') if text_key is None: text_key = self.text_key shorten = False if not self._is_array_item(name) else shorten @@ -1527,10 +1794,13 @@ def parents(self, name): return [parent for parent in self._meta['columns'][name]['parent']] def crosstab(self, x, y=None, w=None, pct=False, decimals=1, text=True, - rules=False, xtotal=False): + rules=False, xtotal=False, f=None): """ """ meta, data = self.split() + if f: + slicer = self.take(f) + data = data.copy().iloc[slicer] y = '@' if not y else y get = 'count' if not pct else 'normalize' show = 'values' if not text else 'text' @@ -1547,6 +1817,15 @@ def data(self): # Helpers # ------------------------------------------------------------------------ + @staticmethod + def de_duplicate(seq): + unique = [] + for x in seq: + if x in unique: + continue + unique.append(x) + return unique + @staticmethod def _is_all_ints(s): try: @@ -1633,6 +1912,11 @@ def _make_values_list(self, categories, text_key, start_at=None): enumerate(categories, start_at)] else: vals = [self._value(cat[0], text_key, cat[1]) for cat in categories] + codes = [v['value'] for v in vals] + dupes = [c for c, count in Counter(codes).items() if count > 1] + if dupes: + err = "Cannot resolve category definition due to code duplicates: {}" + raise ValueError(err.format(dupes)) return vals def _add_to_datafile_items_set(self, name): @@ -1646,10 +1930,14 @@ def _add_to_datafile_items_set(self, name): return None def _add_all_renames_to_mapper(self, mapper, old, new): - mapper['masks@{}'.format(old)] = 'masks@{}'.format(new) - mapper['columns@{}'.format(old)] = 'columns@{}'.format(new) - mapper['lib@values@{}'.format(old)] = 'lib@values@{}'.format(new) - mapper[old] = new + mapper['masks@{}'.format(old).encode('utf8')] = 'masks@{}'.format(new) + mapper['columns@{}'.format(old).encode('utf8')] = 'columns@{}'.format(new) + mapper['lib@values@{}'.format(old).encode('utf8')] = 'lib@values@{}'.format(new) + mapper[old.encode('utf8')] = new + mapper['masks@{}'.format(old).decode('utf8')] = 'masks@{}'.format(new) + mapper['columns@{}'.format(old).decode('utf8')] = 'columns@{}'.format(new) + mapper['lib@values@{}'.format(old).decode('utf8')] = 'lib@values@{}'.format(new) + mapper[old.decode('utf8')] = new return mapper @classmethod @@ -1670,20 +1958,49 @@ def _dims_compat_arr_name(self, arr_name): else: return arr_name + @modify(to_list='name') + @verify(variables={'name': 'both'}) + def _prevent_one_cat_set(self, name=None): + if not name: + name = self.delimited_sets() + else: + name = [n for n in name if self.is_delimited_set(n)] + msg = "Prevent one-category delimited set: Convert '{}' to single." + for n in name: + if len(self.codes(n)) == 1: + self.convert(n, 'single') + print msg.format(n) + return None + + def _check_against_weak_dupes(self, name): + included = self.resolve_name(name) + if included and self._verbose_infos: + w = "weak duplicate is created, {} found in DataSet. Please rename." + warnings.warn(w.format(included)) + def _verify_variable_meta_not_exist(self, name, is_array): """ """ - msg = '' - if not is_array: - if name in self._meta['columns']: - msg = "Overwriting meta for '{}', column already exists!" - else: - if name in self._meta['masks']: - msg = "Overwriting meta for '{}', mask already exists!" - if msg and self._verbose_infos: - print msg.format(name) - else: - return None + if not name in self: return None + if name in self.columns() or self._is_array_item(name): + if not is_array and self._verbose_infos: + print "Overwriting meta for '{}', column already exists!".format(name) + elif is_array: + raise ValueError("{} already exists as column.".format(name)) + elif name in self.masks(): + if is_array and self._verbose_infos: + print "Overwriting meta for '{}', mask already exists!".format(name) + elif not is_array: + raise ValueError("{} already exists as mask.".format(name)) + + @staticmethod + def _in_blacklist(name): + """ + """ + if name in BLACKLIST_VARIABLES: + msg = "Invalid variable name. '{}' is in the blacklist. " + msg += "Please consider another variable name" + raise ValueError(msg.format(name)) def _clean_codes_against_meta(self, name, codes): valid = [c for c in codes if c in self._get_valuemap(name, 'codes')] @@ -1960,6 +2277,14 @@ def _get_meta(self, var, type=None, text_key=None, axis_edit=None): def _pad_meta_list(meta_list, pad_to_len): return meta_list + ([''] * pad_to_len) + def enumerator(self, name): + x = 1 + n = name + while n in self: + x += 1 + n = '{}_{}'.format(name, x) + return n + # ------------------------------------------------------------------------ # fix/ repair meta data # ------------------------------------------------------------------------ @@ -2000,9 +2325,27 @@ def _clean_datafile_set(self): Drop references from ['sets']['data file']['items'] if they do not exist in the ``DataSet`` columns or masks definitions. """ - items = self._meta['sets']['data file']['items'] - n_items = [i for i in items if self.var_exists(i.split('@')[-1])] - self._meta['sets']['data file']['items'] = n_items + file_list = self._meta['sets']['data file']['items'] + for item in file_list[:]: + collection = item.split('@')[0] + variable = item.split('@')[1] + if not variable in self: + file_list.remove(item) + elif collection == 'masks': + for s in self._get_source_ref(variable): + while s in file_list: + file_list.remove(s) + elif self._is_array_item(variable): + parent = self.parents(variable)[0] + if not parent in file_list: + idx = file_list.index(item) + file_list[idx] = parent + while item in file_list: + file_list.remove(item) + f_list = [] + for item in file_list: + if not item in f_list: f_list.append(item) + self._meta['sets']['data file']['items'] = f_list return None def _fix_varnames(self): @@ -2044,6 +2387,32 @@ def restore_item_texts(self, arrays=None): self.set_item_texts(a, rename_items, tk, ed) return None + def _add_secure_variables(self): + """ Add variables in the CSV missing from the data-file set """ + ignore = ['@1', "id_L1"] + actual = [] + for item in self._meta['sets']['data file']['items']: + key, name = item.split('@') + if name in ignore: + continue + if key == 'columns': + actual.append(name) + elif key == 'masks': + for mitem in self._meta['masks'][name]['items']: + mkey, mname = mitem['source'].split('@') + actual.append(mname) + + expected = self._data.columns.values.tolist() + + for col in expected: + if col in ignore: + continue + if col not in actual: + print('Adding {}'.format(col)) + items = self._meta['sets']['data file']['items'] + items.append('columns@{}'.format(col)) + return None + def repair(self): """ Try to fix legacy meta data inconsistencies and badly shaped array / @@ -2055,6 +2424,8 @@ def repair(self): self.repair_text_edits() self.restore_item_texts() self._clean_datafile_set() + self._prevent_one_cat_set() + self._add_secure_variables() return None # ------------------------------------------------------------------------ @@ -2533,13 +2904,19 @@ def weight(self, weight_scheme, weight_name='weight', unique_key='identity', the weight factors. """ if subset: + if isinstance(subset, basestring): + if self.is_filter(subset): + subset = {subset: 0} + else: + raise ValueError('{} is not a valid filter_var'.format(subset)) ds = self.filter('subset', subset, False) meta, data = ds.split() else: meta, data = self.split() - engine = qp.WeightEngine(data, meta) + engine = qp.WeightEngine(data, meta=meta) engine.add_scheme(weight_scheme, key=unique_key, verbose=verbose) engine.run() + org_wname = weight_name if report: print engine.get_report() @@ -2549,23 +2926,39 @@ def weight(self, weight_scheme, weight_name='weight', unique_key='identity', full_file_path = '{} ({}).xlsx'.format(path_report, weight_name) df.to_excel(full_file_path) print 'Weight report saved to:\n{}'.format(full_file_path) + s_name = weight_scheme.name + s_w_name = 'weights_{}'.format(s_name) if inplace: - scheme_name = weight_scheme.name - weight_name = 'weights_{}'.format(scheme_name) - weight_description = '{} weights'.format(scheme_name) - data_wgt = engine.dataframe(scheme_name)[[unique_key, weight_name]] - data_wgt.rename(columns={weight_name: org_wname}, inplace=True) + weight_description = '{} weights'.format(s_name) + data_wgt = engine.dataframe(s_name)[[unique_key, s_w_name]] + data_wgt.rename(columns={s_w_name: org_wname}, inplace=True) if org_wname not in self._meta['columns']: self.add_meta(org_wname, 'float', weight_description) self.update(data_wgt, on=unique_key) else: - return data_wgt + wdf = engine.dataframe(weight_scheme.name) + return wdf.rename(columns={s_w_name: org_wname}) # ------------------------------------------------------------------------ # lists/ sets of variables/ data file items # ------------------------------------------------------------------------ - @modify(to_list=['varlist']) - @verify(variables={'varlist': 'both'}) + + def _array_and_item_list(self, v, keep): + new_list = [] + if not self.is_array(v): + # columns + if keep in ['both', 'items']: + new_list.append(v) + else: + # masks + if keep in ['both', 'mask']: + new_list.append(v) + if keep in ['both', 'items']: + new_list.extend(self.sources(v)) + return new_list + + @modify(to_list=['varlist', 'ignore_arrays']) + @verify(variables={'varlist': 'both_nested', 'ignore_arrays': 'masks'}) def roll_up(self, varlist, ignore_arrays=None): """ Replace any array items with their parent mask variable definition name. @@ -2577,34 +2970,50 @@ def roll_up(self, varlist, ignore_arrays=None): ignore_arrays : (list of) str A list of array mask names that should not be rolled up if their items are found inside ``varlist``. + + Note + ---- + varlist can also contain nesting `var1 > var2`. The variables which are + included in the nesting can also be controlled by keep and both, even + if the variables are also included as a "normal" variable. + Returns ------- rolled_up : list The modified ``varlist``. """ - if ignore_arrays: - if not isinstance(ignore_arrays, list): - ignore_arrays = [ignore_arrays] - else: - ignore_arrays = [] - arrays_defs = {arr: self.sources(arr) for arr in self.masks() - if not arr in ignore_arrays} - item_map = {} - for k, v in arrays_defs.items(): - for item in v: - item_map[item] = k + def _var_to_keep(var, ignore): + if self.is_array(var): + to_keep = 'mask' + else: + to_keep = 'items' + if self._is_array_item(var): + parent = self._maskname_from_item(var) + if parent not in ignore_arrays: + var = parent + to_keep = 'mask' + return var, to_keep + rolled_up = [] - for v in varlist: - if not self.is_array(v): - if v in item_map: - if not item_map[v] in rolled_up: - rolled_up.append(item_map[v]) - else: - rolled_up.append(v) + for var in varlist: + if ' > ' in var: + nested = var.replace(' ', '').split('>') + n_list = [] + for n in nested: + n, to_keep = _var_to_keep(n, ignore_arrays) + n_list.append(self._array_and_item_list(n, to_keep)) + for ru in [' > '.join(list(un)) for un in product(*n_list)]: + if ru not in rolled_up: + rolled_up.append(ru) + else: + var, to_keep = _var_to_keep(var, ignore_arrays) + for ru in self._array_and_item_list(var, to_keep): + if ru not in rolled_up: + rolled_up.append(ru) return rolled_up @modify(to_list=['varlist', 'keep', 'both']) - @verify(variables={'varlist': 'both', 'keep': 'masks'}) + @verify(variables={'varlist': 'both_nested', 'keep': 'masks'}) def unroll(self, varlist, keep=None, both=None): """ Replace mask with their items, optionally excluding/keeping certain ones. @@ -2619,24 +3028,54 @@ def unroll(self, varlist, keep=None, both=None): The names of masks that will be included both as themselves and as collections of their items. + Note + ---- + varlist can also contain nesting `var1 > var2`. The variables which are + included in the nesting can also be controlled by keep and both, even + if the variables are also included as a "normal" variable. + + Example:: + >>> ds.unroll(varlist = ['q1', 'q1 > gender'], both='all') + ['q1', + 'q1_1', + 'q1_2', + 'q1 > gender', + 'q1_1 > gender', + 'q1_2 > gender'] + Returns ------- unrolled : list The modified ``varlist``. """ if both and both[0] == 'all': - both = [mask for mask in varlist if mask in self._meta['masks']] + both = self.masks() unrolled = [] for var in varlist: - if not self.is_array(var): - unrolled.append(var) + if ' > ' in var: + nested = var.replace(' ', '').split('>') + n_list = [] + for n in nested: + if n in keep: + to_keep = 'mask' + elif n in both: + to_keep = 'both' + else: + to_keep = 'items' + n_list.append(self._array_and_item_list(n, to_keep)) + for ur in [' > '.join(list(un)) for un in product(*n_list)]: + if ur not in unrolled: + unrolled.append(ur) else: - if not var in keep: - if var in both: - unrolled.append(var) - unrolled.extend(self.sources(var)) + if var in keep: + to_keep = 'mask' + elif var in both: + to_keep = 'both' else: - unrolled.append(var) + to_keep = 'items' + for ur in self._array_and_item_list(var, to_keep): + if ur not in unrolled: + unrolled.append(ur) return unrolled def _apply_order(self, variables): @@ -2648,8 +3087,129 @@ def _apply_order(self, variables): self._data = self._data[column_order] return None + def _mapped_by_substring(self): + suffixed = {} + suffixed_variables = self.find() + if suffixed_variables: + for sv in suffixed_variables: + for suffix in VAR_SUFFIXES: + if suffix in sv: + origin = sv.split(suffix)[0] + + # test name... + origin_res = self.resolve_name(origin) + if not origin_res: + origin_res = origin + if isinstance(origin_res, list): + if len(origin_res) > 1: + msg = "Unable to regroup to {}, ".format(origin) + msg += "found weak duplicate derived names:\n" + msg += "{}".format(origin_res) + warnings.warn(msg) + origin_res = origin + else: + origin_res = origin_res[0] + + if not origin_res in suffixed: + suffixed[origin_res] = [sv] + else: + suffixed[origin_res].append(sv) + return suffixed + + def _mapped_by_meta(self): + rec_views = {} + for v in self.variables(): + origin = self.get_property(v, 'recoded_net') + if origin: + if not origin in rec_views: + rec_views[origin] = [v] + else: + rec_views[origin].append(v) + return rec_views + + def _map_to_origins(self): + by_origins = self._mapped_by_substring() + recoded_views = self._mapped_by_meta() + varlist = self.variables() + for var in varlist: + if var in recoded_views: + if not var in by_origins: + by_origins[var] = recoded_views[var] + else: + for recoded_view in recoded_views[var]: + if recoded_view not in by_origins[var]: + by_origins[var].append(recoded_view) + for k, v in by_origins.items(): + if not k in varlist: + del by_origins[k] + if not v[0] in varlist: + by_origins[v[0]] = v[1:] + sort_them = [] + for k, v in by_origins.items(): + sort_them.append(k) + sort_them.extend(v) + grouped = [] + for v in varlist: + if v in by_origins: + grouped.append(v) + grouped.extend(by_origins[v]) + else: + if not v in sort_them: grouped.append(v) + return grouped + + @modify(to_list=['vlist', 'fix']) + def align_order(self, vlist, align_against=None, + integrate_rc=(["_rc", "_rb"], True), fix=[]): + """ + Align list to existing order. + + Parameters + ---------- + vlist: list of str + The list which should be reordered. + align_against: str or list of str, default None + The list of variables to align against. If a string is provided, + the depending set list is taken. If None, "data file" set is taken. + integrate_rc: tuple (list, bool) + The provided list are the suffixes for recodes, the bool decides + whether parent variables should be replaced by their recodes if + the parent variable is not in vlist. + fix: list of str + Variables which are fixed at the beginning of the reordered list. + """ + # get list to align against + if not align_against: + align_against = self._variables_from_set("data file") + elif isinstance(align_against, basestring): + align_against = self._variables_from_set(align_against) + + # recode suffixes and replace parent + if not integrate_rc: + integrate_rc = ([], False) + rec_suf, repl_parent = integrate_rc + + # create aligned order + new_vlist = fix[:] + for v in align_against: + recodes = ["{}{}".format(v, suf) for suf in rec_suf] + if v in vlist: + if v not in new_vlist: + new_vlist.append(v) + for rec in recodes: + if rec in vlist and rec not in new_vlist: + new_vlist.append(rec) + elif repl_parent: + for rec in recodes: + if rec in vlist and rec not in new_vlist: + new_vlist.append(rec) + + # add missing vars + miss = [v for v in vlist if v not in new_vlist] + new_vlist += miss + return new_vlist + @modify(to_list='reposition') - def order(self, new_order=None, reposition=None): + def order(self, new_order=None, reposition=None, regroup=False): """ Set the global order of the DataSet variables collection. @@ -2664,23 +3224,36 @@ def order(self, new_order=None, reposition=None): reposition : (List of) dict Each dict maps one or a list of variables to a reference variable name key. The mapped variables are moved before the reference key. + regroup : bool, default False + Attempt to regroup non-native variables (i.e. created either + manually with ``add_meta()``, ``recode()``, ``derive()``, etc. + or automatically by manifesting ``qp.View`` objects) with their + originating variables. Returns ------- None """ - if new_order and reposition: - err = "Cannot reposition variables if 'new_order' is specified." + if (bool(new_order) + bool(reposition) + regroup) > 1: + err = "Can only either apply ``new_order``, ``reposition`` or " + err += "``regroup`` variables, not perform multiple operations at once." raise ValueError(err) - if not reposition: + if new_order: if not sorted(self._variables_from_set('data file')) == sorted(new_order): err = "'new_order' must contain all DataSet variables." raise ValueError(err) check = new_order - else: + elif reposition: check = [] for r in reposition: check.extend(list(r.keys() + r.values())) + elif regroup: + new_order = self._map_to_origins() + check = new_order + else: + err = "No ``order`` operation provided, select one of " + err += "``new_order``, ``regroup``, ``reposition``." + raise ValueError(err) if not all(self.var_exists(v) for v in check): err = "At least one variable named in ordering does not exist." raise ValueError(err) @@ -2792,6 +3365,213 @@ def create_set(self, setname='new_set', based_on='data file', included=None, return None + @modify(to_list=['logic']) + def add_filter_var(self, name, logic, overwrite=False): + """ + Create filter-var, that allows index slicing using ``manifest_filter`` + + Parameters + ---------- + name: str + Name and label of the new filter-variable, which gets also listed + in DataSet.filters + logic: complex logic/ str, list of complex logic/ str + Logic to keep cases. + Complex logic should be provided in form of: + ``` + { + 'label': 'any text', + 'logic': {var: keys} / intersection/ .... + } + ``` + If a str (column-name) is provided, automatically a logic is + created that keeps all cases which are not empty for this column. + If logic is a list, each included list-item becomes a category of + the new filter-variable and all cases are kept that satify all + conditions (intersection) + + overwrite: bool, default False + Overwrite an already existing filter-variable. + """ + name = self._verify_filter_name(name, None) + if name in self: + if overwrite and not self.is_filter(name): + msg = "Cannot add filter-variable '{}', a non-filter" + msg +=" variable is already included" + raise ValueError(msg.format(name)) + elif not overwrite: + msg = "Cannot add filter-variable '{}', it's already included." + raise ValueError(msg.format(name)) + else: + self.drop(name) + if self._verbose_infos: + print 'Overwriting {}'.format(name) + values = [(0, 'keep', None)] + values += self._transform_filter_logics(logic, 1) + self.add_meta(name, 'delimited set', name, [(x, y) for x, y, z in values]) + self.recode(name, {x: z for x, y, z in values[1:]}) + self.recode(name, {0: {name: has_count(len(values)-1)}}, append=True) + self._set_property(name, 'recoded_filter', True) + return None + + @modify(to_list=['logic']) + def extend_filter_var(self, name, logic, extend_as=None): + """ + Extend logic of an existing filter-variable. + + Parameters + ---------- + name: str + Name of the existing filter variable. + logic: (list of) complex logic/ str + Additional logic to keep cases (intersection with existing logic). + Complex logic should be provided in form of: + ``` + { + 'label': 'any text', + 'logic': {var: keys} / intersection/ .... + } + ``` + extend_as: str, default None + Addition to the filter-name to create a new filter. If it is None + the existing filter-variable is overwritten. + """ + if not self.is_filter(name): + raise KeyError('{} is no valid filter-variable.'.format(name)) + name = self._verify_filter_name(name, None) + if extend_as: + extend_as = self._verify_filter_name(extend_as, None) + f_name = '{}_{}'.format(name, extend_as) + if f_name in self: + msg = "Please change 'extend_as': '{}' is already in dataset." + raise KeyError(msg.format(f_name)) + self.copy(name, extend_as) + self._meta['columns'][f_name]['properties']['recoded_filter'] = True + else: + f_name = name + self.uncode(f_name, {0: {f_name: 0}}) + values = self._transform_filter_logics(logic, max(self.codes(f_name))+1) + self.extend_values(f_name, values) + self.recode(f_name, {x: z for x, y, z in values}, append=True) + self.recode(f_name, {0: {f_name: has_count(len(self.codes(f_name))-1)}}, append=True) + text = '{} _ {}'.format(self.text(f_name), extend_as) + self._meta['columns'][f_name]['text'][self.text_key] = text + return None + + def _transform_filter_logics(self, logic, start): + if not logic: logic = ['@1'] + values = [] + for x, l in enumerate(logic, start): + if isinstance(l, basestring): + if not l in self: + raise KeyError("{} is not included in Dataset".format(l)) + val = (x, '{} not empty'.format(l), {l: not_count(0)}) + elif isinstance(l, dict): + if not ('label' in l and 'logic' in l): + l = {'label': str(x), 'logic': l} + if self._verbose_infos: + msg = "Filter logic must contain 'label' and 'logic'" + warnings.warn(msg) + val = (x, l['label'], l['logic']) + else: + try: + l[0].__name__ in ['_intersection', '_union'] + val = (x, str(x), l) + except: + msg = 'Included logic must be (list of) str or dict/complex logic.' + raise TypeError(msg) + values.append(val) + return values + + def _verify_filter_name(self, name, suf='f', number=False): + f = '{}_{}'.format(name, suf) if suf else name + f = f.encode('utf8') + repl = [(' ', '_'), ('~', '_'), ('(', ''), (')', ''), ('&', '_')] + for r in repl: + f = f.replace(r[0], r[1]) + if number: + f = self.enumerator(f) + return f + + @modify(to_list=['values']) + def reduce_filter_var(self, name, values): + """ + Remove values from filter-variables and recalculate the filter. + """ + name = self._verify_filter_name(name, None) + if not self.is_filter(name): + raise KeyError('{} is no valid filter-variable.'.format(name)) + if 0 in values: + raise ValueError('Cannot remove the 0-keep value from filter var') + elif len([x for x in self.codes(name) if not x in values]) <= 1: + raise ValueError('Cannot remove all values from filter var.') + self.uncode(name, {0: {name: 0}}) + self.remove_values(name, values) + self.recode(name, {0: {name: has_count(len(self.codes(name))-1)}}, append=True) + return None + + def manifest_filter(self, name): + """ + Get index slicer from filter-variables. + + Parameters + ---------- + name: str + Name of the filter_variable. + """ + if not name: + return self._data.index + else: + name = self._verify_filter_name(name, None) + if not self.is_filter(name): + raise KeyError('{} is no valid filter-variable.'.format(name)) + return self.take({name: 0}) + + @modify(to_list="filters") + def merge_filter(self, name, filters): + if not all(f in self.filters() for f in filters): + raise KeyError("Not all included names are valid filters.") + logic = { + 'label': 'merged filter logics', + 'logic': union([{f: 0} for f in filters]) + } + self.add_filter_var(name, logic, True) + return None + + @modify(to_list=['name2']) + @verify(variables={'name1': 'both', 'name2': 'both'}) + def compare_filter(self, name1, name2): + """ + Show if filters result in the same index. + + Parameters + ---------- + name1: str + Name of the first filter variable + name2: str/ list of st + Name(s) of the filter variable(s) to compare with. + """ + if not all(self.is_filter(f) for f in [name1] + name2): + raise ValueError('Can only compare filter variables') + equal = True + f0 = self.manifest_filter(name1).tolist() + for f in name2: + if not f0 == self.manifest_filter(f).tolist(): + equal = False + return equal + + @modify(to_list=["name2"]) + def is_subfilter(self, name1, name2): + """ + Verify if index of name2 is part of the index of name1. + """ + idx = self.manifest_filter(name1).tolist() + included = True + for n in name2: + if [i for i in self.manifest_filter(n).tolist() if i not in idx]: + included = False + return included + # ------------------------------------------------------------------------ # extending / merging # ------------------------------------------------------------------------ @@ -2799,7 +3579,8 @@ def create_set(self, setname='new_set', based_on='data file', included=None, @modify(to_list=['dataset']) @verify(variables={'on': 'columns', 'left_on': 'columns'}) def hmerge(self, dataset, on=None, left_on=None, right_on=None, - overwrite_text=False, from_set=None, inplace=True, verbose=True): + overwrite_text=False, from_set=None, inplace=True, + merge_existing=None, verbose=True): """ Merge Quantipy datasets together using an index-wise identifer. @@ -2840,6 +3621,12 @@ def hmerge(self, dataset, on=None, left_on=None, right_on=None, If the merge is not applied ``inplace``, a ``DataSet`` instance is returned. """ + new_tks = [] + for d in dataset: + for tk in d.valid_tks: + if not d in self.valid_tks and not d in new_tks: + new_tks.append(tk) + self.extend_valid_tks(new_tks) ds_left = (self._meta, self._data) ds_right = [(ds._meta, ds._data) for ds in dataset] if on is None and right_on in self.columns(): @@ -2848,7 +3635,8 @@ def hmerge(self, dataset, on=None, left_on=None, right_on=None, id_backup = None merged_meta, merged_data = _hmerge( ds_left, ds_right, on=on, left_on=left_on, right_on=right_on, - overwrite_text=overwrite_text, from_set=from_set, verbose=verbose) + overwrite_text=overwrite_text, from_set=from_set, verbose=verbose, + merge_existing=merge_existing) if id_backup is not None: merged_data[right_on] = id_backup if inplace: @@ -2860,6 +3648,7 @@ def hmerge(self, dataset, on=None, left_on=None, right_on=None, new_dataset._data = merged_data new_dataset._meta = merged_meta return new_dataset + return None def update(self, data, on='identity'): """ @@ -3003,6 +3792,34 @@ def duplicates(self, name='identity'): vals = [int(i) for i in vals] return vals + @verify(variables={'sort_by': 'columns'}) + def drop_duplicates(self, unique_id='identity', keep='first', sort_by=None): + """ + Drop duplicated cases from self._data. + + Parameters + ---------- + unique_id : str + Variable name that gets scanned for duplicates. + keep : str, {'first', 'last'} + Keep first or last of the duplicates. + sort_by : str + Name of a variable to sort the data by, for example "endtime". + It is a helper to specify `keep`. + """ + if sort_by: + self._data.sort(sort_by, inplace=True) + self._data.reset_index(drop=True, inplace=True) + if self.duplicates(unique_id): + cases_before = self._data.shape[0] + self._data.drop_duplicates(subset=unique_id, keep=keep, inplace=True) + if self._verbose_infos: + cases_after = self._data.shape[0] + droped_cases = cases_before - cases_after + msg = '%s duplicated case(s) dropped, %s cases remaining' + print msg % (droped_cases, cases_after) + return None + @verify(variables={'id_key_name': 'columns', 'multiplier': 'columns'}) def _make_unique_key(self, id_key_name, multiplier): """ @@ -3046,6 +3863,7 @@ def merge_texts(self, dataset): # Recoding # ------------------------------------------------------------------------ + @modify(to_list=['categories', 'items']) @verify(text_keys='text_key') def add_meta(self, name, qtype, label, categories=None, items=None, text_key=None, replace=True): @@ -3088,29 +3906,32 @@ def add_meta(self, name, qtype, label, categories=None, items=None, ``DataSet`` is modified inplace, meta data and ``_data`` columns will be added """ + # verify name + self._in_blacklist(name) make_array_mask = True if items else False - test_name = name - self._verify_variable_meta_not_exist(test_name, make_array_mask) - if not text_key: text_key = self.text_key - if make_array_mask: - self._add_array(name, qtype, label, items, categories, text_key) - return None + self._verify_variable_meta_not_exist(name, make_array_mask) + + # verify qtype + valid = ['delimited set', 'single', 'float', 'int', 'date', 'string'] categorical = ['delimited set', 'single'] numerical = ['int', 'float'] - if not qtype in ['delimited set', 'single', 'float', 'int', - 'date', 'string']: + if not qtype in valid: raise NotImplementedError('Type {} data unsupported'.format(qtype)) - if qtype in categorical and not categories: + elif qtype in categorical and not categories: val_err = "Must provide 'categories' when requesting data of type {}." raise ValueError(val_err.format(qtype)) + elif qtype == 'delimited set' and len(categories) == 1: + qtype = 'single' + print 'Only one category is given, qtype is switched to single.' elif qtype in numerical and categories: val_err = "Numerical data of type {} does not accept 'categories'." raise ValueError(val_err.format(qtype)) - else: - if not isinstance(categories, list) and qtype in categorical: - raise TypeError("'Categories' must be a list of labels " - "('str') or a list of tuples of codes ('int') " - "and lables ('str').") + + if not text_key: text_key = self.text_key + if make_array_mask: + self._add_array(name, qtype, label, items, categories, text_key) + return None + new_meta = {'text': {text_key: label}, 'type': qtype, 'name': name, @@ -3242,6 +4063,59 @@ def dichotomize(self, name, value_texts=None, keep_variable_text=True, self.drop(name) return None + @verify(variables={'name': 'columns'}) + def first_responses(self, name, n=3, others='others', reduce_values=False): + """ + Create n-first mentions from the set of responses of a delimited set. + + Parameters + ---------- + name : str + The column variable name of a delimited set keyed in + ``meta['columns']``. + n : int, default 3 + The number of mentions that will be turned into single-type + variables, i.e. 1st mention, 2nd mention, 3rd mention, 4th mention, + etc. + others : None or str, default 'others' + If provided, all remaining values will end up in a new delimited + set variable reduced by the responses transferred to the single + mention variables. + reduce_values : bool, default False + If True, each new variable will only list the categorical value + metadata for the codes found in the respective data vector, i.e. + not the initial full codeframe. + + Returns + ------- + None + DataSet is modified inplace. + """ + if self._get_type(name) != 'delimited set': + return None + created = [] + values = self.values(name) + for _n in frange('1-{}'.format(n)): + n_name = '{}_{}'.format(name, _n) + n_label = '{} ({})'.format(self.text(name), _n) + self.add_meta(n_name, 'single', n_label, values) + n_vector = self[name].str.split(';', n=_n, expand=True)[_n-1] + self[n_name] = n_vector.replace(('', None), np.NaN).astype(float) + created.append(n_name) + if others: + o_name = '{}_{}'.format(name, others) + o_label = '{} ({})'.format(self.text(name), others) + self.add_meta(o_name, 'delimited set', o_label, values) + o_string = self[name].str.split(';', n=n, expand=True)[n] + self[o_name] = o_string.replace(('', None), np.NaN) + created.append(o_name) + if reduce_values: + for v in created: + reduce_codes = [value[0] for value in values + if value[0] not in self.codes_in_data(v)] + self.remove_values(v, reduce_codes) + return None + @modify(to_list='codes') @verify(variables={'name': 'masks'}, text_keys='text_key') def flatten(self, name, codes, new_name=None, text_key=None): @@ -3318,9 +4192,11 @@ def remove_loop(obj, var): ind = df_items.index('masks@{}'.format(var)) n_items = df_items[:ind] + self._get_source_ref(var) + df_items[ind+1:] meta['sets']['data file']['items'] = n_items - values = meta['lib']['values'][var] + if self._has_categorical_data(var): + values = meta['lib']['values'][var] for source in self.sources(var): - meta['columns'][source]['values'] = values + if self._has_categorical_data(var): + meta['columns'][source]['values'] = values meta['columns'][source]['parent'] = {} df_items = meta['sets']['data file']['items'] @@ -3331,6 +4207,22 @@ def remove_loop(obj, var): if not self.is_array(var): data_drop.append(var) remove_loop(meta, var) data.drop(data_drop, 1, inplace=True) + + return None + + @modify(to_list=['name']) + @verify(variables={'name': 'both'}) + def unbind(self, name): + """ + Remove mask-structure for arrays + """ + remove = [] + for n in name: + if not self.is_array(n): continue + self.drop(n, ignore_items=True) + remove.append(n) + if remove and self._verbose_infos: + print "Remove mask structure for: '{}'".format("', '".join(remove)) return None @modify(to_list=['copy_only', 'copy_not']) @@ -3392,8 +4284,8 @@ def copy(self, name, suffix='rec', copy_data=True, slicer=None, copy_only=None, name = self._dims_free_arr_name(name) check_name = self._dims_compat_arr_name(copy_name) - if self.var_exists(check_name): self.drop(check_name) + self._check_against_weak_dupes(check_name) if is_array: # copy meta and create rename mapper for array items @@ -3427,7 +4319,7 @@ def copy(self, name, suffix='rec', copy_data=True, slicer=None, copy_only=None, self._data[copy_name] = np.NaN # run the renaming for the copied variable - self.rename_from_mapper(renames, keep_original=True) + self.rename_from_mapper(renames, keep_original=True, ignore_batch_props=True) # set type 'created' if is_array: for s in self.sources(copy_name): @@ -3525,7 +4417,8 @@ def unify_values(self, name, code_map, slicer=None, exclusive=False): @modify(to_list=['ignore_items', 'ignore_values']) @verify(variables={'name': 'masks'}, text_keys='text_key') def transpose(self, name, new_name=None, ignore_items=None, - ignore_values=None, copy_data=True, text_key=None): + ignore_values=None, copy_data=True, text_key=None, + overwrite=False): """ Create a new array mask with transposed items / values structure. @@ -3552,59 +4445,54 @@ def transpose(self, name, new_name=None, ignore_items=None, text_key : str The text key to be used when generating text objects, i.e. item and value labels. + overwrite: bool, default False + Overwrite variable if `new_name` is already included. Returns ------- None DataSet is modified inplace. """ - org_name = name - # Get array item and value structure - reg_items_object = self._get_itemmap(name) - if ignore_items: - reg_items_object = [i for idx, i in - enumerate(reg_items_object, start=1) - if idx not in ignore_items] - reg_item_names = [item[0] for item in reg_items_object] - reg_item_texts = [item[1] for item in reg_items_object] - - reg_value_object = self._get_valuemap(name) - if ignore_values: - reg_value_object = [v for v in reg_value_object if v[0] - not in ignore_values] - reg_val_codes = [v[0] for v in reg_value_object] - reg_val_texts = [v[1] for v in reg_value_object] - - # Transpose the array structure: values --> items, items --> values - trans_items = [(code, value) for code, value in - zip(reg_val_codes, reg_val_texts)] - trans_values = [(idx, text) for idx, text in - enumerate(reg_item_texts, start=1)] - label = self.text(name, False, text_key) - # Create the new meta data entry for the transposed array structure + if (new_name and self._dims_compat_arr_name(new_name) in self and + not overwrite): + raise ValueError("'{}' is already included.".format(new_name)) if not new_name: - new_name = '{}_trans'.format(self._dims_free_arr_name(name)) - dims_compat_name = self._dims_compat_arr_name(new_name) - qtype = 'delimited set' - self.add_meta(new_name, qtype, label, trans_values, trans_items, text_key) - # Do the case data transformation by looping through items and - # convertig value code entries... - new_name = self._dims_compat_arr_name(new_name) - trans_items = self._get_itemmap(new_name, 'items') - trans_values = self._get_valuemap(new_name, 'codes') - for reg_item_name, new_val_code in zip(reg_item_names, trans_values): - for reg_val_code, trans_item in zip(reg_val_codes, trans_items): - if trans_item not in self._data.columns: - if qtype == 'delimited set': - self[trans_item] = '' - else: - self[trans_item] = np.NaN - if copy_data: - slicer = {reg_item_name: [reg_val_code]} - self.recode(trans_item, {new_val_code: slicer}, - append=True) - if self._verbose_infos: - print 'Transposed array: {} into {}'.format(org_name, dims_compat_name) + new_name = '{}_trans'.format(name) + if new_name == name: + tname = '{}_trans'.format(new_name) + else: + tname = new_name + + # input item_map + item_map = self._get_itemmap(name) + item_labels = [(x, i[1]) for x, i in enumerate(item_map, 1) + if not x in ignore_items] + item_vars = [(x, i[0]) for x, i in enumerate(item_map, 1) + if not x in ignore_items] + # input value_map + value_map = self._get_valuemap(name) + value_map = [v for x, v in enumerate(value_map, 1) + if not x in ignore_values] + # input label + label = self.text(name, False, text_key) + # add transposed meta + self.add_meta(tname, "delimited set", label, item_labels, value_map, text_key) + tname = self._dims_compat_arr_name(tname) + + # transpose the data + tsources = self.sources(tname) + mapper = { + tsource: {} for tsource in tsources + } + for code, source in zip([val[0] for val in value_map], tsources): + mapper = {} + for x, item in item_vars: + mapper[x] = {item: code} + self.recode(source, mapper, append=True) + if new_name == name: + print("Overwrite '{}'.".format(name)) + self.drop(name) + self.rename(tname, new_name) @verify(variables={'target': 'columns'}) def recode(self, target, mapper, default=None, append=False, @@ -3825,6 +4713,49 @@ def interlock(self, name, label, variables, val_text_sep = '/'): self.drop(var) return None + @verify(variables={'name': 'masks'}) + def _level(self, name): + """ + """ + self.copy(name, 'level') + if self._dimensions_comp: + temp = self._dims_free_arr_name(name) + lvlname = self._dims_compat_arr_name('{}_level'.format(temp)) + else: + lvlname = '{}_level'.format(name) + items = self.items(name) + sources = enumerate(self.sources(lvlname), 1) + codes = self.codes(lvlname) + max_code = len(codes) + replace_codes = {} + mapped_codes = {c: [] for c in self.codes(name)} + + for no, source in sources: + offset = (no-1) * max_code + new_codes = frange('{}-{}'.format((offset + 1), (offset + max_code))) + replace_codes[source] = dict(zip(codes, new_codes)) + + for source, codes in replace_codes.items(): + self[source].replace(codes, inplace=True) + self[source].replace(np.NaN, '', inplace=True) + for org, new in codes.items(): + mapped_codes[org].append(new) + + code_range = frange('1-{}'.format(max_code * len(items))) + labels = self.value_texts(name) * len(items) + cats = zip(code_range, labels) + new_sources = self.sources(lvlname) + self.unbind(lvlname) + self.add_meta(lvlname, 'delimited set', self.text(name), cats) + self[lvlname] = self[new_sources].astype('str').apply( + lambda x: ';'.join(x).replace('.0', ''), axis=1) + self.drop(new_sources) + self._meta['columns'][lvlname]['properties']['level'] = { + 'source': name, + 'level_codes': mapped_codes, + 'item_look': self.sources(name)[0]} + return None + @verify(text_keys='text_key') def derive(self, name, qtype, label, cond_map, text_key=None): """ @@ -4023,38 +4954,45 @@ def to_delimited_set(self, name, label, variables, from_dichotomous=True, return None - def to_array(self, name, variables, label): + def to_array(self, name, variables, label, safe=True): """ Combines column variables with same ``values`` meta into an array. Parameters ---------- - name: str + name : str Name of new grid. - variables: list of str or list of dicts + variables : list of str or list of dicts Variable names that become items of the array. New item labels can be added as dict. Example: variables = ['q1_1', {'q1_2': 'shop 2'}, {'q1_3': 'shop 3'}] - label: str + label : str Text label for the mask itself. + safe : bool, default True + If True, the method will raise a ``ValueError`` if the provided + variable name is already present in self. Select ``False`` to + forcefully overwrite an existing variable with the same name + (independent of its type). Returns ------- None """ meta = self._meta - newname = self._dims_compat_arr_name(name) if self.var_exists(newname): - raise ValueError('{} does already exist.'.format(name)) + if safe: + raise ValueError('{} does already exist.'.format(name)) + self.drop(newname, ignore_items=True) var_list = [v.keys()[0] if isinstance(v, dict) else v for v in variables] if not all(self.var_exists(v) for v in var_list): raise KeyError("'variables' must be included in DataSet.") + elif not len(set(var_list)) == len(var_list): + raise ValueError("'variables' contains duplicates!") to_comb = {v.keys()[0]: v.values()[0] for v in variables if isinstance(v, dict)} for var in var_list: to_comb[var] = self.text(var) if var in variables else to_comb[var] - first = var_list[0] subtype = self._get_type(var_list[0]) if self._has_categorical_data(var_list[0]): @@ -4228,6 +5166,8 @@ def _as_single(self, name): """ Change type from ``int``/``date``/``string`` to ``single``. + ``delimited sets`` can be converted if only one category is defined. + Parameters ---------- name : str @@ -4239,9 +5179,9 @@ def _as_single(self, name): """ org_type = self._get_type(name) if org_type == 'single': return None - valid = ['int', 'date', 'string'] + valid = ['int', 'date', 'string', 'delimited set'] + msg = 'Cannot convert variable {} of type {} to single!' if not org_type in valid: - msg = 'Cannot convert variable {} of type {} to single!' raise TypeError(msg.format(name, org_type)) text_key = self.text_key if org_type == 'int': @@ -4263,6 +5203,12 @@ def _as_single(self, name): replace_map = {v: i for i, v in enumerate(vals, start=1)} if replace_map: self._data[name].replace(replace_map, inplace=True) + elif org_type == 'delimited set': + if not len(self.codes(name)) == 1: + raise TypeError(msg.format(name, org_type)) + self._data[name] = self._data[name].apply(lambda x: + int(x.replace(';', '')) if isinstance(x, basestring) else np.NaN) + values_obj = self._get_value_loc(name) self._meta['columns'][name]['type'] = 'single' self._meta['columns'][name]['values'] = values_obj return None @@ -4292,10 +5238,6 @@ def _as_string(self, name): self._data[name] = self._data[name].astype(str) return None - # ------------------------------------------------------------------------ - # Editing - # ------------------------------------------------------------------------ - # renaming # ------------------------------------------------------------------------ @@ -4311,29 +5253,34 @@ def rename(self, name, new_name): or ``meta['masks']``. new_name : str The new variable name. - verify_name : bool, default True - If False the ``new_name`` will not be matched agaist any Dimensions Returns ------- None - DataSet is modified inplace. The new name reference is placed into - both the data and meta component. + DataSet is modified inplace. The new name reference replaces the + original one. """ renames = {} if new_name in self._data.columns: msg = "Cannot rename '{}' into '{}'. Column name already exists!" raise ValueError(msg.format(name, new_name)) + self._in_blacklist(new_name) + self._check_against_weak_dupes(new_name) + if not self._dimensions_comp == 'ignore': self.undimensionize([name] + self.sources(name)) name = self._dims_free_arr_name(name) - for s in self.sources(name): - new_s_name = '{}_{}'.format(new_name, s.split('_')[-1]) + for no, s in enumerate(self.sources(name), start=1): + if '_' in s and s.split('_')[-1].isdigit(): + new_s_name = '{}_{}'.format(new_name, s.split('_')[-1]) + else: + new_s_name = '{}_{}'.format(new_name, no) self._add_all_renames_to_mapper(renames, s, new_s_name) self._add_all_renames_to_mapper(renames, name, new_name) + self.rename_from_mapper(renames) if self._dimensions_comp and not self._dimensions_comp == 'ignore': @@ -4341,7 +5288,8 @@ def rename(self, name, new_name): return None - def rename_from_mapper(self, mapper, keep_original=False): + def rename_from_mapper(self, mapper, keep_original=False, + ignore_batch_props=False): """ Rename meta objects and data columns using mapper. @@ -4357,15 +5305,33 @@ def rename_from_mapper(self, mapper, keep_original=False): None DataSet is modified inplace. """ + def rename_properties(mapper): + """ + Rename variable properties that reference other variables, i.e. + 'recoded_net', 'recoded_stat' meta objects. + """ + net_recs = self._net_view_recodes() + stat_recs = self._stat_view_recodes() + all_recs = set([r for r in net_recs + stat_recs if r in mapper]) + for rec in all_recs: + if self._is_array_item(rec): continue + rn = self.get_property(rec, 'recoded_net') + if rn: self._set_property(rec, 'recoded_net', mapper[rn]) + rs = self.get_property(rec, 'recoded_stat') + if rs: self._set_property(rec, 'recoded_stat', mapper[rs]) + return None - def rename_meta(meta, mapper): + def rename_meta(meta, mapper, ignore_batch_props): """ Rename lib@values, masks, set items and columns using mapper. """ + rename_properties(mapper) rename_lib_values(meta['lib']['values'], mapper) rename_masks(meta['masks'], mapper, keep_original) rename_columns(meta['columns'], mapper, keep_original) rename_sets(meta['sets'], mapper, keep_original) + if 'batches' in meta['sets'] and not ignore_batch_props: + rename_batch_properties(meta['sets']['batches'], mapper) if not keep_original: rename_set_items(meta['sets'], mapper) @@ -4442,6 +5408,29 @@ def rename_sets(sets, mapper, keep_original): if item in mapper: items[i] = mapper[item] + def rename_batch_properties(batches, mapper): + + def _iterate_props(obj, mapper): + if isinstance(obj, bool): + pass + elif isinstance(obj, basestring): + return mapper.get(obj) + elif isinstance(obj, dict): + for k, v in obj.items(): + if _iterate_props(k, mapper): + obj[_iterate_props(k, mapper)] = _iterate_props(v, mapper) or v + del obj[k] + else: + obj[k] = _iterate_props(v, mapper) or v + elif isinstance(obj, list): + return [_iterate_props(a, mapper) or a for a in obj] + elif isinstance(obj, tuple): + return tuple(_iterate_props(a, mapper) or a for a in obj) + + for batch, defs in batches.items(): + _iterate_props(defs, mapper) + + def rename_set_items(sets, mapper): """ Rename standard set object items using mapper. @@ -4456,7 +5445,7 @@ def rename_set_items(sets, mapper): except (AttributeError, KeyError, TypeError, ValueError): pass - rename_meta(self._meta, mapper) + rename_meta(self._meta, mapper, ignore_batch_props) if not keep_original: self._data.rename(columns=mapper, inplace=True) def dimensionizing_mapper(self, names=None): @@ -4475,38 +5464,59 @@ def dimensionizing_mapper(self, names=None): maps non-Dimensions naming conventions to Dimensions naming conventions. """ + + def fix(string): + tags = [ + "'", '"', ' ', '&', '.', '/', '-', + '(', ')', '[', ']', '{', '}' + ] + for tag in tags: + string = string.replace(tag, '_') + return string + masks = self._meta['masks'] columns = self._meta['columns'] suffix = self._dimensions_suffix + if not names: names = self.variables() mapper = {} - if not names: - names = masks.keys() - for mask_name, mask in masks.iteritems(): - if mask_name in names: + for org_mn, mask in masks.iteritems(): + if org_mn in names: + mask_name = fix(org_mn) new_mask_name = '{mn}.{mn}{s}'.format(mn=mask_name, s=suffix) - mapper[mask_name] = new_mask_name + mapper[org_mn] = new_mask_name - mask_mapper = 'masks@{mn}'.format(mn=mask_name) + mask_mapper = 'masks@{mn}'.format(mn=org_mn) new_mask_mapper = 'masks@{nmn}'.format(nmn=new_mask_name) mapper[mask_mapper] = new_mask_mapper - values_mapper = 'lib@values@{mn}'.format(mn=mask_name) + values_mapper = 'lib@values@{mn}'.format(mn=org_mn) new_values_mapper = 'lib@values@{nmn}'.format(nmn=new_mask_name) mapper[values_mapper] = new_values_mapper - items = masks[mask_name]['items'] + items = masks[org_mn]['items'] for i, item in enumerate(items): - col_name = item['source'].split('@')[-1] + org_cn = item['source'].split('@')[-1] + col_name = fix(org_cn) new_col_name = '{mn}[{{{cn}}}].{mn}{s}'.format( mn=mask_name, cn=col_name, s=suffix ) - mapper[col_name] = new_col_name + mapper[org_cn] = new_col_name - col_mapper = 'columns@{cn}'.format(cn=col_name) + col_mapper = 'columns@{cn}'.format(cn=org_cn) new_col_mapper = 'columns@{ncn}'.format(ncn=new_col_name) mapper[col_mapper] = new_col_mapper + for col_name, col in columns.iteritems(): + if col_name in names and not self._is_array_item(col_name): + new_col_name = fix(col_name) + if new_col_name == col_name: continue + mapper[col_name] = new_col_name + + col_mapper = 'columns@{cn}'.format(cn=col_name) + new_col_mapper = 'columns@{ncn}'.format(ncn=new_col_name) + mapper[col_mapper] = new_col_mapper + return mapper def undimensionizing_mapper(self, names=None): @@ -4571,7 +5581,11 @@ def dimensionize(self, names=None): raise ValueError('File is already dimensionized.') mapper = self.dimensionizing_mapper(names) self.rename_from_mapper(mapper) - if not names: self.set_dim_comp(True) + if not names: + self.set_dim_comp(True) + if 'type' in self: + self.rename('type', '_type') + return None @modify(to_list='names') @verify(variables={'names': 'both'}) @@ -4674,6 +5688,8 @@ def remove_values(self, name, remove): else: self.uncode(name, {x: {name: x} for x in remove}) self._verify_data_vs_meta_codes(name) + # convert delimited set to single if only one cat is left + self._prevent_one_cat_set(name) return None @modify(to_list='ext_values') @@ -4692,7 +5708,7 @@ def extend_values(self, name, ext_values, text_key=None, safe=True): ``_meta['masks']``. ext_values : list of str or tuples in form of (int, str), default None When a list of str is given, the categorical values will simply be - enumerated and maped to the category labels. Alternatively codes can + enumerated and mapped to the category labels. Alternatively codes can mapped to categorical labels, e.g.: [(1, 'Elephant'), (2, 'Mouse'), (999, 'No animal')] text_key : str, default None @@ -4899,16 +5915,40 @@ def extend_valid_tks(self, new_tk): self._meta['lib']['valid text'] = self.valid_tks return None + @staticmethod + def _used_text_keys(text_dict, tks): + new = [tk for tk in text_dict.keys() + if not tk in ['x edits', 'y edits'] + tks['tks']] + tks['tks'] += new + + def used_text_keys(self): + """ + Get a list of all used textkeys in the dataset instance. + """ + text_func = self._used_text_keys + args = () + kwargs = {'tks': {'tks': []}} + DataSet._apply_to_texts(text_func, self._meta, args, kwargs) + return kwargs['tks']['tks'] + @staticmethod def _force_texts(text_dict, copy_to, copy_from, update_existing): new_text_key = None for new_tk in reversed(copy_from): if new_tk in text_dict.keys(): - new_text_key = new_tk + if new_tk in ['x edits', 'y edits']: + if text_dict[new_tk].get(copy_to): + new_text_key = new_tk + else: + new_text_key = new_tk if not new_text_key: raise ValueError('{} is no existing text_key'.format(copy_from)) - if not copy_to in text_dict.keys() or update_existing: - text_dict.update({copy_to: text_dict[new_text_key]}) + if not text_dict.get(copy_to) or update_existing: + if new_text_key in ['x edits', 'y edits']: + text = text_dict[new_text_key][copy_to] + else: + text = text_dict[new_text_key] + text_dict.update({copy_to: text}) @modify(to_list='copy_from') @verify(text_keys=['copy_to', 'copy_from']) @@ -5220,7 +6260,7 @@ def _get_text(name, shorten, text_key, axis_edit): p_obj.update({tk: p_text}) n_items = [] for item in self._meta['masks'][parent]['items']: - if name in item['source']: + if name == item['source'].split('@')[-1]: i_textobj = item['text'] for tk in text_key: if axis_edit: @@ -5318,7 +6358,7 @@ def set_value_texts(self, name, renamed_vals, text_key=None, axis_edit=None): if ignore: msg = 'Warning: Cannot set new value texts... ' msg = msg + "Codes {} not found in values object of '{}'!" - warnings.warn(msg) + warnings.warn(msg.format(ignore, name)) else: msg = '{} has empty values object, allowing arbitrary values meta!' msg = msg + ' ...falling back to extend_values() now!' @@ -5462,13 +6502,20 @@ def set_factors(self, name, factormap, safe=False): def get_property(self, name, prop_name, text_key=None): """ """ - mask_ref = self._meta['masks'] - col_ref = self._meta['columns'] - if not text_key: text_key = self.text_key valid_props = ['base_text', 'created', 'recoded_net', 'recoded_stat', - 'recoded_filter'] + 'recoded_filter', '_no_valid_items', '_no_valid_values', + 'simple_org_expr', 'level'] if prop_name not in valid_props: raise ValueError("'prop_name' must be one of {}".format(valid_props)) + return self._get_property(name, prop_name, text_key) + + @verify(variables={'name': 'both'}) + def _get_property(self, name, prop_name, text_key=None): + """ + """ + mask_ref = self._meta['masks'] + col_ref = self._meta['columns'] + if not text_key: text_key = self.text_key has_props = False if self.is_array(name): if 'properties' in mask_ref[name]: @@ -5490,6 +6537,7 @@ def get_property(self, name, prop_name, text_key=None): else: return None + @modify(to_list='name') @verify(variables={'name': 'both'}) def set_property(self, name, prop_name, prop_value, ignore_items=False): """ @@ -5514,22 +6562,30 @@ def set_property(self, name, prop_name, prop_value, ignore_items=False): ------- None """ - valid_props = ['base_text'] + valid_props = ['base_text', '_no_valid_items', '_no_valid_values'] if prop_name not in valid_props: raise ValueError("'prop_name' must be one of {}".format(valid_props)) + self._set_property(name, prop_name, prop_value, ignore_items) + return None + + @modify(to_list='name') + @verify(variables={'name': 'both'}) + def _set_property(self, name, prop_name, prop_value, ignore_items=False): + """ + Access and set the value of a meta object's ``properties`` collection. + + Note: This method allows the setting for any property, so it should only + be used by developers. + """ prop_update = {prop_name: prop_value} - if self.is_array(name): - if not 'properties' in self._meta['masks'][name]: - self._meta['masks'][name]['properties'] = {} - self._meta['masks'][name]['properties'].update(prop_update) - if not ignore_items: - items = self.sources(name) - for i in items: - self.set_property(i, prop_name, prop_value) - else: - if not 'properties' in self._meta['columns'][name]: - self._meta['columns'][name]['properties'] = {} - self._meta['columns'][name]['properties'].update(prop_update) + for n in name: + collection = 'masks' if self.is_array(n) else 'columns' + if not 'properties' in self._meta[collection][n]: + self._meta[collection][n]['properties'] = {} + self._meta[collection][n]['properties'].update(prop_update) + if ignore_items: continue + for s in self.sources(n): + self._set_property(s, prop_name, prop_value) return None @modify(to_list='name') @@ -5564,55 +6620,91 @@ def slicing(self, name, slicer, axis='y'): if 'rules' not in self._meta['columns'][n]: self._meta['columns'][n]['rules'] = {'x': {}, 'y': {}} if not isinstance(slicer, list): slicer = [slicer] - slicer = self._clean_codes_against_meta(n, slicer) - rule_update = {'slicex': {'values': slicer}} + sl = self._clean_codes_against_meta(n, slicer) + rule_update = {'slicex': {'values': sl}} for ax in axis: self._meta['columns'][n]['rules'][ax].update(rule_update) return None + def empty(self, name, condition=None): + """ + Check variables for emptiness (opt. restricted by a condition). + + Parameters + ---------- + name : (list of) str + The mask variable name keyed in ``_meta['columns']``. + condition : Quantipy logic expression, default None + A logical condition expressed as Quantipy logic that determines + which subset of the case data rows to be considered. + + Returns + ------- + empty : bool + """ + empty = [] + if not isinstance(name, list): name = [name] + return_bool = len(name) == 1 + if condition: + df = pd.DataFrame(self[self.take(condition), name]) + else: + df = self._data + for n in name: + if df[n].count() == 0: + empty.append(n) + if return_bool: + return bool(empty) + else: + return empty + + @modify(to_list='name') @verify(variables={'name': 'masks'}) def empty_items(self, name, condition=None, by_name=True): """ - Return items without any responses (opt. restricted by a condition). + Test arrays for item emptiness (opt. restricted by a condition). Parameters ---------- - name : str + name : (list of) str The mask variable name keyed in ``_meta['masks']``. - condition : Quantipy logic expression + condition : Quantipy logic expression, default None A logical condition expressed as Quantipy logic that determines which subset of the case data rows to be considered. - by_name : bool, default + by_name : bool, default True Return array items by their name or their index. Returns ------- - empty_items : list + empty : list The list of empty items by their source names or positional index - (starting from 1!). + (starting from 1!, mapped to their parent mask name if more than + one). """ + empty = {} if condition: - slicer = self.take(condition) - df = self[slicer, name].sum().copy() + df = self[self.take(condition), name].copy() else: - df = self[name].sum().copy() - slicer = df == 0 - empty_items = df.loc[slicer].index.values.tolist() - if by_name: - return empty_items + df = self._data.copy() + for n in name: + empty_items = [i for i in self.unroll(n) + if df[i].value_counts().sum() == 0] + if not by_name: empty_items = [self.item_no(i) for i in empty_items] + if empty_items: empty[n] = empty_items + if empty: + return empty[name[0]] if len(name) == 1 else empty else: - return [self.item_no(i) for i in empty_items] + return None - @modify(to_list='name') - @verify(variables={'name': 'masks'}) - def hide_empty_items(self, name, condition=None): + @verify(variables={'arrays': 'masks'}) + def hide_empty_items(self, condition=None, arrays=None): """ Apply ``rules`` meta to automatically hide empty array items. Parameters ---------- - name : (list of) str - The mask variable names keyed in ``_meta['masks']``. + name : (list of) str, default None + The array mask variable names keyed in ``_meta['masks']``. If not + explicitly provided will test all array mask definitions. condition : Quantipy logic expression A logical condition expressed as Quantipy logic that determines which subset of the case data rows to be considered. @@ -5621,20 +6713,73 @@ def hide_empty_items(self, name, condition=None): ------- None """ - for n in name: - empty_items = self.empty_items(n, condition, False) - if len(empty_items) == len(self.sources(n)): - w = "All items of array '{}' are hidden! Array summary will fail!" - warnings.warn(w.format(n)) - self.hiding(n, empty_items, axis='x', hide_values=False) + if not arrays: arrays = self.masks() + if arrays and not isinstance(arrays, list): arrays = [arrays] + empty_items = self.empty_items(arrays, condition, False) + if empty_items: + if isinstance(empty_items, list): + empty_items = {arrays[0]: empty_items} + for arr, items in empty_items.items(): + if len(items) == len(self.sources(arr)): + self.set_property(arr, '_no_valid_items', True, True) + self.hiding(arr, items, axis='x', hide_values=False) return None - @modify(to_list='name') - @verify(variables={'name': 'both'}) - def hide_empty_values(self, name, condition=None): + def fully_hidden_arrays(self): """ + Get all array definitions that contain only hidden items. + + Returns + ------- + hidden : list + The list of array mask names. """ - pass + hidden = [] + for m in self.masks(): + invalid = self.get_property(m, '_no_valid_items') + if invalid: hidden.append(m) + return hidden + + @modify(to_list='name') + @verify(variables={'name': 'columns'}, axis='axis') + def min_value_count(self, name, min=50, weight=None, condition=None, + axis='y', verbose=True): + """ + Wrapper for self.hiding(), which is hiding low value_counts. + + Parameters + ---------- + variables: str/ list of str + Name(s) of the variable(s) whose values are checked against the + defined border. + min: int + If the amount of counts for a value is below this number, the + value is hidden. + weight: str, default None + Name of the weight, which is used to calculate the weigthed counts. + condition: complex logic + The data, which is used to calculate the counts, can be filtered + by the included condition. + axis: {'y', 'x', ['x', 'y']}, default None + The axis on which the values are hidden. + """ + for v in name: + df = self.crosstab(v, w=weight, text=False, f=condition)[v]['@'][v] + hide = [] + for i, c in zip(df.index, df.values): + if c < min: + hide.append(i) + if hide: + codes = self.codes(v) + if verbose: + if 'All' in hide or all(c in hide for c in codes): + msg = '{}: All values have less counts than {}.' + print msg.format(v, min) + else: + print '{}: Hide values {}'.format(v, hide) + hide = [h for h in hide if not h == 'All'] + self.hiding(v, hide, axis) + return None @modify(to_list='name') @verify(variables={'name': 'both'}, axis='axis') @@ -5677,25 +6822,25 @@ def hiding(self, name, hide, axis='y', hide_values=True): for ax in axis: if collection == 'masks' and ax == 'x' and not hide_values: sources = self.sources(n) - hide = [sources[idx-1] + h = [sources[idx-1] for idx, s in enumerate(sources, start=1) if idx in hide] else: - hide = self._clean_codes_against_meta(n, hide) - if set(hide) == set(self._get_valuemap(n, 'codes')): + h = self._clean_codes_against_meta(n, hide) + if set(h) == set(self._get_valuemap(n, 'codes')): msg = "Cannot hide all values of '{}'' on '{}'-axis" raise ValueError(msg.format(n, ax)) if collection == 'masks' and ax == 'x' and hide_values: for s in self.sources(n): - self.hiding(s, hide, 'x') + self.hiding(s, h, 'x') else: - rule_update = {'dropx': {'values': hide}} + rule_update = {'dropx': {'values': h}} self._meta[collection][n]['rules'][ax].update(rule_update) return None - @modify(to_list='name') + @modify(to_list=['name', 'fix']) @verify(variables={'name': 'both'}) def sorting(self, name, on='@', within=False, between=False, fix=None, - ascending=False, sort_by_weight=None): + ascending=False, sort_by_weight='auto'): """ Set or update ``rules['x']['sortx']`` meta for the named column. @@ -5732,25 +6877,22 @@ def sorting(self, name, on='@', within=False, between=False, fix=None, if on == '@' and is_array: for source in self.sources(n): self.sorting(source, fix=fix, within=within, - between=between, ascending=ascending) + between=between, ascending=ascending, + sort_by_weight=sort_by_weight) else: if 'rules' not in self._meta[collection][n]: self._meta[collection][n]['rules'] = {'x': {}, 'y': {}} - if fix: - if not isinstance(fix, list): fix = [fix] - else: - fix = [] if not is_array: - fix = self._clean_codes_against_meta(n, fix) + n_fix = self._clean_codes_against_meta(n, fix) else: - fix = self._clean_items_against_meta(n, fix) - rule_update = {'sortx': {'ascending': ascending, - 'within': within, - 'between': between, - 'fixed': fix, - 'sort_on': on, - 'with_weight': sort_by_weight}} - self._meta[collection][n]['rules']['x'].update(rule_update) + n_fix = self._clean_items_against_meta(n, fix) + rule_update = {'ascending': ascending, + 'within': within, + 'between': between, + 'fixed': n_fix, + 'sort_on': on, + 'with_weight': sort_by_weight} + self._meta[collection][n]['rules']['x']['sortx'] = rule_update return None def _clean_missing_map(self, var, missing_map): @@ -5769,7 +6911,10 @@ def _clean_missing_map(self, var, missing_map): return valid_map def _set_default_missings(self, ignore=None): - excludes = ['weißnicht', 'keineangabe', 'weißnicht/keineangabe', + excludes = [ + u'weißnicht', + 'keineangabe', + u'weißnicht/keineangabe', 'keineangabe/weißnicht', 'kannmichnichterinnern', 'weißichnicht', 'nichtindeutschland'] d = self.describe() @@ -5792,7 +6937,8 @@ def _set_default_missings(self, ignore=None): return None @verify(variables={'var': 'both', 'ignore': 'both'}) - def set_missings(self, var, missing_map='default', ignore=None): + def set_missings(self, var, missing_map='default', hide_on_y=True, + ignore=None): """ Flag category definitions for exclusion in aggregations. @@ -5824,14 +6970,19 @@ def set_missings(self, var, missing_map='default', ignore=None): self._set_default_missings(ignore) else: if isinstance(missing_map, list): - missing_map = {'exclude': missing_map} + m_map = {'exclude': missing_map} + else: + m_map = org_copy.deepcopy(missing_map) for v in var: if v in ignore: continue - missing_map = self._clean_missing_map(v, missing_map) + v_m_map = self._clean_missing_map(v, m_map) if self._has_missings(v): - self._meta['columns'][v].update({'missings': missing_map}) + self._meta['columns'][v].update({'missings': v_m_map}) else: - self._meta['columns'][v]['missings'] = missing_map + self._meta['columns'][v]['missings'] = v_m_map + if hide_on_y: + self.hiding(var, missing_map, 'y', True) + return None # ------------------------------------------------------------------------ @@ -5872,8 +7023,9 @@ def _derotate_meta(self, mapper, other): """ meta = self._meta new_meta = self.start_meta(self.text_key) - new_meta['info']['name'] = '{}_derotate'.format(meta['info']['name']) - + n = meta['info'].get('dataset', meta['info']).get('name') + dname = '{}_derotate'.format(n) + new_meta['info']['dataset'] = {'name': dname} for var in other: new_meta = self._assume_meta(new_meta, var, var) @@ -6007,8 +7159,8 @@ def derotate(self, levels, mapper, other=None, unique_key='identity', ds._data = ds._data[cols] # save ``DataSet`` instance as json and csv - path_json = '{}/{}.json'.format(ds.path, ds.name) - path_csv = '{}/{}.csv'.format(ds.path, ds.name) + path_json = os.path.join(ds.path, ''.join([ds.name, '.json'])) + path_csv = os.path.join(ds.path, ''.join([ds.name, '.csv'])) ds.write_quantipy(path_json, path_csv) return ds @@ -6017,6 +7169,15 @@ def derotate(self, levels, mapper, other=None, unique_key='identity', # DATA MANIPULATION/HANDLING # ------------------------------------------------------------------------ + def _logic_as_pd_expr(self, logic, prefix='default'): + """ + """ + varname = '{}__logic_dummy__'.format(prefix).replace(' ', '_') + category = [(1, 'select', logic)] + meta = (varname, 'single', '', category) + self.derive(*meta) + return '{}==1'.format(varname) + def make_dummy(self, var, partitioned=False): if not self.is_array(var): vartype = self._get_type(var) @@ -6062,7 +7223,7 @@ def make_dummy(self, var, partitioned=False): codes.extend(self._data[i].dropna().unique().tolist()) codes = sorted(list(set(codes))) dummy_data = [] - if self._is_multicode_array(items[0]): + if any(self._is_multicode_array(i) for i in items): for i in items: try: i_dummy = self[i].str.get_dummies(';') @@ -6090,6 +7251,7 @@ def filter(self, alias, condition, inplace=False): Filter the DataSet using a Quantipy logical expression. """ data = self._data.copy() + data.index = pd.Index(range(0, len(data.index))) filter_idx, _ = get_logic_index(pd.Series(data.index), condition, data) filtered_data = data.iloc[filter_idx, :] if inplace: @@ -6174,9 +7336,13 @@ def get_batch(self, name): Name of existing Batch instance. """ batches = self._meta['sets'].get('batches', {}) - if not batches.get(name.decode('utf8')): + if batches.get(name.decode('utf8')): + b = name.decode('utf8') + elif batches.get(name): + b = name + else: raise KeyError('No Batch found named {}.'.format(name)) - return qp.Batch(self, name.decode('utf8')) + return qp.Batch(self, b) @modify(to_list='batches') def populate(self, batches='all', verbose=True): @@ -6193,27 +7359,33 @@ def populate(self, batches='all', verbose=True): ------- qp.Stack """ + dk = self.name meta = self._meta data = self._data stack = qp.Stack(name='aggregations', add_data={dk: (data, meta)}) batches = stack._check_batches(dk, batches) - for name in batches: - batch = self._meta['sets']['batches'][name] + batch = meta['sets']['batches'][name] xys = batch['x_y_map'] fs = batch['x_filter_map'] fy = batch['y_filter_map'] - f = batch['filter'] my = batch['yks'] - total_len = len(xys) + len(batch['y_on_y']) for idx, xy in enumerate(xys, start=1): x, y = xy if x == '@': - stack.add_link(dk, fs[y[0]], x='@', y=y) + if fs[y[0]] is None: + fi = 'no_filter' + else: + fi = {fs[y[0]]: {fs[y[0]]: 0}} + stack.add_link(dk, fi, x='@', y=y) else: - stack.add_link(dk, fs[x], x=x, y=y) + if fs[x] is None: + fi = 'no_filter' + else: + fi = {fs[x]: {fs[x]: 0}} + stack.add_link(dk, fi, x=x, y=y) if verbose: done = float(idx) / float(total_len) *100 print '\r', @@ -6221,7 +7393,11 @@ def populate(self, batches='all', verbose=True): print 'Batch [{}]: {} %'.format(name, round(done, 1)), sys.stdout.flush() for idx, y_on_y in enumerate(batch['y_on_y'], len(xys)+1): - stack.add_link(dk, fy[y_on_y], x=my[1:], y=my) + if fy[y_on_y] is None: + fi = 'no_filter' + else: + fi = {fy[y_on_y]: {fy[y_on_y]: 1}} + stack.add_link(dk, fi, x=my[1:], y=my) if verbose: done = float(idx) / float(total_len) *100 print '\r', @@ -6231,13 +7407,3 @@ def populate(self, batches='all', verbose=True): if verbose: print '\n' return stack - -# ============================================================================ - - def parrot(self): - from IPython.display import Image - from IPython.display import display - try: - return display(Image(url="https://m.popkey.co/3a9f4b/jZZ83.gif")) - except: - print ':sad_parrot: Looks like the parrot url is not longer there!' \ No newline at end of file diff --git a/quantipy/core/helpers/functions.py b/quantipy/core/helpers/functions.py index 51568813f..de3461661 100644 --- a/quantipy/core/helpers/functions.py +++ b/quantipy/core/helpers/functions.py @@ -2569,3 +2569,13 @@ def filtered_set(meta, based_on, masks=True, included=None, excluded=None, def cpickle_copy(obj): copy = cPickle.loads(cPickle.dumps(obj, cPickle.HIGHEST_PROTOCOL)) return copy + +def parrot(): + from IPython.display import Image + from IPython.display import display + import os + filename = os.path.dirname(__file__) + '\\parrot.gif' + try: + return display(Image(filename=filename, format='png')) + except: + print ':sad_parrot: Looks like the parrot is not available!' \ No newline at end of file diff --git a/quantipy/core/helpers/parrot.gif b/quantipy/core/helpers/parrot.gif new file mode 100644 index 000000000..458ad859d Binary files /dev/null and b/quantipy/core/helpers/parrot.gif differ diff --git a/quantipy/core/quantify/engine.py b/quantipy/core/quantify/engine.py index 5477ade34..a2769f1e2 100644 --- a/quantipy/core/quantify/engine.py +++ b/quantipy/core/quantify/engine.py @@ -64,6 +64,10 @@ def __init__(self, link, weight=None, base_all=False, ignore_flags=False): self.type = self._get_type() if self.type == 'nested': self.nest_def = Nest(self.y, self.d(), self.meta()).nest() + if not self.x == '@': + self.leveled = self.ds.get_property(self.x, 'level') + else: + self.leveled = False self._squeezed = False self.idx_map = None self.xdef = self.ydef = None @@ -221,7 +225,7 @@ def swap(self, var, axis='x', update_axis_def=True, inplace=True): org_sources = self.ds.sources(org_parent) else: org_sources = self.ds.sources(self.x) - if not len(org_sources) == len(new_sources): + if not len(org_sources) == len(new_sources) and array_swap: err = "Cannot swap array-type Quantity with array of different " err += "source items length ({} vs. {})!" err = err.format(len(org_sources), len(new_sources)) @@ -250,6 +254,8 @@ def swap(self, var, axis='x', update_axis_def=True, inplace=True): swapped.x, swapped.y = x, y swapped.f, swapped.w = f, w swapped.type = swapped._get_type() + if swapped.type == 'nested': + swapped.nest_def = Nest(swapped.y, swapped.d(), swapped.meta()).nest() swapped._get_matrix() if not update_axis_def and array_swap: swapped.x = org_name @@ -958,7 +964,8 @@ def _empty_result(self): elif self.ydef is not None and len(self.ydef) == 0: ydim = 2 else: - ydim = len(self.ydef) + 1 + ydim = len(self.ydef) + if not self.type == 'array': ydim += 1 else: if self.xdef is not None: if len(self.xdef) == 0: @@ -1535,25 +1542,57 @@ def _make_nest_multiindex(self): mi = pd.MultiIndex.from_product(values, names=names) return mi - def normalize(self, on='y'): + def _get_other_base(self, other): + """ + """ + swapped = self.swap(other, inplace=False) + return swapped.count().cbase + + def _normalize_on_cells(self, other): + """ + """ + is_df = self._force_to_nparray() + other_q = self.swap(other, update_axis_def=False, inplace=False) + other_len = len(other_q.xdef) + q_len = len(self.xdef) + if not other_len == q_len: + err = "Cannot normalize on '{}', shapes do not match! ({} vs. {})" + raise ValueError(err.format(other, q_len, other_len)) + has_margin = self._attach_margins() + counts = other_q.count(as_df=False, margin=has_margin).result + self._organize_margins(has_margin) + self.result = (self.result / counts) * 100 + if is_df: self.to_df() + return None + + def normalize(self, on='y', per_cell=False): """ Convert a raw cell count result to its percentage representation. Parameters ---------- - on : {'y', 'x'}, default 'y' + on : {'y', 'x', 'counts_sum', str}, default 'y' Defines the base to normalize the result on. ``'y'`` will - produce column percentages, ``'x'`` will produce row - percentages. + produce column percentages, ``'x'`` will produce row percentages. + It is also possible to use another question's frequencies to + compute rebased percentages providing its name instead. + per_cell : bool, default False + Compute percentages on a cell-per-cell basis, effectively treating + each categorical row as a base figure on its own. Only possible if the + ``on`` argument does not indidcate an axis result (``'x'``, ``'y'``, + ``'counts_sum'``), but instead another variable's name. The related + ``xdef`` codes collection length must be identical for this for work, + otherwise a ``ValueError`` is raised. Returns ------- self - Updates an count-based aggregation in the ``result`` property. + Updates a count-based aggregation in the ``result`` property. """ - if on not in ['x', 'y', 'counts_sum']: - raise ValueError("'on' must be one of 'x', 'y' or 'counts_sum'.") - elif on == 'counts_sum' and (self.comb_x or self.comb_y): + rebase = on not in ['x', 'y', 'counts_sum'] + other_counts = rebase and per_cell + other_base = rebase and not per_cell + if on == 'counts_sum' and (self.comb_x or self.comb_y): raise ValueError("Groups cannot be normalized on 'counts_sum'") if on == 'counts_sum': is_df = self._force_to_nparray() @@ -1566,16 +1605,23 @@ def normalize(self, on='y'): self.result = self.result / base * 100 self._organize_margins(has_margin) if is_df: self.to_df() + elif other_counts: + self._normalize_on_cells(on) else: if self.x == '@': on = 'y' if on == 'x' else 'x' - if on == 'y': + if on == 'y' or other_base: if self._has_y_margin or self.y == '@' or self.x == '@': - base = self.cbase + if not other_base: + base = self.cbase + else: + base = self._get_other_base(on) else: - if self._get_type() == 'array': + if not other_base: base = self.cbase else: - base = self.cbase[:, 1:] + base = self._get_other_base(on) + if self._get_type() != 'array': + base = base[:, 1:] elif on == 'x': if self._has_x_margin: base = self.rbase @@ -1584,7 +1630,7 @@ def normalize(self, on='y'): if isinstance(self.result, pd.DataFrame): if self.x == '@': self.result = self.result.T - if on == 'y': + if on == 'y' or other_base: base = np.repeat(base, self.result.shape[0], axis=0) else: base = np.repeat(base, self.result.shape[1], axis=1) @@ -1593,40 +1639,6 @@ def normalize(self, on='y'): self.result = self.result.T return self - def rebase(self, reference, on='counts', overwrite_margins=True): - """ - """ - val_err = 'No frequency aggregation to rebase.' - if self.result is None: - raise ValueError(val_err) - elif self.current_agg != 'freq': - raise ValueError(val_err) - is_df = self._force_to_nparray() - has_margin = self._attach_margins() - ref = self.swap(var=reference, inplace=False) - if self._sects_identical(self.xdef, ref.xdef): - pass - elif self._sects_different_order(self.xdef, ref.xdef): - ref.xdef = self.xdef - ref._x_indexers = ref._get_x_indexers() - ref.matrix = ref.matrix[:, ref._x_indexers + [0]] - elif self._sect_is_subset(self.xdef, ref.xdef): - ref.xdef = [code for code in ref.xdef if code in self.xdef] - ref._x_indexers = ref._sort_indexer_as_codes(ref._x_indexers, - self.xdef) - ref.matrix = ref.matrix[:, [0] + ref._x_indexers] - else: - idx_err = 'Axis defintion is not a subset of rebase reference.' - raise IndexError(idx_err) - ref_freq = ref.count(as_df=False) - self.result = (self.result/ref_freq.result) * 100 - if overwrite_margins: - self.rbase = ref_freq.rbase - self.cbase = ref_freq.cbase - self._organize_margins(has_margin) - if is_df: self.to_df() - return self - @staticmethod def _sects_identical(axdef1, axdef2): return axdef1 == axdef2 @@ -1677,6 +1689,7 @@ def __init__(self, link, view_name_notation, test_total=False): self.Quantity.swap(var=view.has_other_source()) cond = {orgx: not_count(0)} self.Quantity.filter(cond, keep_base=False, inplace=True) + self.rebased = view._kwargs.get('rebased', False) self._set_baseline_aggregates(view) # Set information about the incoming aggregation # to be able to route correctly through the algorithms @@ -1743,7 +1756,7 @@ def _set_baseline_aggregates(self, view): self.values = self.values[:, 1:] self.cbases = self.cbases[:, 1:] elif self.metric == 'proportions': - if not self.test_total: + if not self.test_total or self.rebased: if view.is_cumulative(): agg = self.Quantity.count( margin=False, as_df=False, cum_sum=False) @@ -1829,6 +1842,9 @@ def set_params(self, test_total=False, level='mid', mimic='Dim', testtype='poole self.no_diffs = True if self.y == '@': self.no_pairs = True + if self.rebased: + self.invalid = True + self.no_pairs = True if self.invalid: self.mimic = mimic self.comparevalue, self.level = self._convert_level(level) @@ -2242,6 +2258,8 @@ def _empty_output(self): values = [np.NaN] if self.no_diffs and not self.no_pairs: values[:] = np.NaN + if self.test_total and not self.no_pairs: + values = values[:, 1:] return pd.DataFrame(values, index=self.multiindex[0], columns=self.multiindex[1]) @@ -2335,3 +2353,75 @@ def _interlock_texts(self): interlocked_valtexts = list(product(*all_valtexts)) interlocked_qtexts = list(product(*all_qtexts)) return interlocked_qtexts, interlocked_valtexts + +class Level(object): + """ + """ + def __init__(self, quantity): + """ + """ + self.quantity = quantity + self.dataset = self.quantity.ds + self._lvlspec = self.dataset.get_property(self.quantity.x, 'level') + self.array = self._lvlspec['source'] + self.level_codes = self._lvlspec['level_codes'] + self.item_look = self._lvlspec['item_look'] + self._auxdf = self.quantity.count(margin=False).result.reset_index() + self._collapse_codes() + self.lvldf = None + + def _reindex(self, like='freq'): + ds = self.dataset + like_item = self.item_look + itemres = self.quantity.swap(like_item, axis='x', inplace=False) + if like == 'freq': + itemres.count(margin=False, axis=None, as_df=True) + self.lvldf = self.lvldf.reindex(ds.codes(like_item)) + elif like == 'base': + itemres.count(margin=False, axis='x', as_df=True) + x = [self.quantity.x] + vals = itemres.result.index.get_level_values(1).tolist() + idx = pd.MultiIndex.from_product([x, vals], + names=['Question', 'Values']) + self.lvldf.index = idx + None + + def _collapse_codes(self): + df = self._auxdf + for org, lvls in self.level_codes.items(): + for lvl in lvls: + df['Values'] = df['Values'].replace( + lvl, int(org), inplace=False) + return None + + def count(self): + """ + """ + df = self._auxdf.set_index(['Question', 'Values']) + self.lvldf = df.sum(level=1, axis=0) + self._reindex() + return None + + def base(self): + """ + """ + df = self._auxdf.set_index(['Question', 'Values']) + self.lvldf = df.sum(level=0, axis=0) + self._reindex(like='base') + return None + + def percent(self): + """ + """ + self.count() + c = self.lvldf + self.base() + b = self.lvldf + pcts = c.values / b.values * 100 + self.lvldf = pd.DataFrame(pcts, index=c.index, columns=c.columns) + return None + + def as_view(self): + """ + """ + pass \ No newline at end of file diff --git a/quantipy/core/rules.py b/quantipy/core/rules.py index de6cbe014..1a64433ea 100644 --- a/quantipy/core/rules.py +++ b/quantipy/core/rules.py @@ -4,46 +4,119 @@ import copy import quantipy as qp import numpy as np +import warnings class Rules(object): - def __init__(self, link, view_name, axes=['x', 'y']): + # ------------------------------------------------------------------------ + # init + # ------------------------------------------------------------------------ + def __init__(self, link, view_name, axes=['x', 'y'], rweight=None): self.link = link self.view_name = view_name - self.view_df = link[view_name].dataframe self.stack_base = link.stack[link.data_key] self.link_base = self.stack_base[link.filter] - self.link_weight = view_name.split('|')[-2] self.meta = self.stack_base.meta self.array_summary = self._is_array_summary() self.transposed_summary = self._is_transposed_summary() + if self.transposed_summary: + self.view_df = link[view_name].dataframe.T + self.array_summary = True + else: + self.view_df = link[view_name].dataframe self._xrule_col = None - self._xrule_col = None - self._sort_x_w = None - self._sort_y_w = None + self._yrule_col = None + self._sort_weight = self._get_sort_weight(rweight) self.x_rules = self._set_rules_params(axes, 'x') self.y_rules = self._set_rules_params(axes, 'y') self.x_slicer = None self.y_slicer = None self.rules_view_df = None + def _is_array_summary(self): + return self.link.x in self.meta['masks'] + def _is_transposed_summary(self): + return self.link.x == '@' and self.link.y in self.meta['masks'] + + def _set_rules_params(self, all_rules_axes, rules_axis): + if rules_axis == 'x' and 'x' not in all_rules_axes: + return None + elif rules_axis == 'y' and 'y' not in all_rules_axes: + return None + k, f, x, y = self.link.data_key, self.link.filter, self.link.x, self.link.y + if self.transposed_summary: + x, y = y, x + rules = None + if rules_axis == 'x': + if not self.array_summary: + try: + rules = self.meta['columns'][x]['rules']['x'] + self._xrule_col = x + except: + pass + else: + try: + rules = self.meta['masks'][x]['rules']['x'] + self._xrule_col = x + except: + pass + elif rules_axis == 'y': + if not self.array_summary: + try: + rules = self.meta['columns'][y]['rules']['y'] + self._yrule_col = y + except: + pass + else: + try: + rules = self.meta['masks'][x]['rules']['y'] + self._yrule_col = x + except: + pass + return rules + + def _get_sort_weight(self, use_weight): + var = self.link.y if self.link.x=='@' else self.link.x + try: + collection = self.meta['columns'][var] + except: + collection = self.meta['masks'][var] + rules = collection.get('rules', {}).get('x', {}) + if 'sortx' in rules: + sort_on = rules['sortx'].get('sort_on', '@') + sort_weight = rules['sortx']['with_weight'] or '' + if sort_weight == 'auto': + if use_weight is None: + sort_weight = self.view_name.split('|')[-2] + else: + sort_weight = use_weight + return sort_weight + else: + return None + + # ------------------------------------------------------------------------ + # display + # ------------------------------------------------------------------------ def rules_df(self): - return self.rules_view_df + if self.transposed_summary: + return self.rules_view_df.T + else: + return self.rules_view_df def show_rules(self, axis=None): """ """ if not axis: - return {'X': self.x_rules}, {'y': self.y_rules} + return {'x': self.x_rules}, {'y': self.y_rules} elif axis == 'x': return {'x': self.x_rules} elif axis == 'y': return {'y': self.y_rules} else: err = "If provided, 'axis' must be one of {'x', 'y'}" - raise valueError(err) + raise ValueError(err) def show_slicers(self, axis=None): if not axis: @@ -56,268 +129,196 @@ def show_slicers(self, axis=None): err = "If provided, 'axis' must be one of {'x', 'y'}" raise valueError(err) + # ------------------------------------------------------------------------ + # apply rules + # ------------------------------------------------------------------------ + def apply(self): self.get_slicer() + viable_axes = self.rule_viable_axes() if not viable_axes: df = self.view_df else: df = self.view_df.copy() + if 'x' in viable_axes and not self.x_slicer is None: rule_codes = set(self.x_slicer) view_codes = set(df.index.tolist()) if not rule_codes - view_codes: df = df.loc[self.x_slicer] - if 'x' in viable_axes and self.transposed_summary and self.y_slicer: - df = df.loc[self.rules_y_slicer] - if 'y' in viable_axes and not self.y_slicer is None: df = df[self.y_slicer] if self.view_name.split('|')[1].startswith('t.'): df = self.verify_test_results(df) self.rules_view_df = df - - def _find_expanded_net_groups(self, exp_net_view): - groups = OrderedDict() - view = exp_net_view - logic = view._kwargs.get('logic') - description = view.describe_block() - groups['codes'] = [c for c, d in description.items() if d == 'normal'] - net_names = [v for v, d in description.items() if d == 'net'] - for l in logic: - new_l = copy.deepcopy(l) - for k in l: - if k not in net_names: - del new_l[k] - groups[new_l.keys()[0]] = new_l.values()[0] - groups['codes'] = [c for c, d in description.items() if d == 'normal'] - return groups - - def _find_expanded_nets(self, all_views, rule_axis): - w = self.link_weight - expanded_net = [v for v in all_views if '}+]' in v - and v.split('|')[-2] == w - and v.split('|')[1] == 'f' and - not v.split('|')[3] == 'x'] - if expanded_net: - if len(expanded_net) > 1: - if len(expanded_net) == 2: - if expanded_net[0].split('|')[2] == expanded_net[1].split('|')[2]: - expanded_net = expanded_net[0] - else: - msg = ("Multiple 'expand' using views found for '{}'. " - "Unable to sort!") - raise RuntimeError(msg.format(col_key)) - else: - expanded_net = expanded_net[0] - - cond_expand = expanded_net.split('|')[2] - cond_view = self.view_name.split('|')[2] - if not cond_expand == cond_view or rule_axis == self.y_rules: - expanded_net = [] - - return expanded_net + return None def get_slicer(self): """ """ for axis, rule_axis in enumerate([self.x_rules, self.y_rules]): if not rule_axis: continue - if axis == 0: - col_key = self._xrule_col - elif axis == 1: - col_key = self._yrule_col - rules_slicer = None - views = self.link_base[col_key]['@'].keys() - w = self.link_weight - # weight = self.rules_weight + # get all views of the link, depending on axis + col_key = self._xrule_col if axis == 0 else self._yrule_col + views = self.link_base[col_key]['@'].keys() - expanded_net = self._find_expanded_nets(views, rule_axis) + # get df (-slice) to apply rule on if 'sortx' in rule_axis: - on_mean = rule_axis['sortx'].get('sort_on', '@') == 'mean' - else: - on_mean = False - if 'sortx' in rule_axis and on_mean: - f = self._get_descriptive_via_stack(col_key) - elif 'sortx' in rule_axis and expanded_net: - within = rule_axis['sortx'].get('within', False) - between = rule_axis['sortx'].get('between', False) - fix = rule_axis['sortx'].get('fixed', False) - ascending = rule_axis['sortx'].get('ascending', False) - view = self.link_base[col_key]['@'][expanded_net] - f = self.sort_expanded_nets(view, between=between, within=within, - ascending=ascending, fix=fix) - else: - - f = self._get_frequency_via_stack(col_key, axis) - - if axis == 0 and self.array_summary: - slice_array_items = True + sort_on = rule_axis['sortx'].get('sort_on', '@') + + sort_on_stat = False + sort_on_net = False + + if isinstance(sort_on, (str, unicode)): + sort_on_stat = sort_on in [ + 'median', 'stddev', 'sem', 'max', 'min', 'mean', + 'upper_q', 'lower_q'] + sort_on_net = sort_on.startswith('net') + + expanded_net = self._find_expanded_nets(views, rule_axis) + + # sort expanded nets + if expanded_net and not self.array_summary: + if not sort_on == '@': + msg = 'Cannot sort expanded nets on {}.' + raise AttributeError(msg .format(sort_on)) + view = self.link_base[col_key]['@'][expanded_net] + f = self.sort_expanded_nets(view, rule_axis['sortx']) + r_slicer = self._get_rules_slicer(f, rule_axis, + ['slicex', 'dropx']) + if axis == 0: + self.x_slicer = r_slicer + else: + self.y_slicer = r_slicer + return None + # get df-desc-slice to sort on + elif sort_on_stat: + f = self._get_descriptive_via_stack(col_key, sort_on) + # get df-net-slice to sort on + elif sort_on_net: + f = self._get_net_via_stack(col_key, sort_on) + # get df-freq-slice to sort on + else: + f = self._get_frequency_via_stack(col_key, axis, self._sort_weight) + # get df for hiding + slicing else: - slice_array_items = False + f = self._get_frequency_via_stack(col_key, axis, None) - if self.transposed_summary or (not slice_array_items and self.array_summary): - rules_slicer = self._get_rules_slicer(f.T, rule_axis) - else: - if not expanded_net or ('sortx' in rule_axis and on_mean): - rules_slicer = self._get_rules_slicer(f, rule_axis) - else: - rules_slicer = f.index.values.tolist() - try: - rules_slicer.remove((col_key, 'All')) - except: - pass + # get rules slicer + f = f.T if self.array_summary and axis == 1 else f + r_slicer = self._get_rules_slicer(f, rule_axis) if axis == 0: - self.x_slicer = rules_slicer + self.x_slicer = r_slicer else: - self.y_slicer = rules_slicer + self.y_slicer = r_slicer return None - - def _set_rules_params(self, all_rules_axes, rules_axis): - if rules_axis == 'x' and 'x' not in all_rules_axes: - return None - elif rules_axis == 'y' and 'y' not in all_rules_axes: - return None - k, f, x, y = self.link.data_key, self.link.filter, self.link.x, self.link.y - - rules = None - if rules_axis == 'x': - if not self.array_summary and not self.transposed_summary: - xcol = x - ycol = None - try: - rules = self.meta['columns'][x]['rules']['x'] - self._xrule_col = x - except: - pass - elif self.array_summary: - xcol = x - ycol = '@' - try: - rules = self.meta['masks'][x]['rules']['x'] - self._xrule_col = x - except: - pass - elif self.transposed_summary: - xcol = '@' - ycol = y - try: - rules = self.meta['masks'][y]['rules']['x'] - self._xrule_col = y - except: - pass - if rules and 'sortx' in rules and 'with_weight' in rules['sortx']: - self._sort_x_w = rules['sortx']['with_weight'] - elif rules_axis == 'y': - if not self.array_summary and not self.transposed_summary: - xcol = None - ycol = x - try: - rules = self.meta['columns'][y]['rules']['y'] - self._yrule_col = y - except: - pass - elif self.array_summary: - xcol = x - ycol = '@' - try: - rules = self.meta['masks'][x]['rules']['y'] - self._yrule_col = x - except: - pass - elif self.transposed_summary: - xcol = '@' - ycol = y - try: - rules = self.meta['masks'][y]['rules']['x'] - self._yrule_col = y - except: - pass - if rules and 'sortx' in rules and 'with_weight' in rules['sortx']: - self._sort_y_w = rules['sortx']['with_weight'] - return rules - - def _is_array_summary(self): - return self.link.x in self.meta['masks'] - - def _is_transposed_summary(self): - return self.link.x == '@' and self.link.y in self.meta['masks'] - - def _get_frequency_via_stack(self, col, axis): - weight_notation = self.link_weight - vk = 'x|f|:||{}|counts'.format(weight_notation) + def _get_frequency_via_stack(self, col, axis, weight): + if weight is None: + vk = 'x|f|:|||counts' + else: + vk = 'x|f|:||{}|counts'.format(weight) + view_weight = self.view_name.split('|')[-2] + link_weights = [k.split('|')[-2] for k in self.link.keys() + if not 'base' in k.split('|')[-1]] + if not (weight == view_weight or weight in link_weights): + msg = "\n{}: view-weight and weight to sort on differ ('{}' vs '{}')\n" + warnings.warn(msg.format(col, view_weight, weight or None)) try: - f = self.link_base[col]['@'][vk].dataframe - except (KeyError, AttributeError) as e: - try: + if self.transposed_summary: f = self.link_base['@'][col][vk].dataframe.T - except (KeyError, AttributeError) as e: - freq = qp.core.tools.dp.prep.frequency - if axis == 0 and self._sort_x_w: - agg_w = self._sort_x_w - elif axis == 1 and self._sort_y_w: - agg_w = self._sort_y_w - else: - agg_w = self.link_weight if not self.link_weight == '' else None - f = freq(self.stack_base.meta, self.stack_base.data, - x=col, weight=agg_w) + else: + f = self.link_base[col]['@'][vk].dataframe + except (KeyError, AttributeError) as e: + freq = qp.core.tools.dp.prep.frequency + f = freq(self.stack_base.meta, self.stack_base.data, x=col, + weight=weight or None) return f - def _get_descriptive_via_stack(self, col): + def _get_descriptive_via_stack(self, col, desc='mean'): l = self.link_base[col]['@'] - w = self.link_weight - mean_key = [k for k in l.keys() if 'd.mean' in k.split('|')[1] and - k.split('|')[-2] == w] - if not mean_key: - msg = "No mean view to sort '{}' on found!" - raise RuntimeError(msg.format(col)) - elif len(mean_key) > 1: - msg = "Multiple mean views found for '{}'. Unable to sort!" + w = self._sort_weight + desc_key = [k for k in l.keys() if 'd.{}'.format(desc) in k.split('|')[1] + and k.split('|')[-2] == w] + if not desc_key: + msg = "No {} view to sort '{}' on found!" + raise RuntimeError(msg.format(desc, col)) + elif len(desc_key) > 1: + msg = "Multiple {} views found for '{}'. Unable to sort!" + raise RuntimeError(msg.format(desc, col)) + else: + desc_key = desc_key[0] + d = l[desc_key].dataframe + return d + + def _get_net_via_stack(self, col, net='net_1'): + l = self.link_base[col]['@'] + w = self._sort_weight + net_no = int(net.split('_')[-1]) + net_key = [k for k in l.keys() if k.split('|')[-1] == 'net' + and len(k.split('|')[2].split(',x')) >= net_no + and k.split('|')[-2] == w] + if not net_key: + msg = "No net view to sort '{}' on found!" raise RuntimeError(msg.format(col)) else: - mean_key = mean_key[0] - vk = mean_key - d = l[mean_key].dataframe + net_key = net_key[0] + d = l[net_key].dataframe return d - def _get_rules_slicer(self, f, rules, copy=True): + def _get_rules_slicer(self, f, rules, apply_rules=None): + f = f.copy() + rulesx = OrderedDict([ + ('slicex', self.slicex), + ('sortx', self.sortx), + ('dropx', self.dropx)]) + + if not apply_rules: apply_rules = rulesx.keys() + for r, method in rulesx.items(): + if apply_rules and r in apply_rules: + if r in rules: + f = method(f, **rules[r]) + rules_slicer = f.index.values.tolist() + col_key = f.index.levels[0].tolist()[0] + if (col_key, 'All') in rules_slicer: + rules_slicer.remove((col_key, 'All')) + + return rules_slicer - if copy: - f = f.copy() + def _find_expanded_nets(self, all_views, rule_axis): + expanded_net = [v for v in all_views if '}+]' in v + and v.split('|')[-2] == self._sort_weight + and v.split('|')[1] == 'f' and + not v.split('|')[3] == 'x'] - if 'slicex' in rules: - kwargs = rules['slicex'] - values = kwargs.get('values', None) - # if not values is None: - # kwargs['values'] = [val for val in values] - f = self.slicex(f, **kwargs) + return expanded_net[0] if expanded_net else None - if 'sortx' in rules: - kwargs = rules['sortx'] - fixed = kwargs.get('fixed', None) - sort_on = kwargs.get('sort_on', '@') - # if not fixed is None: - # kwargs['fixed'] = [fix for fix in fixed] - f = self.sortx(f, **kwargs) - - if 'dropx' in rules: - kwargs = rules['dropx'] - values = kwargs.get('values', None) - # if not values is None: - # kwargs['values'] = [v for v in values] - f = self.dropx(f, **kwargs) - - return f.index.values.tolist() - - def sort_expanded_nets(self, view, within=True, between=True, ascending=False, - fix=None): - if not within and not between: - return view.dataframe - df = view.dataframe + def _find_expanded_net_groups(self, exp_net_view): + groups = OrderedDict() + view = exp_net_view + logic = view._kwargs.get('logic') + description = view.describe_block() + groups['codes'] = [c for c, d in description.items() if d == 'normal'] + net_names = [v for v, d in description.items() if d == 'net'] + for l in logic: + new_l = copy.deepcopy(l) + for k in l: + if k not in net_names: + del new_l[k] + groups[new_l.keys()[0]] = new_l.values()[0] + groups['codes'] = [c for c, d in description.items() if d == 'normal'] + return groups + def sort_expanded_nets(self, view, sortx): + within = sortx.get('within', True) + between = sortx.get('between', True) + ascending = sortx.get('ascending', False) + fix = sortx.get('fixed', None) + if not within and not between: return view.dataframe + df = view.dataframe name = df.index.levels[0][0] sort_col = (df.columns.levels[0][0], '@') # get valid fixed codes @@ -356,7 +357,8 @@ def sort_expanded_nets(self, view, within=True, between=True, ascending=False, is_code = len(g) == 1 if not is_code: fixed_net_name = g[0] - sort = [(name, v) for v in g[1:]] + fixed_in_g = [v for v in g[1:] if v in fix_codes] + sort = [(name, v) for v in g[1:] if not v in fixed_in_g] if within: if pd.__version__ == '0.19.2': temp_df = df.loc[sort].sort_values(sort_col, 0, ascending=ascending) @@ -364,8 +366,9 @@ def sort_expanded_nets(self, view, within=True, between=True, ascending=False, temp_df = df.loc[sort].sort_index(0, sort_col, ascending=ascending) else: temp_df = df.loc[sort] - new_idx = [fixed_net_name] + temp_df.index.get_level_values(1).tolist() + new_idx = [fixed_net_name] + temp_df.index.get_level_values(1).tolist() + fixed_in_g final_index.extend(new_idx) + fix_codes = [c for c in fix_codes if not c in fixed_in_g] else: final_index.extend(g) # build final index including any fixed codes @@ -448,15 +451,17 @@ def sortx(self, df, sort_on='@', within=True, between=True, ascending=False, if fixed is None: s_fixed = [] else: - s_fixed = [(name_x, value) for value in fixed] + s_fixed = [(name_x, value) for value in fixed + if (name_x, value) in s_sort] # Drop fixed tuples from the sort slicer s_sort = [t for t in s_sort if not t in s_fixed] # Get sorted slicer - if (name_y, sort_on) in df.columns: - sort_col = (name_y, sort_on) - elif (name_y, str(sort_on)) in df.columns: - sort_col = (name_y, str(sort_on)) + try: + sort_on = int(sort_on) + except: + sort_on = str(sort_on) + sort_col = (name_y, sort_on) if pd.__version__ == '0.19.2': df_sorted = df.loc[s_sort].sort_values(sort_col, 0, ascending) else: @@ -530,21 +535,14 @@ def dropx(self, df, values): return df name_x = df.index.levels[0][0] - slicer = [(name_x, value) for value in values] + slicer = [(name_x, value) for value in values + if (name_x, value) in df.index] - if not all([s in df.index for s in slicer]): - raise KeyError ( - "Some of of the values from the list %s cannot be dropped" - " from the dataframe because they were not found in %s." - " Be careful that you are not both slicing and/or sorting" - " any values that you are also trying to drop." % ( - values, - df.index.tolist() - ) - ) - df = df.drop(slicer) + if slicer: + df = df.drop(slicer) return df + # ------------------------------------------------------------------------ def rule_viable_axes(self): viable_axes = ['x', 'y'] @@ -552,10 +550,12 @@ def rule_viable_axes(self): condensed_y = False meta = self.meta - x, y = self.link.x, self.link.y + if self.transposed_summary: + y, x = self.link.x, self.link.y + else: + x, y = self.link.x, self.link.y vk = self.view_name array_summary = (x in meta['masks'] and y == '@') - transposed_summary = (y in meta['masks'] and x == '@') v_method = vk.split('|')[1] relation = vk.split('|')[2] s_name = vk.split('|')[-1] @@ -563,10 +563,6 @@ def rule_viable_axes(self): exp_net = '}+]' in relation array_sum_freqs = array_summary and s_name in ['counts', 'c%', 'r%'] - - if transposed_summary: - x, y = y, x - if (relation.split(":")[0].startswith('x') and not exp_net) or descriptive: if not array_summary: condensed_x = True @@ -626,7 +622,8 @@ def verify_test_value(value): if len(value)==1: value = set(value) else: - value = set([int(i) for i in list(value[1:-1].split(','))]) + value = set([int(i) if i.isdigit() else i + for i in list(value[1:-1].split(', '))]) value = cols.intersection(value) if not value: value = '' diff --git a/quantipy/core/stack.py b/quantipy/core/stack.py index bf2db3e78..7ebed7301 100644 --- a/quantipy/core/stack.py +++ b/quantipy/core/stack.py @@ -1,2673 +1,2808 @@ - -#-*- coding: utf-8 -*- -import io -import itertools -import json -import pandas as pd -import numpy as np -import quantipy as qp -import copy -import time -import sys - -from link import Link -from chain import Chain -from view import View -from helpers import functions -from view_generators.view_mapper import ViewMapper -from view_generators.view_maps import QuantipyViews -from quantipy.core.tools.qp_decorators import modify -from quantipy.core.tools.dp.spss.reader import parse_sav_file -from quantipy.core.tools.dp.io import unicoder, write_quantipy -from quantipy.core.tools.dp.prep import frequency, verify_test_results, frange -from quantipy.core.tools.view.logic import ( - has_any, has_all, has_count, - not_any, not_all, not_count, - is_lt, is_ne, is_gt, - is_le, is_eq, is_ge, - union, intersection, get_logic_index) -from cache import Cache - -import itertools -from collections import defaultdict, OrderedDict - -# Pickle modules -import cPickle - -# Compression methods -import gzip - -from quantipy.sandbox.sandbox import Chain as NewChain -from quantipy.sandbox.sandbox import ChainManager - - -class Stack(defaultdict): - """ - Container of quantipy.Link objects holding View objects. - - A Stack is nested dictionary that structures the data and variable - relationships storing all View aggregations performed. - """ - - def __init__(self, - name="", - add_data=None): - - super(Stack, self).__init__(Stack) - - self.name = name - self.key = None - self.parent = None - - # This is the root of the stack - # It is used by the get/set methods to determine - # WHERE in the stack those methods are. - self.stack_pos = "stack_root" - - self.x_variables = None - self.y_variables = None - - self.__view_keys = [] - - if add_data: - for key in add_data: - if isinstance(add_data[key], dict): - self.add_data( - data_key=key, - data=add_data[key].get('data', None), - meta=add_data[key].get('meta', None) - ) - elif isinstance(add_data[key], tuple): - self.add_data( - data_key=key, - data=add_data[key][0], - meta=add_data[key][1] - ) - else: - raise TypeError( - "All data_key values must be one of the following types: " - "<dict> or <tuple>. " - "Given: %s" % (type(add_data[key])) - ) - - def __setstate__(self, attr_dict): - self.__dict__.update(attr_dict) - - def __reduce__(self): - arguments = (self.name, ) - state = self.__dict__.copy() - if 'cache' in state: - state.pop('cache') - state['cache'] = Cache() # Empty the cache for storage - return self.__class__, arguments, state, None, self.iteritems() - - def __setitem__(self, key, val): - """ The 'set' method for the Stack(dict) - - It 'sets' the value in it's correct place in the Stack - AND applies a 'stack_pos' value depending on WHERE in - the stack the value is being placed. - """ - super(Stack, self).__setitem__(key, val) - - # The 'meta' portion of the stack is a standar dict (not Stack) - try: - if isinstance(val, Stack) and val.stack_pos is "stack_root": - val.parent = self - val.key = key - - # This needs to be compacted and simplified. - if self.stack_pos is "stack_root": - val.stack_pos = "data_root" - elif self.stack_pos is "data_root": - val.stack_pos = "filter" - elif self.stack_pos is "filter": - val.stack_pos = "x" - - except AttributeError: - pass - - def __getitem__(self, key): - """ The 'get' method for the Stack(dict) - - The method 'gets' a value from the stack. If 'stack_pos' is 'y' - AND the value isn't a Link instance THEN it tries to query the - stack again with the x/y variables swapped and IF that yelds - a result that is a Link object THEN it sets a 'transpose' variable - as True in the result and the result is transposed. - """ - val = defaultdict.__getitem__(self, key) - return val - - def add_data(self, data_key, data=None, meta=None, ): - """ - Sets the data_key into the stack, optionally mapping data sources it. - - It is possible to handle the mapping of data sources in different ways: - - * no meta or data (for proxy links not connected to source data) - * meta only (for proxy links with supporintg meta) - * data only (meta will be inferred if possible) - * data and meta - - Parameters - ---------- - data_key : str - The reference name for a data source connected to the Stack. - data : pandas.DataFrame - The input (case) data source. - meta : dict or OrderedDict - A quantipy compatible metadata source that describes the case data. - - Returns - ------- - None - """ - self._verify_key_types(name='data', keys=data_key) - - if data_key in self.keys(): - warning_msg = "You have overwritten data/meta for key: ['%s']." - print warning_msg % (data_key) - - if data is not None: - if isinstance(data, pd.DataFrame): - if meta is None: - # To do: infer meta from DataFrame - meta = {'info': None, 'lib': None, 'sets': None, - 'columns': None, 'masks': None} - # Add a special column of 1s - data['@1'] = np.ones(len(data.index)) - data.index = list(xrange(0, len(data.index))) - else: - raise TypeError( - "The 'data' given to Stack.add_data() must be one of the following types: " - "<pandas.DataFrame>" - ) - - if not meta is None: - if isinstance(meta, (dict, OrderedDict)): - # To do: verify incoming meta - pass - else: - raise TypeError( - "The 'meta' given to Stack.add_data() must be one of the following types: " - "<dict>, <collections.OrderedDict>." - ) - - # Add the data key to the stack - # self[data_key] = {} - - # Add the meta and data to the data_key position in the stack - self[data_key].meta = meta - self[data_key].data = data - self[data_key].cache = Cache() - self[data_key]['no_filter'].data = self[data_key].data - - def remove_data(self, data_keys): - """ - Deletes the data_key(s) and associated data specified in the Stack. - - Parameters - ---------- - data_keys : str or list of str - The data keys to remove. - - Returns - ------- - None - """ - self._verify_key_types(name='data', keys=data_keys) - if isinstance(data_keys, (str, unicode)): - data_keys = [data_keys] - for data_key in data_keys: - del self[data_key] - - def variable_types(self, data_key, only_type=None, verbose=True): - """ - Group variables by data types found in the meta. - - Parameters - ---------- - data_key : str - The reference name of a case data source hold by the Stack instance. - only_type : {'int', 'float', 'single', 'delimited set', 'string', - 'date', time', 'array'}, optional - Will restrict the output to the given data type. - - Returns - ------- - types : dict or list of str - A summary of variable names mapped to their data types, in form of - {type_name: [variable names]} or a list of variable names - confirming only_type. - """ - if self[data_key].meta['columns'] is None: - return 'No meta attached to data_key: %s' %(data_key) - else: - types = { - 'int': [], - 'float': [], - 'single': [], - 'delimited set': [], - 'string': [], - 'date': [], - 'time': [], - 'array': [] - } - not_found = [] - for col in self[data_key].data.columns: - if not col in ['@1', 'id_L1', 'id_L1.1']: - try: - types[ - self[data_key].meta['columns'][col]['type'] - ].append(col) - except: - not_found.append(col) - for mask in self[data_key].meta['masks'].keys(): - types[self[data_key].meta['masks'][mask]['type']].append(mask) - if not_found and verbose: - print '%s not found in meta file. Ignored.' %(not_found) - if only_type: - return types[only_type] - else: - return types - - def apply_meta_edits(self, batch_name, data_key, filter_key=None, - freeze=False): - """ - Take over meta_edits from Batch definitions. - - Parameters - ---------- - batch_name: str - Name of the Batch whose meta_edits are taken. - data_key: str - Accessing this metadata: ``self[data_key].meta`` - Batch definitions are takes from here and this metadata is modified. - filter_key: str, default None - Currently not implemented! - Accessing this metadata: ``self[data_key][filter_key].meta`` - Batch definitions are takes from here and this metadata is modified. - """ - if filter_key: - raise NotImplementedError("'filter_key' is not implemented.") - if freeze: - self.freeze_master_meta(data_key) - meta = self[data_key].meta - batch = meta['sets']['batches'][batch_name] - for name, e_meta in batch['meta_edits'].items(): - if name == 'lib': - continue - elif name in meta['masks']: - meta['masks'][name] = e_meta - try: - lib = batch['meta_edits']['lib'][name] - meta['lib']['values'][name] = lib - except: - pass - else: - meta['columns'][name] = e_meta - meta['lib']['default text'] = batch['language'] - return None - - def freeze_master_meta(self, data_key, filter_key=None): - """ - Save ``.meta`` in ``.master_meta`` for a defined data_key. - - Parameters - ---------- - data_key: str - Using: ``self[data_key]`` - filter_key: str, default None - Currently not implemented! - Using: ``self[data_key][filter_key]`` - """ - if filter_key: - raise NotImplementedError("'filter_key' is not implemented.") - self[data_key].master_meta = copy.deepcopy(self[data_key].meta) - self[data_key].meta = copy.deepcopy(self[data_key].meta) - return None - - def restore_meta(self, data_key, filter_key=None): - """ - Restore the ``.master_meta`` for a defined data_key if it exists. - - Undo self.apply_meta_edits() - - Parameters - ---------- - data_key: str - Accessing this metadata: ``self[data_key].meta`` - filter_key: str, default None - Currently not implemented! - Accessing this metadata: ``self[data_key][filter_key].meta`` - """ - if filter_key: - raise NotImplementedError("'filter_key' is not implemented.") - try: - self[data_key].meta = copy.deepcopy(self[data_key].master_meta) - except: - pass - return None - - def get_chain(self, *args, **kwargs): - - if qp.OPTIONS['new_chains']: - chain = ChainManager(self) - chain = chain.get(*args, **kwargs) - return chain - else: - def _get_chain(name=None, data_keys=None, filters=None, x=None, y=None, - views=None, orient_on=None, select=None, - rules=False, rules_weight=None, described=None): - """ - Construct a "chain" shaped subset of Links and their Views from the Stack. - - A chain is a one-to-one or one-to-many relation with an orientation that - defines from which axis (x or y) it is build. - - Parameters - ---------- - name : str, optional - If not provided the name of the chain is generated automatically. - data_keys, filters, x, y, views : str or list of str - Views will be added reflecting the order in ``views`` parameter. If - both ``x`` and ``y`` have multiple items, you must specify the - ``orient_on`` parameter. - orient_on : {'x', 'y'}, optional - Must be specified if both ``x`` and ``y`` are lists of multiple - items. - select : tbc. - :TODO: document this! - - Returns - ------- - chain : Chain object instance - """ - - #Make sure all the given keys are in lists - data_keys = self._force_key_as_list(data_keys) - # filters = self._force_key_as_list(filters) - views = self._force_key_as_list(views) - - #Make sure all the given keys are in lists - x = self._force_key_as_list(x) - y = self._force_key_as_list(y) - - if orient_on is None: - if len(x)==1: - orientation = 'x' - elif len(y)==1: - orientation = 'y' - else: - orientation = 'x' - else: - orientation = orient_on - if described is None: - described = self.describe() - - if isinstance(rules, bool): - if rules: - rules = ['x', 'y'] - else: - rules = [] - - if orient_on: - if x is None: - x = described['x'].drop_duplicates().values.tolist() - if y is None: - y = described['y'].drop_duplicates().values.tolist() - if views is None: - views = self._Stack__view_keys - views = [v for v in views if '|default|' not in v] - chains = self.__get_chains( - name=name, - data_keys=data_keys, - filters=filters, - x=x, - y=y, - views=views, - orientation=orient_on, - select=select, - rules=rules, - rules_weight=rules_weight) - return chains - else: - chain = Chain(name) - found_views = [] - - #Make sure all the given keys are in lists - x = self._force_key_as_list(x) - y = self._force_key_as_list(y) - - if data_keys is None: - # Apply lazy data_keys if none given - data_keys = self.keys() - - the_filter = "no_filter" if filters is None else filters - - if self.__has_list(data_keys): - for key in data_keys: - # Use describe method to get x keys if not supplied. - if x is None: - x_keys = described['x'].drop_duplicates().values.tolist() - else: - x_keys = x - - # Use describe method to get y keys if not supplied. - if y is None: - y_keys = described['y'].drop_duplicates().values.tolist() - else: - y_keys = y - - # Use describe method to get view keys if not supplied. - if views is None: - v_keys = described['view'].drop_duplicates().values.tolist() - v_keys = [v_key for v_key in v_keys if '|default|' - not in v_key] - else: - v_keys = views - - chain._derive_attributes( - key, the_filter, x_keys, y_keys, views, orientation=orientation) - - # Apply lazy name if none given - if name is None: - chain._lazy_name() - - for x_key in x_keys: - self._verify_key_exists( - x_key, - stack_path=[key, the_filter] - ) - - for y_key in y_keys: - self._verify_key_exists( - y_key, - stack_path=[key, the_filter, x_key]) - - - try: - base_text = self[key].meta['columns'][x_key]['properties']['base_text'] - if isinstance(base_text, (str, unicode)): - if base_text.startswith(('Base:', 'Bas:')): - base_text = base_text.split(':')[-1].lstrip() - elif isinstance(base_text, dict): - for text_key in base_text.keys(): - if base_text[text_key].startswith(('Base:', 'Bas:')): - base_text[text_key] = base_text[text_key].split(':')[-1].lstrip() - chain.base_text = base_text - except: - pass - if views is None: - chain[key][the_filter][x_key][y_key] = self[key][the_filter][x_key][y_key] - else: - stack_link = self[key][the_filter][x_key][y_key] - link_keys = stack_link.keys() - chain_link = {} - chain_view_keys = [k for k in views if k in link_keys] - for vk in chain_view_keys: - stack_view = stack_link[vk] - # Get view dataframe - rules_x_slicer = self.axis_slicer_from_vartype( - rules, 'x', key, the_filter, x_key, y_key, rules_weight) - - rules_y_slicer = self.axis_slicer_from_vartype( - rules, 'y', key, the_filter, x_key, y_key, rules_weight) - if rules_x_slicer is None and rules_y_slicer is None: - # No rules to apply - view_df = stack_view.dataframe - else: - # Apply rules - viable_axes = functions.rule_viable_axes(self[key].meta, vk, x_key, y_key) - transposed_array_sum = x_key == '@' and y_key in self[key].meta['masks'] - if not viable_axes: - # Axes are not viable for rules application - view_df = stack_view.dataframe - else: - view_df = stack_view.dataframe.copy() - if 'x' in viable_axes and not rules_x_slicer is None: - # Apply x-rules - rule_codes = set(rules_x_slicer) - view_codes = set(view_df.index.tolist()) - if not rule_codes - view_codes: - view_df = view_df.loc[rules_x_slicer] - if 'x' in viable_axes and transposed_array_sum and rules_y_slicer: - view_df = view_df.loc[rules_y_slicer] - if 'y' in viable_axes and not rules_y_slicer is None: - # Apply y-rules - view_df = view_df[rules_y_slicer] - if vk.split('|')[1].startswith('t.'): - view_df = verify_test_results(view_df) - chain_view = View( - link=stack_link, - name = stack_view.name, - kwargs=stack_view._kwargs) - chain_view._notation = vk - chain_view.grp_text_map = stack_view.grp_text_map - chain_view.dataframe = view_df - chain_view._custom_txt = stack_view._custom_txt - chain_view.add_base_text = stack_view.add_base_text - chain_link[vk] = chain_view - if vk not in found_views: - found_views.append(vk) - - chain[key][the_filter][x_key][y_key] = chain_link - else: - raise ValueError( - "One or more of your data_keys ({data_keys}) is not" - " in the stack ({stack_keys})".format( - data_keys=data_keys, - stack_keys=self.keys() - ) - ) - - # Make sure chain.views only contains views that actually exist - # in the chain - if found_views: - chain.views = [ - view - for view in chain.views - if view in found_views] - return chain - - return _get_chain(*args, **kwargs) - - def reduce(self, data_keys=None, filters=None, x=None, y=None, variables=None, views=None): - ''' - Remove keys from the matching levels, erasing discrete Stack portions. - - Parameters - ---------- - data_keys, filters, x, y, views : str or list of str - - Returns - ------- - None - ''' - - # Ensure given keys are all valid types - self._verify_multiple_key_types( - data_keys=data_keys, - filters=filters, - x=x, - y=y, - variables=variables, - views=views - ) - - # Make sure all the given keys are in lists - data_keys = self._force_key_as_list(data_keys) - filters = self._force_key_as_list(filters) - views = self._force_key_as_list(views) - if not variables is None: - variables = self._force_key_as_list(variables) - x = variables - y = variables - else: - x = self._force_key_as_list(x) - y = self._force_key_as_list(y) - - # Make sure no keys that don't exist anywhere were passed - key_check = { - 'data': data_keys, - 'filter': filters, - 'x': x, - 'y': y, - 'view': views - } - - contents = self.describe() - for key_type, keys in key_check.iteritems(): - if not keys is None: - uk = contents[key_type].unique() - if not any([tk in uk for tk in keys]): - raise ValueError( - "Some of the %s keys passed to stack.reduce() " - "weren't found. Found: %s. " - "Given: %s" % (key_type, uk, keys) - ) - - if not data_keys is None: - for dk in data_keys: - try: - del self[dk] - except: - pass - - for dk in self.keys(): - if not filters is None: - for fk in filters: - try: - del self[dk][fk] - except: - pass - - for fk in self[dk].keys(): - if not x is None: - for xk in x: - try: - del self[dk][fk][xk] - except: - pass - - for xk in self[dk][fk].keys(): - if not y is None: - for yk in y: - try: - del self[dk][fk][xk][yk] - except: - pass - - for yk in self[dk][fk][xk].keys(): - if not views is None: - for vk in views: - try: - del self[dk][fk][xk][yk][vk] - except: - pass - - def add_link(self, data_keys=None, filters=['no_filter'], x=None, y=None, - views=None, weights=None, variables=None): - """ - Add Link and View defintions to the Stack. - - The method can be used flexibly: It is possible to pass only Link - defintions that might be composed of filter, x and y specifications, - only views incl. weight variable selections or arbitrary combinations of - the former. - - :TODO: Remove ``variables`` from parameter list and method calls. - - Parameters - ---------- - data_keys : str, optional - The data_key to be added to. If none is given, the method will try - to add to all data_keys found in the Stack. - filters : list of str describing filter defintions, default ['no_filter'] - The string must be a valid input for the - pandas.DataFrame.query() method. - x, y : str or list of str - The x and y variables to constrcut Links from. - views : list of view method names. - Can be any of Quantipy's preset Views or the names of created - view method specifications. - weights : list, optional - The names of weight variables to consider in the data aggregation - process. Weight variables must be of type ``float``. - - Returns - ------- - None - """ - if data_keys is None: - data_keys = self.keys() - else: - self._verify_key_types(name='data', keys=data_keys) - data_keys = self._force_key_as_list(data_keys) - - if not isinstance(views, ViewMapper): - # Use DefaultViews if no view were given - if views is None: - pass - # views = DefaultViews() - elif isinstance(views, (list, tuple)): - views = QuantipyViews(views=views) - else: - raise TypeError( - "The views past to stack.add_link() must be type <quantipy.view_generators.ViewMapper>, " - "or they must be a list of method names known to <quantipy.view_generators.QuantipyViews>." - ) - - qplogic_filter = False - if not isinstance(filters, dict): - self._verify_key_types(name='filter', keys=filters) - filters = self._force_key_as_list(filters) - filters = {f: f for f in filters} - # if filters.keys()[0] != 'no_filter': - # msg = ("Warning: pandas-based filtering will be deprecated in the " - # "future!\nPlease switch to quantipy-logic expressions.") - # print UserWarning(msg) - else: - qplogic_filter = True - - if not variables is None: - if not x is None or not y is None: - raise ValueError( - "You cannot pass both 'variables' and 'x' and/or 'y' to stack.add_link() " - "at the same time." - ) - - x = self._force_key_as_list(x) - y = self._force_key_as_list(y) - - # Get the lazy y keys none were given and there is only 1 x key - if not x is None: - if len(x)==1 and y is None: - y = self.describe( - index=['y'], - query="x=='%s'" % (x[0]) - ).index.tolist() - - # Get the lazy x keys none were given and there is only 1 y key - if not y is None: - if len(y)==1 and x is None: - x = self.describe( - index=['x'], - query="y=='%s'" % (y[0]) - ).index.tolist() - - for dk in data_keys: - self._verify_key_exists(dk) - for filter_def, logic in filters.items(): - - # qp.OPTIONS-based hack to allow faster stack filters - # ------------------------------------------------------ - if qp.OPTIONS['fast_stack_filters']: - if not filter_def in self[dk].keys(): - if filter_def=='no_filter': - self[dk][filter_def].data = self[dk].data - self[dk][filter_def].meta = self[dk].meta - else: - if not qplogic_filter: - try: - self[dk][filter_def].data = self[dk].data.query(logic) - self[dk][filter_def].meta = self[dk].meta - except Exception, ex: - raise UserWarning('A filter definition is invalid and will be skipped: {filter_def}'.format(filter_def=filter_def)) - continue - else: - dataset = qp.DataSet('stack') - dataset.from_components(self[dk].data, self[dk].meta) - f_dataset = dataset.filter(filter_def, logic, inplace=False) - self[dk][filter_def].data = f_dataset._data - self[dk][filter_def].meta = f_dataset._meta - else: - if filter_def=='no_filter': - self[dk][filter_def].data = self[dk].data - self[dk][filter_def].meta = self[dk].meta - else: - if not qplogic_filter: - try: - self[dk][filter_def].data = self[dk].data.query(logic) - self[dk][filter_def].meta = self[dk].meta - except Exception, ex: - raise UserWarning('A filter definition is invalid and will be skipped: {filter_def}'.format(filter_def=filter_def)) - continue - else: - dataset = qp.DataSet('stack') - dataset.from_components(self[dk].data, self[dk].meta) - f_dataset = dataset.filter(filter_def, logic, inplace=False) - self[dk][filter_def].data = f_dataset._data - self[dk][filter_def].meta = f_dataset._meta - - - fdata = self[dk][filter_def].data - if len(fdata) == 0: - raise UserWarning('A filter definition resulted in no cases and will be skipped: {filter_def}'.format(filter_def=filter_def)) - continue - self.__create_links(data=fdata, data_key=dk, the_filter=filter_def, x=x, y=y, views=views, weights=weights, variables=variables) - - def describe(self, index=None, columns=None, query=None, split_view_names=False): - """ - Generates a structured overview of all Link defining Stack elements. - - Parameters - ---------- - index, columns : str of or list of {'data', 'filter', 'x', 'y', 'view'}, - optional - Controls the output representation by structuring a pivot-style - table according to the index and column values. - query : str - A query string that is valid for the pandas.DataFrame.query() method. - split_view_names : bool, default False - If True, will create an output of unique view name notations split - up into their components. - - Returns - ------- - description : pandas.DataFrame - DataFrame summing the Stack's structure in terms of Links and Views. - """ - stack_tree = [] - for dk in self.keys(): - path_dk = [dk] - filters = self[dk] - -# for fk in filters.keys(): -# path_fk = path_dk + [fk] -# xs = self[dk][fk] - - for fk in filters.keys(): - path_fk = path_dk + [fk] - xs = self[dk][fk] - - for sk in xs.keys(): - path_sk = path_fk + [sk] - ys = self[dk][fk][sk] - - for tk in ys.keys(): - path_tk = path_sk + [tk] - views = self[dk][fk][sk][tk] - - if views.keys(): - for vk in views.keys(): - path_vk = path_tk + [vk, 1] - stack_tree.append(tuple(path_vk)) - else: - path_vk = path_tk + ['|||||', 1] - stack_tree.append(tuple(path_vk)) - - column_names = ['data', 'filter', 'x', 'y', 'view', '#'] - description = pd.DataFrame.from_records(stack_tree, columns=column_names) - if split_view_names: - views_as_series = pd.DataFrame( - description.pivot_table(values='#', columns='view', aggfunc='count') - ).reset_index()['view'] - parts = ['xpos', 'agg', 'condition', 'rel_to', 'weights', - 'shortname'] - description = pd.concat( - (views_as_series, - pd.DataFrame(views_as_series.str.split('|').tolist(), - columns=parts)), axis=1) - - description.replace('|||||', np.NaN, inplace=True) - if query is not None: - description = description.query(query) - if not index is None or not columns is None: - description = description.pivot_table(values='#', index=index, columns=columns, - aggfunc='count') - return description - - def refresh(self, data_key, new_data_key='', new_weight=None, - new_data=None, new_meta=None): - """ - Re-run all or a portion of Stack's aggregations for a given data key. - - refresh() can be used to re-weight the data using a new case data - weight variable or to re-run all aggregations based on a changed source - data version (e.g. after cleaning the file/ dropping cases) or a - combination of the both. - - .. note:: - Currently this is only supported for the preset QuantipyViews(), - namely: ``'cbase'``, ``'rbase'``, ``'counts'``, ``'c%'``, - ``'r%'``, ``'mean'``, ``'ebase'``. - - Parameters - ---------- - data_key : str - The Links' data key to be modified. - new_data_key : str, default '' - Controls if the existing data key's files and aggregations will be - overwritten or stored via a new data key. - new_weight : str - The name of a new weight variable used to re-aggregate the Links. - new_data : pandas.DataFrame - The case data source. If None is given, the - original case data found for the data key will be used. - new_meta : quantipy meta document - A meta data source associated with the case data. If None is given, - the original meta definition found for the data key will be used. - - Returns - ------- - None - """ - content = self.describe()[['data', 'filter', 'x', 'y', 'view']] - content = content[content['data'] == data_key] - put_meta = self[data_key].meta if new_meta is None else new_meta - put_data = self[data_key].data if new_data is None else new_data - dk = new_data_key if new_data_key else data_key - self.add_data(data_key=dk, data=put_data, meta=put_meta) - skipped_views = [] - for _, f, x, y, view in content.values: - shortname = view.split('|')[-1] - if shortname not in ['default', 'cbase', 'cbase_gross', - 'rbase', 'counts', 'c%', - 'r%', 'ebase', 'mean', - 'c%_sum', 'counts_sum']: - if view not in skipped_views: - skipped_views.append(view) - warning_msg = ('\nOnly preset QuantipyViews are supported.' - 'Skipping: {}').format(view) - print warning_msg - else: - view_weight = view.split('|')[-2] - if not x in [view_weight, new_weight]: - if new_data is None and new_weight is not None: - if not view_weight == '': - if new_weight == '': - weight = [None, view_weight] - else: - weight = [view_weight, new_weight] - else: - if new_weight == '': - weight = None - else: - weight = [None, new_weight] - self.add_link(data_keys=dk, filters=f, x=x, y=y, - weights=weight, views=[shortname]) - else: - if view_weight == '': - weight = None - elif new_weight is not None: - if not (view_weight == new_weight): - if new_weight == '': - weight = [None, view_weight] - else: - weight = [view_weight, new_weight] - else: - weight = view_weight - else: - weight = view_weight - try: - self.add_link(data_keys=dk, filters=f, x=x, y=y, - weights=weight, views=[shortname]) - except ValueError, e: - print '\n', e - return None - - def save(self, path_stack, compression="gzip", store_cache=True, - decode_str=False, dataset=False, describe=False): - """ - Save Stack instance to .stack file. - - Parameters - ---------- - path_stack : str - The full path to the .stack file that should be created, including - the extension. - compression : {'gzip'}, default 'gzip' - The intended compression type. - store_cache : bool, default True - Stores the MatrixCache in a file in the same location. - decode_str : bool, default=True - If True the unicoder function will be used to decode all str - objects found anywhere in the meta document/s. - dataset : bool, default=False - If True a json/csv will be saved parallel to the saved stack - for each data key in the stack. - describe : bool, default=False - If True the result of stack.describe().to_excel() will be - saved parallel to the saved stack. - - Returns - ------- - None - """ - protocol = cPickle.HIGHEST_PROTOCOL - if not path_stack.endswith('.stack'): - raise ValueError( - "To avoid ambiguity, when using Stack.save() you must provide the full path to " - "the stack file you want to create, including the file extension. For example: " - "stack.save(path_stack='./output/MyStack.stack'). Your call looks like this: " - "stack.save(path_stack='%s', ...)" % (path_stack) - ) - - # Make sure there are no str objects in any meta documents. If - # there are any non-ASCII characters will be encoded - # incorrectly and lead to UnicodeDecodeErrors in Jupyter. - if decode_str: - for dk in self.keys(): - self[dk].meta = unicoder(self[dk].meta) - - if compression is None: - f = open(path_stack, 'wb') - cPickle.dump(self, f, protocol) - else: - f = gzip.open(path_stack, 'wb') - cPickle.dump(self, f, protocol) - - if store_cache: - caches = {} - for key in self.keys(): - caches[key] = self[key].cache - - path_cache = path_stack.replace('.stack', '.cache') - if compression is None: - f1 = open(path_cache, 'wb') - cPickle.dump(caches, f1, protocol) - else: - f1 = gzip.open(path_cache, 'wb') - cPickle.dump(caches, f1, protocol) - - f1.close() - - f.close() - - if dataset: - for key in self.keys(): - path_json = path_stack.replace( - '.stack', - ' [{}].json'.format(key)) - path_csv = path_stack.replace( - '.stack', - ' [{}].csv'.format(key)) - write_quantipy( - meta=self[key].meta, - data=self[key].data, - path_json=path_json, - path_csv=path_csv) - - if describe: - path_describe = path_stack.replace('.stack', '.xlsx') - self.describe().to_excel(path_describe) - - # def get_slice(data_key=None, x=None, y=None, filters=None, views=None): - # """ """ - # pass - - # STATIC METHODS - - @staticmethod - def from_sav(data_key, filename, name=None, path=None, ioLocale="en_US.UTF-8", ioUtf8=True): - """ - Creates a new stack instance from a .sav file. - - Parameters - ---------- - data_key : str - The data_key for the data and meta in the sav file. - filename : str - The name to the sav file. - name : str - A name for the sav (stored in the meta). - path : str - The path to the sav file. - ioLocale : str - The locale used in during the sav processing. - ioUtf8 : bool - Boolean that indicates the mode in which text communicated to or - from the I/O module will be. - - Returns - ------- - stack : stack object instance - A stack instance that has a data_key with data and metadata - to run aggregations. - """ - if name is None: - name = data_key - - meta, data = parse_sav_file(filename=filename, path=path, name=name, ioLocale=ioLocale, ioUtf8=ioUtf8) - return Stack(add_data={name: {'meta': meta, 'data':data}}) - - @staticmethod - def load(path_stack, compression="gzip", load_cache=False): - """ - Load Stack instance from .stack file. - - Parameters - ---------- - path_stack : str - The full path to the .stack file that should be created, including - the extension. - compression : {'gzip'}, default 'gzip' - The compression type that has been used saving the file. - load_cache : bool, default False - Loads MatrixCache into the Stack a .cache file is found. - - Returns - ------- - None - """ - - - if not path_stack.endswith('.stack'): - raise ValueError( - "To avoid ambiguity, when using Stack.load() you must provide the full path to " - "the stack file you want to create, including the file extension. For example: " - "stack.load(path_stack='./output/MyStack.stack'). Your call looks like this: " - "stack.load(path_stack='%s', ...)" % (path_stack) - ) - - if compression is None: - f = open(path_stack, 'rb') - else: - f = gzip.open(path_stack, 'rb') - new_stack = cPickle.load(f) - f.close() - - if load_cache: - path_cache = path_stack.replace('.stack', '.cache') - if compression is None: - f = open(path_cache, 'rb') - else: - f = gzip.open(path_cache, 'rb') - caches = cPickle.load(f) - for key in caches.keys(): - if key in new_stack.keys(): - new_stack[key].cache = caches[key] - else: - raise ValueError( - "Tried to insert a loaded MatrixCache in to a data_key in the stack that" - "is not in the stack. The data_key is '{}', available keys are {}" - .format(key, caches.keys()) - ) - f.close() - - return new_stack - - - # PRIVATE METHODS - - def __get_all_y_keys(self, data_key, the_filter="no_filter"): - if(self.stack_pos == 'stack_root'): - return self[data_key].y_variables - else: - raise KeyError("get_all_y_keys can only be called from a stack at root level. Current level is '{0}'".format(self.stack_pos)) - - def __get_all_x_keys(self, data_key, the_filter="no_filter"): - if(self.stack_pos == 'stack_root'): - return self[data_key].x_variables - else: - raise KeyError("get_all_x_keys can only be called from a stack at root level. Current level is '{0}'".format(self.stack_pos)) - - def __get_all_x_keys_except(self, data_key, exception): - keys = self.__get_all_x_keys(data_key) - return [i for i in keys if i != exception[0]] - - def __get_all_y_keys_except(self, data_key, exception): - keys = self.__get_all_y_keys(data_key) - return [i for i in keys if i != exception[0]] - - def __set_x_key(self, key): - if self.x_variables is None: - self.x_variables = set(key) - else: - self.x_variables.update(key) - - def __set_y_key(self, key): - if self.y_variables is None: - self.y_variables = set(key) - else: - self.y_variables.update(key) - - def _set_x_and_y_keys(self, data_key, x, y): - """ - Sets the x_variables and y_variables in the data part of the stack for this data_key, e.g. stack['Jan']. - This method can also be used to add to the current lists and it makes sure the list stays unique. - """ - if self.stack_pos == 'stack_root': - self[data_key].__set_x_key(x) - self[data_key].__set_y_key(y) - else: - raise KeyError("set_x_keys can only be called from a stack at root level. Current level is '{0}'".format(self.stack_pos)) - - def __create_combinations(self, data, data_key, x=None, y=None, weight=None, variables=None): - if isinstance(y, str): - y = [y] - if isinstance(x, str): - x = [x] - - has_metadata = self[data_key].meta is not None and not isinstance(self[data_key].meta, Stack) - - # any(...) returns true if ANY of the vars are not None - if any([x, y]) and variables is not None: - # Raise an error if variables AND x/y are BOTH supplied - raise ValueError("Either use the 'variables' OR 'x', 'y' NOT both.") - - if not any([x, y]): - if variables is None: - if not has_metadata: - # "fully-lazy" method. (variables, x and y are all None) - variables = data.columns.tolist() - - if variables is not None: - x = variables - y = variables - variables = None - - # Ensure that we actually have metadata - if has_metadata: - # THEN we try to create the combinations with metadata - combinations = self.__create_combinations_with_meta(data=data, data_key=data_key, x=x, y=y, weight=weight) - else: - # Either variables or both x AND y are supplied. Then create the combinations from that. - combinations = self.__create_combinations_no_meta(data=data, data_key=data_key, x=x, y=y, weight=weight) - - unique_list = set([item for comb in combinations for item in comb]) - - return combinations, unique_list - - def __create_combinations_with_meta(self, data, data_key, x=None, y=None, weight=None): - # TODO: These meta functions should possibly be in the helpers functions - metadata_columns = self[data_key].meta['columns'].keys() - for mask, mask_data in self[data_key].meta['masks'].iteritems(): - # TODO :: Get the static list from somewhere. not hardcoded. - if mask_data['type'].lower() in ['array', 'dichotomous set', - "categorical set"]: - metadata_columns.append(mask) - for item in mask_data['items']: - if "source" in item: - column = item["source"].split('@')[1] - metadata_columns.remove(column) - elif mask_data['type'].lower() in ["overlay"]: - pass - # Use all from the metadata, if nothing is specified (fully-lazy) - if x is None and y is None: - x = metadata_columns - y = metadata_columns - if all([x, y]): - metadata_columns = list(set(metadata_columns + x + y)) - elif x is not None: - metadata_columns = list(set(metadata_columns + x)) - elif y is not None: - metadata_columns = list(set(metadata_columns + y)) - combinations = functions.create_combinations_from_array(sorted(metadata_columns)) - - for var in [x, y]: - if var is not None: - if weight in var: - var.remove(weight) - if all([x, y]): - combinations = [(x_item, y_item) for x_item, y_item in combinations - if x_item in x and y_item in y] - elif x is not None: - combinations = [(x_item, y_item) for x_item, y_item in combinations - if x_item in x] - elif y is not None: - combinations = [(x_item, y_item) for x_item, y_item in combinations - if y_item in y] - - return combinations - - def __create_combinations_no_meta(self, data, data_key, x=None, y=None, weight=None): - if x is None: - x = data.columns.tolist() - if y is None: - y = data.columns.tolist() - for var in [x, y]: - if weight in var: - var.remove(weight) - combinations = [(x_item, y_item) for x_item in x for y_item - in y if x_item != y_item] - self._set_x_and_y_keys(data_key, x, y) - - return combinations - - def __create_links(self, data, data_key, views, variables=None, x=None, y=None, - the_filter=None, store_view_in_link=False, weights=None): - if views is not None: - has_links = True if self[data_key][the_filter].keys() else False - if has_links: - xs = self[data_key][the_filter].keys() - if x is not None: - valid_x = [xk for xk in xs if xk in x] - valid_x.extend(x) - x = set(valid_x) - else: - x = xs - ys = list(set(itertools.chain.from_iterable( - [self[data_key][the_filter][xk].keys() - for xk in xs]))) - if y is not None: - valid_y = [yk for yk in ys if yk in y] - valid_y.extend(y) - y = set(valid_y) - else: - y = ys - if self._x_and_y_keys_in_file(data_key, data, x, y): - for x_key, y_key in itertools.product(x, y): - if x_key==y_key and x_key=='@': - continue - if y_key == '@': - if not isinstance(self[data_key][the_filter][x_key][y_key], Link): - link = Link( - the_filter=the_filter, - x=x_key, - y='@', - data_key=data_key, - stack=self, - store_view=store_view_in_link, - create_views=False - ) - self[data_key][the_filter][x_key]['@'] = link - else: - link = self[data_key][the_filter][x_key]['@'] - elif x_key == '@': - if not isinstance(self[data_key][the_filter][x_key][y_key], Link): - link = Link( - the_filter=the_filter, - x='@', - y=y_key, - data_key=data_key, - stack=self, - store_view=store_view_in_link, - create_views=False - ) - self[data_key][the_filter]['@'][y_key] = link - else: - link = self[data_key][the_filter]['@'][y_key] - else: - if not isinstance(self[data_key][the_filter][x_key][y_key], Link): - link = Link( - the_filter=the_filter, - x=x_key, - y=y_key, - data_key=data_key, - stack=self, - store_view=store_view_in_link, - create_views=False - ) - self[data_key][the_filter][x_key][y_key] = link - else: - link = self[data_key][the_filter][x_key][y_key] - if views is not None: - views._apply_to(link, weights) - - def _x_and_y_keys_in_file(self, data_key, data, x, y): - data_columns = data.columns.tolist() - if '>' in ','.join(y): y = self._clean_from_nests(y) - if '>' in ','.join(x): - raise NotImplementedError('x-axis Nesting not supported.') - x_not_found = [var for var in x if not var in data_columns - and not var == '@'] - y_not_found = [var for var in y if not var in data_columns - and not var == '@'] - if x_not_found is not None: - masks_meta_lookup_x = [var for var in x_not_found - if var in self[data_key].meta['masks'].keys()] - for found_in_meta in masks_meta_lookup_x: - x_not_found.remove(found_in_meta) - if y_not_found is not None: - masks_meta_lookup_y = [var for var in y_not_found - if var in self[data_key].meta['masks'].keys()] - for found_in_meta in masks_meta_lookup_y: - y_not_found.remove(found_in_meta) - if not x_not_found and not y_not_found: - return True - elif x_not_found and y_not_found: - raise ValueError( - 'data key {}: x: {} and y: {} not found.'.format( - data_key, x_not_found, y_not_found)) - elif x_not_found: - raise ValueError( - 'data key {}: x: {} not found.'.format( - data_key, x_not_found)) - elif y_not_found: - raise ValueError( - 'data key {}: y: {} not found.'.format( - data_key, y_not_found)) - - def _clean_from_nests(self, variables): - cleaned = [] - nests = [var for var in variables if '>' in var] - non_nests = [var for var in variables if not '>' in var] - for nest in nests: - cleaned.extend([var.strip() for var in nest.split('>')]) - non_nests += cleaned - non_nests = list(set(non_nests)) - return non_nests - - def __clean_column_names(self, columns): - """ - Remove extra doublequotes if there are any - """ - cols = [] - for column in columns: - cols.append(column.replace('"', '')) - return cols - - def __generate_key_from_list_of(self, list_of_keys): - """ - Generate keys from a list (or tuple). - """ - list_of_keys = list(list_of_keys) - list_of_keys.sort() - return ",".join(list_of_keys) - - def __has_list(self, small): - """ - Check if object contains a list of strings. - """ - keys = self.keys() - for i in xrange(len(keys)-len(small)+1): - for j in xrange(len(small)): - if keys[i+j] != small[j]: - break - else: - return i, i+len(small) - return False - - def __get_all_combinations(self, list_of_items): - """Generates all combinations of items from a list """ - return [itertools.combinations(list_of_items, index+1) - for index in range(len(list_of_items))] - - def __get_stack_pointer(self, stack_pos): - """Takes a stack_pos and returns the stack with that location - raises an exception IF the stack pointer is not found - """ - if self.parent.stack_pos == stack_pos: - return self.parent - else: - return self.parent.__get_stack_pointer(stack_pos) - - def __get_chains(self, name, data_keys, filters, x, y, views, - orientation, select, rules, - rules_weight): - """ - List comprehension wrapper around .get_chain(). - """ - if orientation == 'y': - return [ - self.get_chain( - name=name, - data_keys=data_keys, - filters=filters, - x=x, - y=y_var, - views=views, - select=select, - rules=rules, - rules_weight=rules_weight - ) - for y_var in y - ] - elif orientation == 'x': - return [ - self.get_chain( - name=name, - data_keys=data_keys, - filters=filters, - x=x_var, - y=y, - views=views, - select=select, - rules=rules, - rules_weight=rules_weight - ) - for x_var in x - ] - else: - raise ValueError( - "Unknown orientation type. Please use 'x' or 'y'." - ) - - def _verify_multiple_key_types(self, data_keys=None, filters=None, x=None, - y=None, variables=None, views=None): - """ - Verify that the given keys str or unicode or a list or tuple of those. - """ - if data_keys is not None: - self._verify_key_types(name='data', keys=data_keys) - - if filters is not None: - self._verify_key_types(name='filter', keys=filters) - - if x is not None: - self._verify_key_types(name='x', keys=x) - - if y is not None: - self._verify_key_types(name='y', keys=y) - - if variables is not None: - self._verify_key_types(name='variables', keys=variables) - - if views is not None: - self._verify_key_types(name='view', keys=views) - - def _verify_key_exists(self, key, stack_path=[]): - """ - Verify that the given key exists in the stack at the path targeted. - """ - error_msg = ( - "Could not find the {key_type} key '{key}' in: {stack_path}. " - "Found {keys_found} instead." - ) - try: - dk = stack_path[0] - fk = stack_path[1] - xk = stack_path[2] - yk = stack_path[3] - vk = stack_path[4] - except: - pass - try: - if len(stack_path) == 0: - if key not in self: - key_type, keys_found = 'data', self.keys() - stack_path = 'stack' - raise ValueError - elif len(stack_path) == 1: - if key not in self[dk]: - key_type, keys_found = 'filter', self[dk].keys() - stack_path = "stack['{dk}']".format( - dk=dk) - raise ValueError - elif len(stack_path) == 2: - if key not in self[dk][fk]: - key_type, keys_found = 'x', self[dk][fk].keys() - stack_path = "stack['{dk}']['{fk}']".format( - dk=dk, fk=fk) - raise ValueError - elif len(stack_path) == 3: - meta = self[dk].meta - if self._is_array_summary(meta, xk, None) and not key == '@': - pass - elif key not in self[dk][fk][xk]: - key_type, keys_found = 'y', self[dk][fk][xk].keys() - stack_path = "stack['{dk}']['{fk}']['{xk}']".format( - dk=dk, fk=fk, xk=xk) - raise ValueError - elif len(stack_path) == 4: - if key not in self[dk][fk][xk][yk]: - key_type, keys_found = 'view', self[dk][fk][xk][yk].keys() - stack_path = "stack['{dk}']['{fk}']['{xk}']['{yk}']".format( - dk=dk, fk=fk, xk=xk, yk=yk) - raise ValueError - except ValueError: - print error_msg.format( - key_type=key_type, - key=key, - stack_path=stack_path, - keys_found=keys_found - ) - - def _force_key_as_list(self, key): - """Returns key as [key] if it is str or unicode""" - return [key] if isinstance(key, (str, unicode)) else key - - def _verify_key_types(self, name, keys): - """ - Verify that the given keys str or unicode or a list or tuple of those. - """ - if isinstance(keys, (list, tuple)): - for key in keys: - self._verify_key_types(name, key) - elif isinstance(keys, (str, unicode)): - pass - else: - raise TypeError( - "All %s keys must be one of the following types: " - "<str> or <unicode>, " - "<list> of <str> or <unicode>, " - "<tuple> of <str> or <unicode>. " - "Given: %s" % (name, keys) - ) - - def _find_groups(self, view): - groups = OrderedDict() - logic = view._kwargs.get('logic') - description = view.describe_block() - groups['codes'] = [c for c, d in description.items() if d == 'normal'] - net_names = [v for v, d in description.items() if d == 'net'] - for l in logic: - new_l = copy.deepcopy(l) - for k in l: - if k not in net_names: - del new_l[k] - groups[new_l.keys()[0]] = new_l.values()[0] - groups['codes'] = [c for c, d in description.items() if d == 'normal'] - return groups - - def sort_expanded_nets(self, view, within=True, between=True, ascending=False, - fix=None): - if not within and not between: - return view.dataframe - df = view.dataframe - name = df.index.levels[0][0] - if not fix: - fix_codes = [] - else: - if not isinstance(fix, list): - fix_codes = [fix] - else: - fix_codes = fix - fix_codes = [c for c in fix_codes if c in - df.index.get_level_values(1).tolist()] - net_groups = self._find_groups(view) - sort_col = (df.columns.levels[0][0], '@') - sort = [(name, v) for v in df.index.get_level_values(1) - if (v in net_groups['codes'] or - v in net_groups.keys()) and not v in fix_codes] - if between: - if pd.__version__ == '0.19.2': - temp_df = df.loc[sort].sort_values(sort_col, 0, ascending=ascending) - else: - temp_df = df.loc[sort].sort_index(0, sort_col, ascending=ascending) - else: - temp_df = df.loc[sort] - between_order = temp_df.index.get_level_values(1).tolist() - code_group_list = [] - for g in between_order: - if g in net_groups: - code_group_list.append([g] + net_groups[g]) - elif g in net_groups['codes']: - code_group_list.append([g]) - final_index = [] - for g in code_group_list: - is_code = len(g) == 1 - if not is_code: - fixed_net_name = g[0] - sort = [(name, v) for v in g[1:]] - if within: - if pd.__version__ == '0.19.2': - temp_df = df.loc[sort].sort_values(sort_col, 0, ascending=ascending) - else: - temp_df = df.loc[sort].sort_index(0, sort_col, ascending=ascending) - else: - temp_df = df.loc[sort] - new_idx = [fixed_net_name] + temp_df.index.get_level_values(1).tolist() - final_index.extend(new_idx) - else: - final_index.extend(g) - final_index = [(name, i) for i in final_index] - if fix_codes: - fix_codes = [(name, f) for f in fix_codes] - final_index.extend(fix_codes) - df = df.reindex(final_index) - return df - - def get_frequency_via_stack(self, data_key, the_filter, col, weight=None): - weight_notation = '' if weight is None else weight - vk = 'x|f|:||{}|counts'.format(weight_notation) - try: - f = self[data_key][the_filter][col]['@'][vk].dataframe - except (KeyError, AttributeError) as e: - try: - f = self[data_key][the_filter]['@'][col][vk].dataframe.T - except (KeyError, AttributeError) as e: - f = frequency(self[data_key].meta, self[data_key].data, x=col, weight=weight) - return f - - def get_descriptive_via_stack(self, data_key, the_filter, col, weight=None): - l = self[data_key][the_filter][col]['@'] - w = '' if weight is None else weight - mean_key = [k for k in l.keys() if 'd.mean' in k.split('|')[1] and - k.split('|')[-2] == w] - if not mean_key: - msg = "No mean view to sort '{}' on found!" - raise RuntimeError(msg.format(col)) - elif len(mean_key) > 1: - msg = "Multiple mean views found for '{}'. Unable to sort!" - raise RuntimeError(msg.format(col)) - else: - mean_key = mean_key[0] - vk = mean_key - d = l[mean_key].dataframe - return d - - def _is_array_summary(self, meta, x, y): - return x in meta['masks'] - - def _is_transposed_summary(self, meta, x, y): - return x == '@' and y in meta['masks'] - - def axis_slicer_from_vartype(self, all_rules_axes, rules_axis, dk, the_filter, x, y, rules_weight): - if rules_axis == 'x' and 'x' not in all_rules_axes: - return None - elif rules_axis == 'y' and 'y' not in all_rules_axes: - return None - meta = self[dk].meta - - array_summary = self._is_array_summary(meta, x, y) - transposed_summary = self._is_transposed_summary(meta, x, y) - - axis_slicer = None - - if rules_axis == 'x': - if not array_summary and not transposed_summary: - axis_slicer = self.get_rules_slicer_via_stack( - dk, the_filter, x=x, weight=rules_weight) - elif array_summary: - axis_slicer = self.get_rules_slicer_via_stack( - dk, the_filter, x=x, y='@', weight=rules_weight, - slice_array_items=True) - elif transposed_summary: - axis_slicer = self.get_rules_slicer_via_stack( - dk, the_filter, x='@', y=y, weight=rules_weight) - elif rules_axis == 'y': - if not array_summary and not transposed_summary: - axis_slicer = self.get_rules_slicer_via_stack( - dk, the_filter, y=y, weight=rules_weight) - elif array_summary: - axis_slicer = self.get_rules_slicer_via_stack( - dk, the_filter, x=x, y='@', weight=rules_weight, - slice_array_items=False) - elif transposed_summary: - axis_slicer = self.get_rules_slicer_via_stack( - dk, the_filter, x='@', y=y, weight=rules_weight) - - return axis_slicer - - def get_rules_slicer_via_stack(self, data_key, the_filter, - x=None, y=None, weight=None, - slice_array_items=False): - m = self[data_key].meta - array_summary = self._is_array_summary(m, x, y) - transposed_summary = self._is_transposed_summary(m, x, y) - - rules = None - - if not array_summary and not transposed_summary: - if not x is None: - try: - rules = self[data_key].meta['columns'][x]['rules']['x'] - col = x - except: - pass - elif not y is None: - try: - rules = self[data_key].meta['columns'][y]['rules']['y'] - col = y - except: - pass - - elif array_summary: - if slice_array_items: - try: - rules = self[data_key].meta['masks'][x]['rules']['x'] - col = x - except: - pass - else: - try: - rules = self[data_key].meta['masks'][x]['rules']['y'] - col = x - except: - pass - - elif transposed_summary: - try: - rules = self[data_key].meta['masks'][y]['rules']['x'] - col = y - except: - pass - - if not rules: return None - views = self[data_key][the_filter][col]['@'].keys() - w = '' if weight is None else weight - expanded_net = [v for v in views if '}+]' in v - and v.split('|')[-2] == w - and v.split('|')[1] == 'f' and - not v.split('|')[3] == 'x'] - if expanded_net: - if len(expanded_net) > 1: - if len(expanded_net) == 2: - if expanded_net[0].split('|')[2] == expanded_net[1].split('|')[2]: - expanded_net = expanded_net[0] - else: - msg = "Multiple 'expand' using views found for '{}'. Unable to sort!" - raise RuntimeError(msg.format(col)) - else: - expanded_net = expanded_net[0] - if 'sortx' in rules: - on_mean = rules['sortx'].get('sort_on', '@') == 'mean' - else: - on_mean = False - if 'sortx' in rules and on_mean: - f = self.get_descriptive_via_stack( - data_key, the_filter, col, weight=weight) - elif 'sortx' in rules and expanded_net: - within = rules['sortx'].get('within', False) - between = rules['sortx'].get('between', False) - fix = rules['sortx'].get('fixed', False) - ascending = rules['sortx'].get('ascending', False) - view = self[data_key][the_filter][col]['@'][expanded_net] - f = self.sort_expanded_nets(view, between=between, within=within, - ascending=ascending, fix=fix) - else: - f = self.get_frequency_via_stack( - data_key, the_filter, col, weight=weight) - - if transposed_summary or (not slice_array_items and array_summary): - rules_slicer = functions.get_rules_slicer(f.T, rules) - else: - if not expanded_net or ('sortx' in rules and on_mean): - rules_slicer = functions.get_rules_slicer(f, rules) - else: - rules_slicer = f.index.values.tolist() - try: - rules_slicer.remove((col, 'All')) - except: - pass - return rules_slicer - - @modify(to_list='batches') - def _check_batches(self, dk, batches='all'): - """ - Returns a list of valid ``qp.Batch`` names. - - Parameters - ---------- - batches: str/ list of str, default 'all' - Included names are checked against valid ``qp.Batch`` names. If - batches='all', all valid ``Batch`` names are returned. - - Returns - ------- - list of str - """ - if not batches: - return [] - elif batches[0] == 'all': - return self[dk].meta['sets']['batches'].keys() - else: - valid = self[dk].meta['sets']['batches'].keys() - not_valid = [b for b in batches if not b in valid] - if not_valid: - msg = '``Batch`` name not found in ``Stack``: {}' - raise KeyError(msg.format(not_valid)) - return batches - - def _x_y_f_w_map(self, dk, batches='all'): - """ - """ - def _append_loop(mapping, x, fn, f, w, ys): - if not x in mapping: - mapping[x] = {fn: {'f': f, tuple(w): ys}} - elif not fn in mapping[x]: - mapping[x][fn] = {'f': f, tuple(w): ys} - elif not tuple(w) in mapping[x][fn]: - mapping[x][fn][tuple(w)] = ys - elif not all(y in mapping[x][fn][tuple(w)] for y in ys): - yks = set(mapping[x][fn][tuple(w)]).union(set(ys)) - mapping[x][fn][tuple(w)] = list(yks) - return None - - arrays = self.variable_types(dk, verbose=False)['array'] - mapping = {} - y_on_y = {} - batches = self._check_batches(dk, batches) - for batch in batches: - b = self[dk].meta['sets']['batches'][batch] - xy = b['x_y_map'] - f = b['x_filter_map'] - fy = b['y_filter_map'] - w = b['weights'] - for x, y in xy: - if x == '@': - y = y[0] - fn = f[y] if f[y] == 'no_filter' else f[y].keys()[0] - _append_loop(mapping, x, fn, f[y], w, [y]) - else: - fn = f[x] if f[x] == 'no_filter' else f[x].keys()[0] - _append_loop(mapping, x, fn, f[x], w, y) - for yy in b['y_on_y']: - fn = fy[yy] if fy[yy] == 'no_filter' else fy[yy].keys()[0] - for x in b['yks'][1:]: - _append_loop(mapping, x, fn, fy[yy], w, b['yks']) - _append_loop(y_on_y, x, fn, fy[yy], w, b['yks']) - return mapping, y_on_y - - @modify(to_list=['views', 'categorize', 'xs', 'batches']) - def aggregate(self, views, unweighted_base=True, categorize=[], - batches='all', xs=None, bases={}, verbose=True): - - """ - Add views to all defined ``qp.Link`` in ``qp.Stack``. - - Parameters - ---------- - views: str or list of str or qp.ViewMapper - ``views`` that are added. - unweighted_base: bool, default True - If True, unweighted 'cbase' is added to all non-arrays. - This parameter will be deprecated in future, please use bases - instead. - categorize: str or list of str - Determines how numerical data is handled: If provided, the - variables will get counts and percentage aggregations - (``'counts'``, ``'c%'``) alongside the ``'cbase'`` view. If False, - only ``'cbase'`` views are generated for non-categorical types. - batches: str/ list of str, default 'all' - Name(s) of ``qp.Batch`` instance(s) that are used to aggregate the - ``qp.Stack``. - xs: list of str - Names of variable, for which views are added. - bases: dict - Defines which bases should be aggregated, weighted or unweighted. - - Returns - ------- - None, modify ``qp.Stack`` inplace - """ - # Preparing bases if older version with unweighed_base is used - valid_bases = ['cbase', 'cbase_gross', 'ebase'] - if not bases and any(v in valid_bases for v in views): - new_bases = {} - for ba in valid_bases: - if ba in views: - new_bases[ba] = {'unwgt': False if ba=='ebase' else unweighted_base, - 'wgt': True} - views = [v for v in views if not v in valid_bases] - else: - new_bases = bases - - # Check if views are complete - if views and isinstance(views[0], ViewMapper): - views = views[0] - complete = views[views.keys()[0]]['kwargs'].get('complete', False) - elif any('cumsum' in v for v in views): - complete = True - else: - complete = False - - # get counts + net views - count_net_views = ['counts', 'counts_sum', 'counts_cumsum'] - if isinstance(views, ViewMapper) and views.keys() == ['net']: - counts_nets = qp.ViewMapper() - counts_nets.make_template('frequency', {'rel_to': [None, 'y']}) - options = {'logic': views['net']['kwargs']['logic'], - 'axis': 'x', - 'expand': views['net']['kwargs']['expand'], - 'complete': views['net']['kwargs']['complete'], - 'calc': views['net']['kwargs']['calc']} - counts_nets.add_method('net', kwargs=options) - else: - counts_nets = [v for v in views if v in count_net_views] - - x_in_stack = self.describe('x').index.tolist() - for dk in self.keys(): - batches = self._check_batches(dk, batches) - if not batches: return None - # check for unweighted_counts - batch = self[dk].meta['sets']['batches'] - unwgt_c = any(batch[b].get('unwgt_counts') for b in batches) - # get map and conditions for aggregation - x_y_f_w_map, y_on_y = self._x_y_f_w_map(dk, batches) - if not xs: - xs = [x for x in x_y_f_w_map.keys() if x in x_in_stack] - else: - xs = [x for x in xs if x in x_in_stack] - v_typ = self.variable_types(dk, verbose=False) - numerics = v_typ['int'] + v_typ['float'] - skipped = [x for x in xs if (x in numerics and not x in categorize)] - total_len = len(xs) - # loop over map and aggregate views - if total_len == 0: - msg = "Cannot aggregate, 'xs' contains no valid variables." - raise ValueError(msg) - for idx, x in enumerate(xs, start=1): - if not x in x_y_f_w_map.keys(): - msg = "Cannot find {} in qp.Stack for ``qp.Batch`` '{}'" - raise KeyError(msg.format(x, batches)) - v = [] if x in skipped else views - for f_dict in x_y_f_w_map[x].values(): - f = f_dict.pop('f') - f_key = f.keys()[0] if isinstance(f, dict) else f - for weight, y in f_dict.items(): - w = list(weight) if weight else None - # add bases - for ba, weights in new_bases.items(): - ba_w = [b_w for b_w in w if not b_w is None] - if weights.get('wgt') and ba_w: - self.add_link(dk, f, x=x, y=y, views=[ba], weights=ba_w) - elif weights.get('wgt') and not ba_w: - self.add_link(dk, f, x=x, y=y, views=[ba], weights=None) - if weights.get('unwgt'): - if not (x in v_typ['array'] or any(yks in v_typ['array'] for yks in y)): - self.add_link(dk, f, x=x, y=y, views=[ba], weights=None) - # remove existing nets for link if new view is a net - if isinstance(v, ViewMapper) and v.get('net'): - for ys in y: - link = self[dk][f_key][x][ys] - for view in link.keys(): - if view.split('|')[-1] == 'net': - del link[view] - # add unweighted views for counts/ nets - if unwgt_c and counts_nets and not None in w: - self.add_link(dk, f, x=x, y=y, views=counts_nets, weights=None) - # add common views - self.add_link(dk, f, x=x, y=y, views=v, weights=w) - # remove views if complete (cumsum/ nets) - if complete: - for ys in y: - y_on_ys = y_on_y.get(x, {}).get(f_key, {}).get(tuple(w), []) - if ys in y_on_ys: continue - link = self[dk][f_key][x][ys] - for ws in w: - pct = 'x|f|:|y|{}|c%'.format('' if not ws else ws) - counts = 'x|f|:||{}|counts'.format('' if not ws else ws) - for view in [pct, counts]: - if view in link: - del link[view] - - if verbose: - done = float(idx) / float(total_len) *100 - print '\r', - time.sleep(0.01) - print 'Stack [{}]: {} %'.format(dk, round(done, 1)), - sys.stdout.flush() - print '\n' - - if skipped and verbose: - msg = ("\n\nWarning: Found {} non-categorized numeric variable(s): {}.\n" - "Descriptive statistics must be added!") - print msg.format(len(skipped), skipped) - return None - - @modify(to_list=['on_vars', '_batches']) - def cumulative_sum(self, on_vars, _batches='all', verbose=True): - """ - Add cumulative sum view to a specified collection of xks of the stack. - - Parameters - ---------- - on_vars : list - The list of x variables to add the view to. - _batches: str or list of str - Only for ``qp.Links`` that are defined in this ``qp.Batch`` - instances views are added. - - Returns - ------- - None - The stack instance is modified inplace. - """ - for dk in self.keys(): - _batches = self._check_batches(dk, _batches) - if not _batches or not on_vars: return None - meta = self[dk].meta - data = self[dk].data - for v in on_vars: - if v in meta['sets']: - items = [i.split('@')[-1] for i in meta['sets'][v]['items']] - on_vars = list(set(on_vars + items)) - - self.aggregate(['counts_cumsum', 'c%_cumsum'], False, [], _batches, on_vars, verbose=verbose) - return None - - def _add_checking_chain(self, dk, cluster, name, x, y, views): - key, view, c_view = views - if isinstance(cluster, ChainManager): - c_stack = cluster.stack - else: - c_stack = qp.Stack('checks') - c_stack.add_data('checks', data=self[dk].data, meta=self[dk].meta) - c_stack.add_link(x=x, y=y, views=view, weights=None) - c_stack.add_link(x=x, y=y, views=c_view, weights=None) - c_views = c_stack.describe('view').index.tolist() - len_v_keys = len(view) - view_keys = ['x|f|x:|||cbase', 'x|f|:|||counts'][0:len_v_keys] - c_views = view_keys + [v for v in c_views - if v.endswith('{}_check'.format(key))] - if isinstance(cluster, ChainManager): - cluster.get('checks', 'no_filter', x, y, c_views, folder=name) - else: - if name == 'stat_check': - chain = c_stack.get_chain(x=x, y=y, views=c_views, orient_on='x') - name = [v for v in c_views if v.endswith('{}_check'.format(key))][0] - cluster[name] = chain - else: - chain = c_stack.get_chain(name=name, x=x, y=y, views=c_views) - cluster.add_chain(chain) - return cluster - - @modify(to_list=['on_vars', '_batches']) - def add_nets(self, on_vars, net_map, expand=None, calc=None, text_prefix='Net:', - checking_cluster=None, _batches='all', recode=None, verbose=True): - """ - Add a net-like view to a specified collection of x keys of the stack. - - Parameters - ---------- - on_vars : list - The list of x variables to add the view to. - net_map : list of dicts - The listed dicts must map the net/band text label to lists of - categorical answer codes to group together, e.g.: - - >>> [{'Top3': [1, 2, 3]}, - ... {'Bottom3': [4, 5, 6]}] - It is also possible to provide enumerated net definition dictionaries - that are explicitly setting ``text`` metadata per ``text_key`` entries: - - >>> [{1: [1, 2], 'text': {'en-GB': 'UK NET TEXT', - ... 'da-DK': 'DK NET TEXT', - ... 'de-DE': 'DE NET TEXT'}}] - expand : {'before', 'after'}, default None - If provided, the view will list the net-defining codes after or before - the computed net groups (i.e. "overcode" nets). - calc : dict, default None - A dictionary that is attaching a text label to a calculation expression - using the the net definitions. The nets are referenced as per - 'net_1', 'net_2', 'net_3', ... . - Supported calculation expressions are add, sub, div, mul. Example: - - >>> {'calc': ('net_1', add, 'net_2'), 'text': {'en-GB': 'UK CALC LAB', - ... 'da-DK': 'DA CALC LAB', - ... 'de-DE': 'DE CALC LAB'}} - text_prefix : str, default 'Net:' - By default each code grouping/net will have its ``text`` label prefixed - with 'Net: '. Toggle by passing None (or an empty str, ''). - checking_cluster : quantipy.Cluster, default None - When provided, an automated checking aggregation will be added to the - ``Cluster`` instance. - _batches: str or list of str - Only for ``qp.Links`` that are defined in this ``qp.Batch`` - instances views are added. - recode: {'extend_codes', 'drop_codes', 'collect_codes', 'collect_codes@cat_name'}, - default None - Adds variable with nets as codes to DataSet/Stack. If 'extend_codes', - codes are extended with nets. If 'drop_codes', new variable only - contains nets as codes. If 'collect_codes' or 'collect_codes@cat_name' - the variable contains nets and another category that summarises all - codes which are not included in any net. If no cat_name is provided, - 'Other' is taken as default - Returns - ------- - None - The stack instance is modified inplace. - """ - def _netdef_from_map(net_map, expand, prefix, text_key): - netdef = [] - for no, net in enumerate(net_map, start=1): - if 'text' in net: - logic = net[no] - text = net['text'] - else: - logic = net.values()[0] - text = {t: net.keys()[0] for t in text_key} - if not isinstance(logic, list) and isinstance(logic, int): - logic = [logic] - if prefix and not expand: - text = {k: '{} {}'.format(prefix, v) for k, v in text.items()} - if expand: - text = {k: '{} (NET)'.format(v) for k, v in text.items()} - netdef.append({'net_{}'.format(no): logic, 'text': text}) - return netdef - - def _check_and_update_calc(calc_expression, text_key): - if not isinstance(calc_expression, dict): - err_msg = ("'calc' must be a dict in form of\n" - "{'calculation label': (net # 1, operator, net # 2)}") - raise TypeError(err_msg) - for k, v in calc_expression.items(): - if not k in ['text', 'calc_only']: exp = v - if not k == 'calc_only': text = v - if not 'text' in calc_expression: - text = {tk: text for tk in text_key} - calc_expression['text'] = text - if not isinstance(exp, (tuple, list)) or len(exp) != 3: - err_msg = ("Not properly formed expression found in 'calc':\n" - "{}\nMust be provided as (net # 1, operator, net # 2)") - raise TypeError(err_msg.format(exp)) - return calc_expression - - def _recode_from_net_def(dataset, on_vars, net_map, expand, recode, verbose): - for var in on_vars: - if dataset.is_array(var): continue - suffix = '_rc' - for s in [str(x) if not x == 1 else '' for x in frange('1-5')]: - suf = suffix + s - name = '{}{}'.format(dataset._dims_free_arr_item_name(var), suf) - if dataset.var_exists(name): - if dataset._meta['columns'][name]['properties'].get('recoded_net'): - break - else: - break - - if dataset._is_array_item(var): - if not 'to_array' in dataset._meta['sets']: - dataset._meta['sets']['to_array'] = {} - to_array_set = dataset._meta['sets']['to_array'] - parent = dataset.parents(var)[0].split('@')[-1] - arr_name = dataset._dims_free_arr_name(parent) + suf - no = dataset.item_no(var) - if not arr_name in to_array_set: - to_array_set[arr_name] = [parent, [name], [no]] - else: - to_array_set[arr_name][1].append(name) - to_array_set[arr_name][2].append(no) - - mapper = [] - if recode == 'extend_codes': - mapper += [(x, y, {var: x}) for (x,y) in dataset.values(var)] - max_code = max(dataset.codes(var)) - elif recode == 'drop_codes': - max_code = 0 - elif 'collect_codes' in recode: - max_code = 0 - appends = [(max_code + x, net.keys()[0], {var: net.values()[0]}) - for x, net in enumerate(net_map, 1)] - mapper += appends - - if dataset._is_delimited_set_mapper(mapper): - qtype = 'delimited set' - else: - qtype = 'single' - dataset.derive(name, qtype, dataset.text(var), mapper) - if not dataset._meta['columns'][name].get('properties'): - dataset._meta['columns'][name]['properties'] = {} - dataset._meta['columns'][name]['properties'].update({'recoded_net': var}) - if 'properties' in dataset._meta['columns'][var]: - for pname, props in dataset._meta['columns'][var]['properties'].items(): - dataset._meta['columns'][name]['properties'][pname] = props - if verbose: - print 'Created: {}'. format(name) - if 'collect_codes' in recode: - cat_name = recode.split('@')[-1] if '@' in recode else 'Other' - code = len(net_map)+1 - dataset.extend_values(name, [(code, cat_name)]) - dataset.recode(name, {code: intersection([ - {var: not_count(0)}, - {name: has_count(0)}])}) - if recode == 'extend_codes' and expand: - codes = dataset.codes(var) - insert = [{net[0]: net[-1].values()[0]} - if isinstance(net[-1].values()[0], list) - else {net[0]: [net[-1].values()[0]]} - for net in appends] - remove = [] - if expand == 'after': - for net in insert: - if len(net.values()[0]) == 1: - codes[codes.index(net.values()[0][0])] = net.keys()[0] - remove.append(net.values()[0][0]) - else: - ind = codes.index(min(net.values()[0])) - codes = codes[:ind] + [net.keys()[0]] + codes[ind:] - elif expand == 'before': - for net in insert: - if len(net.values()[0]) == 1: - codes[codes.index(net.values()[0][0])] = net.keys()[0] - remove.append(net.values()[0][0]) - else: - ind = codes.index(max(net.values()[0])) + 1 - codes = codes[:ind] + [net.keys()[0]] + codes[ind:] - dataset.remove_values(name, remove) - dataset.reorder_values(name, codes) - - return None - - for dk in self.keys(): - _batches = self._check_batches(dk, _batches) - only_recode = not _batches and recode - if not _batches and not recode: return None - meta = self[dk].meta - data = self[dk].data - for v in on_vars: - if v in meta['sets']: - items = [i.split('@')[-1] for i in meta['sets'][v]['items']] - on_vars = list(set(on_vars)) + items - if not only_recode: - all_batches = copy.deepcopy(meta['sets']['batches']) - for n, b in all_batches.items(): - if not n in _batches: all_batches.pop(n) - languages = list(set(b['language'] for n, b in all_batches.items())) - netdef = _netdef_from_map(net_map, expand, text_prefix, languages) - if calc: calc = _check_and_update_calc(calc, languages) - view = qp.ViewMapper() - view.make_template('frequency', {'rel_to': [None, 'y']}) - options = {'logic': netdef, - 'axis': 'x', - 'expand': expand if expand in ['after', 'before'] else None, - 'complete': True if expand else False, - 'calc': calc} - view.add_method('net', kwargs=options) - self.aggregate(view, False, [], _batches, on_vars, verbose=verbose) - - if recode and any(rec in recode - for rec in ['extend_codes', 'drop_codes', 'collect_codes']): - ds = ds = qp.DataSet(dk, dimensions_comp=meta['info'].get('dimensions_comp')) - ds.from_stack(self, dk) - on_vars = [x for x in on_vars if x in self.describe('x').index.tolist()] - _recode_from_net_def(ds, on_vars, net_map, expand, recode, verbose) - - if checking_cluster is not None and not only_recode: - if isinstance(checking_cluster, ChainManager): - cc_keys = checking_cluster.folder_names - else: - cc_keys = checking_cluster.keys() - c_vars = {v: '{}_net'.format(v) for v in on_vars - if not v in meta['sets'] and - not '{}_net'.format(v) in cc_keys} - view['net_check'] = view.pop('net') - view['net_check']['kwargs']['iterators'].pop('rel_to') - for k, net in c_vars.items(): - checking_cluster = self._add_checking_chain(dk, checking_cluster, - net, k, ['@', k], ('net', ['cbase'], view)) - - if recode and 'to_array' in ds._meta['sets']: - for arr_name, arr_items in ds._meta['sets']['to_array'].items(): - dims_name = ds._dims_compat_arr_name(arr_name) - ds.to_array(arr_name, arr_items[1], ds.text(arr_items[0])) - sorter = list(enumerate(arr_items[2], start=1)) - sorter.sort(key = lambda x: x[1]) - sorter = [s[0] for s in sorter] - ds.reorder_items(dims_name, sorter) - msg = "Array {} built from recoded view variables!" - prop = ds._meta['masks'][dims_name]['properties'] - prop['recoded_net'] = arr_items[0] - if 'properties' in ds._meta['masks'][arr_items[0]]: - for p, v in ds._meta['masks'][arr_items[0]]['properties'].items(): - prop[p] = v - org_items = ds.sources(arr_items[0]) - new_items = ds.sources(dims_name) - for org, new in zip(org_items, new_items): - for p, v in ds._meta['columns'][org]['properties'].items(): - ds._meta['columns'][new]['properties'][p] = v - if verbose: print msg.format(dims_name) - del ds._meta['sets']['to_array'] - - return None - - @staticmethod - def _factor_labs(values, axis, rescale, drop, exclude, factor_labels, - has_factors): - if not rescale: rescale = {} - ignore = [v['value'] for v in values if v['value'] in exclude or - (not v['value'] in rescale.keys() and drop)] - if factor_labels == '()': - new_lab = '{} ({})' - split = ('(', ')') - else: - new_lab = '{} [{}]' - split = ('[', ']') - factors_mapped = {} - for v in values: - if v['value'] in ignore: continue - has_xedits = v['text'].get('x edits', {}) - has_yedits = v['text'].get('y edits', {}) - if not has_xedits: v['text']['x edits'] = {} - if not has_yedits: v['text']['y edits'] = {} - - factor = rescale[v['value']] if rescale else v['value'] - for tk, text in v['text'].items(): - if tk in ['x edits', 'y edits']: continue - for ax in axis: - try: - t = v['text']['{} edits'.format(ax)][tk] - except: - t = text - if has_factors: - fac = t.split(split[0])[-1].replace(split[1], '') - if fac == str(factor): continue - v['text']['{} edits'.format(ax)][tk] = new_lab.format(t, factor) - return values - - @staticmethod - def _add_factor_meta(dataset, var, options): - if not dataset._has_categorical_data(var): - return None - rescale = options[0] - drop = options[1] - exclude = options[2] - dataset.clear_factors(var) - all_codes = dataset.codes(var) - if rescale: - fm = rescale - else: - fm = {c: c for c in all_codes} - if not drop and rescale: - for c in all_codes: - if not c in fm: - fm[c] = c - if exclude: - for e in exclude: - if e in fm: - del fm[e] - dataset.set_factors(var, fm) - return None - - @modify(to_list=['on_vars', 'stats', 'exclude', '_batches']) - def add_stats(self, on_vars, stats=['mean'], other_source=None, rescale=None, - drop=True, exclude=None, factor_labels=True, custom_text=None, - checking_cluster=None, _batches='all', recode=False, verbose=True): - """ - Add a descriptives view to a specified collection of xks of the stack. - - Valid descriptives views: {'mean', 'stddev', 'min', 'max', 'median', 'sem'} - - Parameters - ---------- - on_vars : list - The list of x variables to add the view to. - stats : list of str, default ``['mean']`` - The metrics to compute and add as a view. - other_source : str - If provided the Link's x-axis variable will be swapped with the - (numerical) variable provided. This can be used to attach statistics - of a different variable to a Link definition. - rescale : dict - A dict that maps old to new codes, e.g. {1: 5, 2: 4, 3: 3, 4: 2, 5: 1} - drop : bool, default True - If ``rescale`` is provided all codes that are not mapped will be - ignored in the computation. - exclude : list - Codes/values to ignore in the computation. - factor_labels : bool / str, default True - Writes the (rescaled) factor values next to the category text label. - If True, square-brackets are used. If '()', normal brackets are used. - custom_text : str, default None - A custom string affix to put at the end of the requested statistics' - names. - checking_cluster : quantipy.Cluster, default None - When provided, an automated checking aggregation will be added to the - ``Cluster`` instance. - _batches: str or list of str - Only for ``qp.Links`` that are defined in this ``qp.Batch`` - instances views are added. - recode: bool, default False - Create a new variable that contains only the values - which are needed for the stat computation. The values and the included - data will be rescaled. - - Returns - ------- - None - The stack instance is modified inplace. - """ - - def _recode_from_stat_def(dataset, on_vars, rescale, drop, exclude, verbose): - for var in on_vars: - if dataset.is_array(var): continue - suffix = '_rc' - for s in [str(x) if not x == 1 else '' for x in frange('1-5')]: - suf = suffix + s - name = '{}{}'.format(var, suf) - if dataset.var_exists(name): - if dataset._meta['columns'][name]['properties'].get('recoded_stat'): - break - else: - break - if not rescale: - rescale = {x: x for x in dataset.codes(var)} - else: - rescale = copy.deepcopy(rescale) - if drop or exclude: - for x in rescale.keys(): - if not x in dataset.codes(var) or x in exclude: - rescale.pop(x) - dataset.add_meta(name, 'float', dataset.text(var)) - for x, y in rescale.items(): - sl = dataset.take({var: x}) - dataset[sl, name] = y - if verbose: - print 'Created: {}'. format(name) - dataset._meta['columns'][name]['properties'].update({'recoded_stat': var}) - return None - - def _add_factors(v, meta, values, args): - if isinstance(values, basestring): - p = values.split('@')[-1] - p_meta = meta.get('masks', meta)[p] - p_lib = meta['lib'].get('values', meta['lib']) - has_factors = p_meta.get('properties', {}).get('factor_labels', False) - v_args = args + [has_factors] - values = p_lib[p] - p_lib[p] = self._factor_labs(values, ['x', 'y'], *v_args) - if not p_meta.get('properties'): p_meta['properties'] = {} - p_meta['properties'].update({'factor_labels': True}) - else: - v_meta = meta.get('columns', meta)[v] - has_factors = v_meta.get('properties', {}).get('factor_labels') - v_args = args + [has_factors] - v_meta['values'] = self._factor_labs(values, ['x'], *v_args) - if not v_meta.get('properties'): v_meta['properties'] = {} - v_meta['properties'].update({'factor_labels': True}) - return None - - if other_source and not isinstance(other_source, str): - raise ValueError("'other_source' must be a str!") - if not rescale: drop = False - - options = {'stats': '', - 'source': other_source, - 'rescale': rescale, - 'drop': drop, 'exclude': exclude, - 'axis': 'x', - 'text': '' if not custom_text else custom_text} - for dk in self.keys(): - _batches = self._check_batches(dk, _batches) - if not _batches: return None - meta = self[dk].meta - data = self[dk].data - check_on = [] - for v in on_vars: - if v in meta['sets']: - items = [i.split('@')[-1] for i in meta['sets'][v]['items']] - on_vars = list(set(on_vars + items)) - check_on = list(set(check_on + [items[0]])) - elif not meta['columns'][v].get('values'): - continue - elif not isinstance(meta['columns'][v]['values'], list): - parent = meta['columns'][v]['parent'].keys()[0].split('@')[-1] - items = [i.split('@')[-1] for i in meta['sets'][parent]['items']] - check_on = list(set(check_on + [items[0]])) - else: - check_on = list(set(check_on + [v])) - - ds = qp.DataSet(dk, dimensions_comp=meta['info'].get('dimensions_comp')) - ds.from_stack(self, dk) - - self._add_factor_meta(ds, v, (rescale, drop, exclude)) - - - view = qp.ViewMapper() - view.make_template('descriptives') - for stat in stats: - options['stats'] = stat - view.add_method('stat', kwargs=options) - self.aggregate(view, False, on_vars, _batches, on_vars, verbose=verbose) - - if recode: - if other_source: - raise ValueError('Cannot recode if other_source is provided.') - ds = qp.DataSet(dk, dimensions_comp=meta['info'].get('dimensions_comp')) - ds.from_stack(self, dk) - on_vars = [x for x in on_vars if x in self.describe('x').index.tolist()] - _recode_from_stat_def(ds, on_vars, rescale, drop, exclude, verbose) - - if factor_labels: - args = [rescale, drop, exclude, factor_labels] - all_batches = meta['sets']['batches'].keys() - if not _batches: _batches = all_batches - batches = [b for b in all_batches if b in _batches] - for v in check_on: - globally = False - for b in batches: - batch_me = meta['sets']['batches'][b]['meta_edits'] - values = batch_me.get(v, {}).get('values', []) - if not values: - globally = True - else: - _add_factors(v, batch_me, values, args) - if globally: - values = meta['columns'][v]['values'] - _add_factors(v, meta, values, args) - if isinstance(checking_cluster, ChainManager): - cm_meta = checking_cluster.stack['checks'].meta - values = cm_meta['columns'][v]['values'] - _add_factors(v, cm_meta, values, args) - if checking_cluster and 'mean' in stats and check_on: - - options['stats'] = 'mean' - c_view = qp.ViewMapper().make_template('descriptives') - c_view.add_method('stat_check', kwargs=options) - - views = ('stat', ['cbase', 'counts'], c_view) - checking_cluster = self._add_checking_chain(dk, checking_cluster, - 'stat_check', check_on, ['@'], views) - - return None - - @modify(to_list=['_batches']) - def add_tests(self, _batches='all', verbose=True): - """ - Apply coltests for selected batches. - - Sig. Levels are taken from ``qp.Batch`` definitions. - - Parameters - ---------- - _batches: str or list of str - Only for ``qp.Links`` that are defined in this ``qp.Batch`` - instances views are added. - - Returns - ------- - None - """ - self._remove_coltests() - - if verbose: - start = time.time() - - for dk in self.keys(): - _batches = self._check_batches(dk, _batches) - if not _batches: return None - for batch_name in _batches: - batch = self[dk].meta['sets']['batches'][batch_name] - sigpro = batch.get('sigproperties', {}) - levels = batch.get('sigproperties', batch).get('siglevels', []) - weight = batch['weights'] - x_y = batch['x_y_map'] - x_f = batch['x_filter_map'] - y_f = batch['y_filter_map'] - yks = batch['yks'] - - if levels: - vm_tests = qp.ViewMapper().make_template( - method='coltests', - iterators={'metric': ['props', 'means'], - 'mimic': sigpro.get('mimic', ['Dim']), - 'level': levels}) - vm_tests.add_method('significance', - kwargs = {'flag_bases': sigpro.get('flag_bases', [30, 100]), - 'test_total': sigpro.get('test_total', None), - 'groups': 'Tests'}) - for yy in batch['y_on_y']: - self.add_link(filters=y_f[yy], x=yks[1:], y=yks, - views=vm_tests, weights=weight) - total_len = len(x_y) - for idx, xy in enumerate(x_y, 1): - x, y = xy - if x == '@': continue - self.add_link(filters=x_f[x], x=x, y=y, - views=vm_tests, weights=weight) - if verbose: - done = float(idx) / float(total_len) *100 - print '\r', - time.sleep(0.01) - print 'Batch [{}]: {} %'.format(batch_name, round(done, 1)), - sys.stdout.flush() - if verbose: print '\n' - if verbose: print 'Sig-Tests:', time.time()-start - return None - - def _remove_coltests(self, props=True, means=True): - """ - Remove coltests from stack. - - Parameters - ---------- - props : bool, default=True - If True, column proportion test view will be removed from stack. - means : bool, default=True - If True, column mean test view will be removed from stack. - """ - for dk in self.keys(): - for fk in self[dk].keys(): - for xk in self[dk][fk].keys(): - for yk in self[dk][fk][xk].keys(): - for vk in self[dk][fk][xk][yk].keys(): - del_prop = props and 't.props' in vk - del_mean = means and 't.means' in vk - if del_prop or del_mean: - del self[dk][fk][xk][yk][vk] - return None \ No newline at end of file + +#-*- coding: utf-8 -*- +import io +import itertools +import json +import pandas as pd +import numpy as np +import quantipy as qp +import copy +import time +import sys +import warnings + +from link import Link +from chain import Chain +from view import View +from helpers import functions +from view_generators.view_mapper import ViewMapper +from view_generators.view_maps import QuantipyViews +from quantipy.core.tools.qp_decorators import modify +from quantipy.core.tools.dp.spss.reader import parse_sav_file +from quantipy.core.tools.dp.io import unicoder, write_quantipy +from quantipy.core.tools.dp.prep import frequency, verify_test_results, frange +from quantipy.core.tools.view.logic import ( + has_any, has_all, has_count, + not_any, not_all, not_count, + is_lt, is_ne, is_gt, + is_le, is_eq, is_ge, + union, intersection, get_logic_index) +from cache import Cache + +import itertools +from collections import defaultdict, OrderedDict + +# Pickle modules +import cPickle + +# Compression methods +import gzip + +from quantipy.sandbox.sandbox import Chain as NewChain +from quantipy.sandbox.sandbox import ChainManager + + +class Stack(defaultdict): + """ + Container of quantipy.Link objects holding View objects. + + A Stack is nested dictionary that structures the data and variable + relationships storing all View aggregations performed. + """ + + def __init__(self, + name="", + add_data=None): + + super(Stack, self).__init__(Stack) + + self.name = name + self.key = None + self.parent = None + + # This is the root of the stack + # It is used by the get/set methods to determine + # WHERE in the stack those methods are. + self.stack_pos = "stack_root" + + self.x_variables = None + self.y_variables = None + + self.__view_keys = [] + + if add_data: + for key in add_data: + if isinstance(add_data[key], dict): + self.add_data( + data_key=key, + data=add_data[key].get('data', None), + meta=add_data[key].get('meta', None) + ) + elif isinstance(add_data[key], tuple): + self.add_data( + data_key=key, + data=add_data[key][0], + meta=add_data[key][1] + ) + else: + raise TypeError( + "All data_key values must be one of the following types: " + "<dict> or <tuple>. " + "Given: %s" % (type(add_data[key])) + ) + + def __setstate__(self, attr_dict): + self.__dict__.update(attr_dict) + + def __reduce__(self): + arguments = (self.name, ) + state = self.__dict__.copy() + if 'cache' in state: + state.pop('cache') + state['cache'] = Cache() # Empty the cache for storage + return self.__class__, arguments, state, None, self.iteritems() + + def __setitem__(self, key, val): + """ The 'set' method for the Stack(dict) + + It 'sets' the value in it's correct place in the Stack + AND applies a 'stack_pos' value depending on WHERE in + the stack the value is being placed. + """ + super(Stack, self).__setitem__(key, val) + + # The 'meta' portion of the stack is a standar dict (not Stack) + try: + if isinstance(val, Stack) and val.stack_pos is "stack_root": + val.parent = self + val.key = key + + # This needs to be compacted and simplified. + if self.stack_pos is "stack_root": + val.stack_pos = "data_root" + elif self.stack_pos is "data_root": + val.stack_pos = "filter" + elif self.stack_pos is "filter": + val.stack_pos = "x" + + except AttributeError: + pass + + def __getitem__(self, key): + """ The 'get' method for the Stack(dict) + + The method 'gets' a value from the stack. If 'stack_pos' is 'y' + AND the value isn't a Link instance THEN it tries to query the + stack again with the x/y variables swapped and IF that yelds + a result that is a Link object THEN it sets a 'transpose' variable + as True in the result and the result is transposed. + """ + val = defaultdict.__getitem__(self, key) + return val + + def add_data(self, data_key, data=None, meta=None, ): + """ + Sets the data_key into the stack, optionally mapping data sources it. + + It is possible to handle the mapping of data sources in different ways: + + * no meta or data (for proxy links not connected to source data) + * meta only (for proxy links with supporintg meta) + * data only (meta will be inferred if possible) + * data and meta + + Parameters + ---------- + data_key : str + The reference name for a data source connected to the Stack. + data : pandas.DataFrame + The input (case) data source. + meta : dict or OrderedDict + A quantipy compatible metadata source that describes the case data. + + Returns + ------- + None + """ + self._verify_key_types(name='data', keys=data_key) + + if data_key in self.keys(): + warning_msg = "You have overwritten data/meta for key: ['%s']." + print warning_msg % (data_key) + + if data is not None: + if isinstance(data, pd.DataFrame): + if meta is None: + # To do: infer meta from DataFrame + meta = {'info': None, 'lib': None, 'sets': None, + 'columns': None, 'masks': None} + # Add a special column of 1s + data['@1'] = np.ones(len(data.index)) + data.index = list(xrange(0, len(data.index))) + else: + raise TypeError( + "The 'data' given to Stack.add_data() must be one of the following types: " + "<pandas.DataFrame>" + ) + + if not meta is None: + if isinstance(meta, (dict, OrderedDict)): + # To do: verify incoming meta + pass + else: + raise TypeError( + "The 'meta' given to Stack.add_data() must be one of the following types: " + "<dict>, <collections.OrderedDict>." + ) + + # Add the data key to the stack + # self[data_key] = {} + + # Add the meta and data to the data_key position in the stack + self[data_key].meta = meta + self[data_key].data = data + self[data_key].cache = Cache() + self[data_key]['no_filter'].data = self[data_key].data + + def remove_data(self, data_keys): + """ + Deletes the data_key(s) and associated data specified in the Stack. + + Parameters + ---------- + data_keys : str or list of str + The data keys to remove. + + Returns + ------- + None + """ + self._verify_key_types(name='data', keys=data_keys) + if isinstance(data_keys, (str, unicode)): + data_keys = [data_keys] + for data_key in data_keys: + del self[data_key] + + def variable_types(self, data_key, only_type=None, verbose=True): + """ + Group variables by data types found in the meta. + + Parameters + ---------- + data_key : str + The reference name of a case data source hold by the Stack instance. + only_type : {'int', 'float', 'single', 'delimited set', 'string', + 'date', time', 'array'}, optional + Will restrict the output to the given data type. + + Returns + ------- + types : dict or list of str + A summary of variable names mapped to their data types, in form of + {type_name: [variable names]} or a list of variable names + confirming only_type. + """ + if self[data_key].meta['columns'] is None: + return 'No meta attached to data_key: %s' %(data_key) + else: + types = { + 'int': [], + 'float': [], + 'single': [], + 'delimited set': [], + 'string': [], + 'date': [], + 'time': [], + 'array': [] + } + not_found = [] + for col in self[data_key].data.columns: + if not col in ['@1', 'id_L1', 'id_L1.1']: + try: + types[ + self[data_key].meta['columns'][col]['type'] + ].append(col) + except: + not_found.append(col) + for mask in self[data_key].meta['masks'].keys(): + types[self[data_key].meta['masks'][mask]['type']].append(mask) + if not_found and verbose: + print '%s not found in meta file. Ignored.' %(not_found) + if only_type: + return types[only_type] + else: + return types + + def apply_meta_edits(self, batch_name, data_key, filter_key=None, + freeze=False): + """ + Take over meta_edits from Batch definitions. + + Parameters + ---------- + batch_name: str + Name of the Batch whose meta_edits are taken. + data_key: str + Accessing this metadata: ``self[data_key].meta`` + Batch definitions are takes from here and this metadata is modified. + filter_key: str, default None + Currently not implemented! + Accessing this metadata: ``self[data_key][filter_key].meta`` + Batch definitions are takes from here and this metadata is modified. + """ + if filter_key: + raise NotImplementedError("'filter_key' is not implemented.") + if freeze: + self.freeze_master_meta(data_key) + meta = self[data_key].meta + batch = meta['sets']['batches'][batch_name] + for name, e_meta in batch['meta_edits'].items(): + if name == 'lib': + continue + elif name in meta['masks']: + meta['masks'][name] = e_meta + try: + lib = batch['meta_edits']['lib'][name] + meta['lib']['values'][name] = lib + except: + pass + else: + meta['columns'][name] = e_meta + meta['lib']['default text'] = batch['language'] + return None + + def freeze_master_meta(self, data_key, filter_key=None): + """ + Save ``.meta`` in ``.master_meta`` for a defined data_key. + + Parameters + ---------- + data_key: str + Using: ``self[data_key]`` + filter_key: str, default None + Currently not implemented! + Using: ``self[data_key][filter_key]`` + """ + if filter_key: + raise NotImplementedError("'filter_key' is not implemented.") + self[data_key].master_meta = copy.deepcopy(self[data_key].meta) + self[data_key].meta = copy.deepcopy(self[data_key].meta) + return None + + def restore_meta(self, data_key, filter_key=None): + """ + Restore the ``.master_meta`` for a defined data_key if it exists. + + Undo self.apply_meta_edits() + + Parameters + ---------- + data_key: str + Accessing this metadata: ``self[data_key].meta`` + filter_key: str, default None + Currently not implemented! + Accessing this metadata: ``self[data_key][filter_key].meta`` + """ + if filter_key: + raise NotImplementedError("'filter_key' is not implemented.") + try: + self[data_key].meta = copy.deepcopy(self[data_key].master_meta) + except: + pass + return None + + def get_chain(self, *args, **kwargs): + + if qp.OPTIONS['new_chains']: + chain = ChainManager(self) + chain = chain.get(*args, **kwargs) + return chain + else: + def _get_chain(name=None, data_keys=None, filters=None, x=None, y=None, + views=None, orient_on=None, select=None, + rules=False, rules_weight=None, described=None): + """ + Construct a "chain" shaped subset of Links and their Views from the Stack. + + A chain is a one-to-one or one-to-many relation with an orientation that + defines from which axis (x or y) it is build. + + Parameters + ---------- + name : str, optional + If not provided the name of the chain is generated automatically. + data_keys, filters, x, y, views : str or list of str + Views will be added reflecting the order in ``views`` parameter. If + both ``x`` and ``y`` have multiple items, you must specify the + ``orient_on`` parameter. + orient_on : {'x', 'y'}, optional + Must be specified if both ``x`` and ``y`` are lists of multiple + items. + select : tbc. + :TODO: document this! + + Returns + ------- + chain : Chain object instance + """ + + #Make sure all the given keys are in lists + data_keys = self._force_key_as_list(data_keys) + # filters = self._force_key_as_list(filters) + views = self._force_key_as_list(views) + + #Make sure all the given keys are in lists + x = self._force_key_as_list(x) + y = self._force_key_as_list(y) + + if orient_on is None: + if len(x)==1: + orientation = 'x' + elif len(y)==1: + orientation = 'y' + else: + orientation = 'x' + else: + orientation = orient_on + if described is None: + described = self.describe() + + if isinstance(rules, bool): + if rules: + rules = ['x', 'y'] + else: + rules = [] + + if orient_on: + if x is None: + x = described['x'].drop_duplicates().values.tolist() + if y is None: + y = described['y'].drop_duplicates().values.tolist() + if views is None: + views = self._Stack__view_keys + views = [v for v in views if '|default|' not in v] + chains = self.__get_chains( + name=name, + data_keys=data_keys, + filters=filters, + x=x, + y=y, + views=views, + orientation=orient_on, + select=select, + rules=rules, + rules_weight=rules_weight) + return chains + else: + chain = Chain(name) + found_views = [] + + #Make sure all the given keys are in lists + x = self._force_key_as_list(x) + y = self._force_key_as_list(y) + + if data_keys is None: + # Apply lazy data_keys if none given + data_keys = self.keys() + + the_filter = "no_filter" if filters is None else filters + + if self.__has_list(data_keys): + for key in data_keys: + # Use describe method to get x keys if not supplied. + if x is None: + x_keys = described['x'].drop_duplicates().values.tolist() + else: + x_keys = x + + # Use describe method to get y keys if not supplied. + if y is None: + y_keys = described['y'].drop_duplicates().values.tolist() + else: + y_keys = y + + # Use describe method to get view keys if not supplied. + if views is None: + v_keys = described['view'].drop_duplicates().values.tolist() + v_keys = [v_key for v_key in v_keys if '|default|' + not in v_key] + else: + v_keys = views + + chain._derive_attributes( + key, the_filter, x_keys, y_keys, views, orientation=orientation) + + # Apply lazy name if none given + if name is None: + chain._lazy_name() + + for x_key in x_keys: + self._verify_key_exists( + x_key, + stack_path=[key, the_filter] + ) + + for y_key in y_keys: + self._verify_key_exists( + y_key, + stack_path=[key, the_filter, x_key]) + + + try: + base_text = self[key].meta['columns'][x_key]['properties']['base_text'] + if isinstance(base_text, (str, unicode)): + if base_text.startswith(('Base:', 'Bas:')): + base_text = base_text.split(':')[-1].lstrip() + elif isinstance(base_text, dict): + for text_key in base_text.keys(): + if base_text[text_key].startswith(('Base:', 'Bas:')): + base_text[text_key] = base_text[text_key].split(':')[-1].lstrip() + chain.base_text = base_text + except: + pass + if views is None: + chain[key][the_filter][x_key][y_key] = self[key][the_filter][x_key][y_key] + else: + stack_link = self[key][the_filter][x_key][y_key] + link_keys = stack_link.keys() + chain_link = {} + chain_view_keys = [k for k in views if k in link_keys] + for vk in chain_view_keys: + stack_view = stack_link[vk] + # Get view dataframe + rules_x_slicer = self.axis_slicer_from_vartype( + rules, 'x', key, the_filter, x_key, y_key, rules_weight) + + rules_y_slicer = self.axis_slicer_from_vartype( + rules, 'y', key, the_filter, x_key, y_key, rules_weight) + if rules_x_slicer is None and rules_y_slicer is None: + # No rules to apply + view_df = stack_view.dataframe + else: + # Apply rules + viable_axes = functions.rule_viable_axes(self[key].meta, vk, x_key, y_key) + transposed_array_sum = x_key == '@' and y_key in self[key].meta['masks'] + if not viable_axes: + # Axes are not viable for rules application + view_df = stack_view.dataframe + else: + view_df = stack_view.dataframe.copy() + if 'x' in viable_axes and not rules_x_slicer is None: + # Apply x-rules + rule_codes = set(rules_x_slicer) + view_codes = set(view_df.index.tolist()) + if not rule_codes - view_codes: + view_df = view_df.loc[rules_x_slicer] + if 'x' in viable_axes and transposed_array_sum and rules_y_slicer: + view_df = view_df.loc[rules_y_slicer] + if 'y' in viable_axes and not rules_y_slicer is None: + # Apply y-rules + view_df = view_df[rules_y_slicer] + if vk.split('|')[1].startswith('t.'): + view_df = verify_test_results(view_df) + chain_view = View( + link=stack_link, + name = stack_view.name, + kwargs=stack_view._kwargs) + chain_view._notation = vk + chain_view.grp_text_map = stack_view.grp_text_map + chain_view.dataframe = view_df + chain_view._custom_txt = stack_view._custom_txt + chain_view.add_base_text = stack_view.add_base_text + chain_link[vk] = chain_view + if vk not in found_views: + found_views.append(vk) + + chain[key][the_filter][x_key][y_key] = chain_link + else: + raise ValueError( + "One or more of your data_keys ({data_keys}) is not" + " in the stack ({stack_keys})".format( + data_keys=data_keys, + stack_keys=self.keys() + ) + ) + + # Make sure chain.views only contains views that actually exist + # in the chain + if found_views: + chain.views = [ + view + for view in chain.views + if view in found_views] + return chain + + return _get_chain(*args, **kwargs) + + def reduce(self, data_keys=None, filters=None, x=None, y=None, variables=None, views=None): + ''' + Remove keys from the matching levels, erasing discrete Stack portions. + + Parameters + ---------- + data_keys, filters, x, y, views : str or list of str + + Returns + ------- + None + ''' + + # Ensure given keys are all valid types + self._verify_multiple_key_types( + data_keys=data_keys, + filters=filters, + x=x, + y=y, + variables=variables, + views=views + ) + + # Make sure all the given keys are in lists + data_keys = self._force_key_as_list(data_keys) + filters = self._force_key_as_list(filters) + views = self._force_key_as_list(views) + if not variables is None: + variables = self._force_key_as_list(variables) + x = variables + y = variables + else: + x = self._force_key_as_list(x) + y = self._force_key_as_list(y) + + # Make sure no keys that don't exist anywhere were passed + key_check = { + 'data': data_keys, + 'filter': filters, + 'x': x, + 'y': y, + 'view': views + } + + contents = self.describe() + for key_type, keys in key_check.iteritems(): + if not keys is None: + uk = contents[key_type].unique() + if not any([tk in uk for tk in keys]): + raise ValueError( + "Some of the %s keys passed to stack.reduce() " + "weren't found. Found: %s. " + "Given: %s" % (key_type, uk, keys) + ) + + if not data_keys is None: + for dk in data_keys: + try: + del self[dk] + except: + pass + + for dk in self.keys(): + if not filters is None: + for fk in filters: + try: + del self[dk][fk] + except: + pass + + for fk in self[dk].keys(): + if not x is None: + for xk in x: + try: + del self[dk][fk][xk] + except: + pass + + for xk in self[dk][fk].keys(): + if not y is None: + for yk in y: + try: + del self[dk][fk][xk][yk] + except: + pass + + for yk in self[dk][fk][xk].keys(): + if not views is None: + for vk in views: + try: + del self[dk][fk][xk][yk][vk] + except: + pass + + def add_link(self, data_keys=None, filters=['no_filter'], x=None, y=None, + views=None, weights=None, variables=None): + """ + Add Link and View defintions to the Stack. + + The method can be used flexibly: It is possible to pass only Link + defintions that might be composed of filter, x and y specifications, + only views incl. weight variable selections or arbitrary combinations of + the former. + + :TODO: Remove ``variables`` from parameter list and method calls. + + Parameters + ---------- + data_keys : str, optional + The data_key to be added to. If none is given, the method will try + to add to all data_keys found in the Stack. + filters : list of str describing filter defintions, default ['no_filter'] + The string must be a valid input for the + pandas.DataFrame.query() method. + x, y : str or list of str + The x and y variables to constrcut Links from. + views : list of view method names. + Can be any of Quantipy's preset Views or the names of created + view method specifications. + weights : list, optional + The names of weight variables to consider in the data aggregation + process. Weight variables must be of type ``float``. + + Returns + ------- + None + """ + if data_keys is None: + data_keys = self.keys() + else: + self._verify_key_types(name='data', keys=data_keys) + data_keys = self._force_key_as_list(data_keys) + + if not isinstance(views, ViewMapper): + # Use DefaultViews if no view were given + if views is None: + pass + # views = DefaultViews() + elif isinstance(views, (list, tuple)): + views = QuantipyViews(views=views) + else: + raise TypeError( + "The views past to stack.add_link() must be type <quantipy.view_generators.ViewMapper>, " + "or they must be a list of method names known to <quantipy.view_generators.QuantipyViews>." + ) + + qplogic_filter = False + if not isinstance(filters, dict): + self._verify_key_types(name='filter', keys=filters) + filters = self._force_key_as_list(filters) + filters = {f: f for f in filters} + # if filters.keys()[0] != 'no_filter': + # msg = ("Warning: pandas-based filtering will be deprecated in the " + # "future!\nPlease switch to quantipy-logic expressions.") + # print UserWarning(msg) + else: + qplogic_filter = True + + if not variables is None: + if not x is None or not y is None: + raise ValueError( + "You cannot pass both 'variables' and 'x' and/or 'y' to stack.add_link() " + "at the same time." + ) + x = self._force_key_as_list(x) + y = self._force_key_as_list(y) + + # Get the lazy y keys none were given and there is only 1 x key + if not x is None: + if len(x)==1 and y is None: + y = self.describe( + index=['y'], + query="x=='%s'" % (x[0]) + ).index.tolist() + + # Get the lazy x keys none were given and there is only 1 y key + if not y is None: + if len(y)==1 and x is None: + x = self.describe( + index=['x'], + query="y=='%s'" % (y[0]) + ).index.tolist() + + for dk in data_keys: + self._verify_key_exists(dk) + for filter_def, logic in filters.items(): + # qp.OPTIONS-based hack to allow faster stack filters + # ------------------------------------------------------ + if qp.OPTIONS['fast_stack_filters']: + if not filter_def in self[dk].keys(): + if filter_def=='no_filter': + self[dk][filter_def].data = self[dk].data + self[dk][filter_def].meta = self[dk].meta + else: + if not qplogic_filter: + try: + self[dk][filter_def].data = self[dk].data.query(logic) + self[dk][filter_def].meta = self[dk].meta + except Exception, ex: + raise UserWarning('A filter definition is invalid and will be skipped: {filter_def}'.format(filter_def=filter_def)) + continue + else: + dataset = qp.DataSet('stack') + dataset.from_components(self[dk].data, self[dk].meta, + reset=False) + f_dataset = dataset.filter(filter_def, logic, inplace=False) + self[dk][filter_def].data = f_dataset._data + self[dk][filter_def].meta = f_dataset._meta + else: + if filter_def=='no_filter': + self[dk][filter_def].data = self[dk].data + self[dk][filter_def].meta = self[dk].meta + else: + if not qplogic_filter: + try: + self[dk][filter_def].data = self[dk].data.query(logic) + self[dk][filter_def].meta = self[dk].meta + except Exception, ex: + raise UserWarning('A filter definition is invalid and will be skipped: {filter_def}'.format(filter_def=filter_def)) + continue + else: + dataset = qp.DataSet('stack') + dataset.from_components(self[dk].data, self[dk].meta) + f_dataset = dataset.filter(filter_def, logic, inplace=False) + self[dk][filter_def].data = f_dataset._data + self[dk][filter_def].meta = f_dataset._meta + fdata = self[dk][filter_def].data + + if len(fdata) == 0: + raise UserWarning('A filter definition resulted in no cases and will be skipped: {filter_def}'.format(filter_def=filter_def)) + continue + self.__create_links(data=fdata, data_key=dk, the_filter=filter_def, x=x, y=y, views=views, weights=weights, variables=variables) + + def describe(self, index=None, columns=None, query=None, split_view_names=False): + """ + Generates a structured overview of all Link defining Stack elements. + + Parameters + ---------- + index, columns : str of or list of {'data', 'filter', 'x', 'y', 'view'}, + optional + Controls the output representation by structuring a pivot-style + table according to the index and column values. + query : str + A query string that is valid for the pandas.DataFrame.query() method. + split_view_names : bool, default False + If True, will create an output of unique view name notations split + up into their components. + + Returns + ------- + description : pandas.DataFrame + DataFrame summing the Stack's structure in terms of Links and Views. + """ + stack_tree = [] + for dk in self.keys(): + path_dk = [dk] + filters = self[dk] + +# for fk in filters.keys(): +# path_fk = path_dk + [fk] +# xs = self[dk][fk] + + for fk in filters.keys(): + path_fk = path_dk + [fk] + xs = self[dk][fk] + + for sk in xs.keys(): + path_sk = path_fk + [sk] + ys = self[dk][fk][sk] + + for tk in ys.keys(): + path_tk = path_sk + [tk] + views = self[dk][fk][sk][tk] + + if views.keys(): + for vk in views.keys(): + path_vk = path_tk + [vk, 1] + stack_tree.append(tuple(path_vk)) + else: + path_vk = path_tk + ['|||||', 1] + stack_tree.append(tuple(path_vk)) + + column_names = ['data', 'filter', 'x', 'y', 'view', '#'] + description = pd.DataFrame.from_records(stack_tree, columns=column_names) + if split_view_names: + views_as_series = pd.DataFrame( + description.pivot_table(values='#', columns='view', aggfunc='count') + ).reset_index()['view'] + parts = ['xpos', 'agg', 'condition', 'rel_to', 'weights', + 'shortname'] + description = pd.concat( + (views_as_series, + pd.DataFrame(views_as_series.str.split('|').tolist(), + columns=parts)), axis=1) + + description.replace('|||||', np.NaN, inplace=True) + if query is not None: + description = description.query(query) + if not index is None or not columns is None: + description = description.pivot_table(values='#', index=index, columns=columns, + aggfunc='count') + return description + + def refresh(self, data_key, new_data_key='', new_weight=None, + new_data=None, new_meta=None): + """ + Re-run all or a portion of Stack's aggregations for a given data key. + + refresh() can be used to re-weight the data using a new case data + weight variable or to re-run all aggregations based on a changed source + data version (e.g. after cleaning the file/ dropping cases) or a + combination of the both. + + .. note:: + Currently this is only supported for the preset QuantipyViews(), + namely: ``'cbase'``, ``'rbase'``, ``'counts'``, ``'c%'``, + ``'r%'``, ``'mean'``, ``'ebase'``. + + Parameters + ---------- + data_key : str + The Links' data key to be modified. + new_data_key : str, default '' + Controls if the existing data key's files and aggregations will be + overwritten or stored via a new data key. + new_weight : str + The name of a new weight variable used to re-aggregate the Links. + new_data : pandas.DataFrame + The case data source. If None is given, the + original case data found for the data key will be used. + new_meta : quantipy meta document + A meta data source associated with the case data. If None is given, + the original meta definition found for the data key will be used. + + Returns + ------- + None + """ + content = self.describe()[['data', 'filter', 'x', 'y', 'view']] + content = content[content['data'] == data_key] + put_meta = self[data_key].meta if new_meta is None else new_meta + put_data = self[data_key].data if new_data is None else new_data + dk = new_data_key if new_data_key else data_key + self.add_data(data_key=dk, data=put_data, meta=put_meta) + skipped_views = [] + for _, f, x, y, view in content.values: + shortname = view.split('|')[-1] + if shortname not in ['default', 'cbase', 'cbase_gross', + 'rbase', 'counts', 'c%', + 'r%', 'ebase', 'mean', + 'c%_sum', 'counts_sum']: + if view not in skipped_views: + skipped_views.append(view) + warning_msg = ('\nOnly preset QuantipyViews are supported.' + 'Skipping: {}').format(view) + print warning_msg + else: + view_weight = view.split('|')[-2] + if not x in [view_weight, new_weight]: + if new_data is None and new_weight is not None: + if not view_weight == '': + if new_weight == '': + weight = [None, view_weight] + else: + weight = [view_weight, new_weight] + else: + if new_weight == '': + weight = None + else: + weight = [None, new_weight] + self.add_link(data_keys=dk, filters=f, x=x, y=y, + weights=weight, views=[shortname]) + else: + if view_weight == '': + weight = None + elif new_weight is not None: + if not (view_weight == new_weight): + if new_weight == '': + weight = [None, view_weight] + else: + weight = [view_weight, new_weight] + else: + weight = view_weight + else: + weight = view_weight + try: + self.add_link(data_keys=dk, filters=f, x=x, y=y, + weights=weight, views=[shortname]) + except ValueError, e: + print '\n', e + return None + + def save(self, path_stack, compression="gzip", store_cache=True, + decode_str=False, dataset=False, describe=False): + """ + Save Stack instance to .stack file. + + Parameters + ---------- + path_stack : str + The full path to the .stack file that should be created, including + the extension. + compression : {'gzip'}, default 'gzip' + The intended compression type. + store_cache : bool, default True + Stores the MatrixCache in a file in the same location. + decode_str : bool, default=True + If True the unicoder function will be used to decode all str + objects found anywhere in the meta document/s. + dataset : bool, default=False + If True a json/csv will be saved parallel to the saved stack + for each data key in the stack. + describe : bool, default=False + If True the result of stack.describe().to_excel() will be + saved parallel to the saved stack. + + Returns + ------- + None + """ + protocol = cPickle.HIGHEST_PROTOCOL + if not path_stack.endswith('.stack'): + raise ValueError( + "To avoid ambiguity, when using Stack.save() you must provide the full path to " + "the stack file you want to create, including the file extension. For example: " + "stack.save(path_stack='./output/MyStack.stack'). Your call looks like this: " + "stack.save(path_stack='%s', ...)" % (path_stack) + ) + + # Make sure there are no str objects in any meta documents. If + # there are any non-ASCII characters will be encoded + # incorrectly and lead to UnicodeDecodeErrors in Jupyter. + if decode_str: + for dk in self.keys(): + self[dk].meta = unicoder(self[dk].meta) + + if compression is None: + f = open(path_stack, 'wb') + cPickle.dump(self, f, protocol) + else: + f = gzip.open(path_stack, 'wb') + cPickle.dump(self, f, protocol) + + if store_cache: + caches = {} + for key in self.keys(): + caches[key] = self[key].cache + + path_cache = path_stack.replace('.stack', '.cache') + if compression is None: + f1 = open(path_cache, 'wb') + cPickle.dump(caches, f1, protocol) + else: + f1 = gzip.open(path_cache, 'wb') + cPickle.dump(caches, f1, protocol) + + f1.close() + + f.close() + + if dataset: + for key in self.keys(): + path_json = path_stack.replace( + '.stack', + ' [{}].json'.format(key)) + path_csv = path_stack.replace( + '.stack', + ' [{}].csv'.format(key)) + write_quantipy( + meta=self[key].meta, + data=self[key].data, + path_json=path_json, + path_csv=path_csv) + + if describe: + path_describe = path_stack.replace('.stack', '.xlsx') + self.describe().to_excel(path_describe) + + # def get_slice(data_key=None, x=None, y=None, filters=None, views=None): + # """ """ + # pass + + # STATIC METHODS + + @staticmethod + def from_sav(data_key, filename, name=None, path=None, ioLocale="en_US.UTF-8", ioUtf8=True): + """ + Creates a new stack instance from a .sav file. + + Parameters + ---------- + data_key : str + The data_key for the data and meta in the sav file. + filename : str + The name to the sav file. + name : str + A name for the sav (stored in the meta). + path : str + The path to the sav file. + ioLocale : str + The locale used in during the sav processing. + ioUtf8 : bool + Boolean that indicates the mode in which text communicated to or + from the I/O module will be. + + Returns + ------- + stack : stack object instance + A stack instance that has a data_key with data and metadata + to run aggregations. + """ + if name is None: + name = data_key + + meta, data = parse_sav_file(filename=filename, path=path, name=name, ioLocale=ioLocale, ioUtf8=ioUtf8) + return Stack(add_data={name: {'meta': meta, 'data':data}}) + + @staticmethod + def load(path_stack, compression="gzip", load_cache=False): + """ + Load Stack instance from .stack file. + + Parameters + ---------- + path_stack : str + The full path to the .stack file that should be created, including + the extension. + compression : {'gzip'}, default 'gzip' + The compression type that has been used saving the file. + load_cache : bool, default False + Loads MatrixCache into the Stack a .cache file is found. + + Returns + ------- + None + """ + + + if not path_stack.endswith('.stack'): + raise ValueError( + "To avoid ambiguity, when using Stack.load() you must provide the full path to " + "the stack file you want to create, including the file extension. For example: " + "stack.load(path_stack='./output/MyStack.stack'). Your call looks like this: " + "stack.load(path_stack='%s', ...)" % (path_stack) + ) + + if compression is None: + f = open(path_stack, 'rb') + else: + f = gzip.open(path_stack, 'rb') + new_stack = cPickle.load(f) + f.close() + + if load_cache: + path_cache = path_stack.replace('.stack', '.cache') + if compression is None: + f = open(path_cache, 'rb') + else: + f = gzip.open(path_cache, 'rb') + caches = cPickle.load(f) + for key in caches.keys(): + if key in new_stack.keys(): + new_stack[key].cache = caches[key] + else: + raise ValueError( + "Tried to insert a loaded MatrixCache in to a data_key in the stack that" + "is not in the stack. The data_key is '{}', available keys are {}" + .format(key, caches.keys()) + ) + f.close() + + return new_stack + + + # PRIVATE METHODS + + def __get_all_y_keys(self, data_key, the_filter="no_filter"): + if(self.stack_pos == 'stack_root'): + return self[data_key].y_variables + else: + raise KeyError("get_all_y_keys can only be called from a stack at root level. Current level is '{0}'".format(self.stack_pos)) + + def __get_all_x_keys(self, data_key, the_filter="no_filter"): + if(self.stack_pos == 'stack_root'): + return self[data_key].x_variables + else: + raise KeyError("get_all_x_keys can only be called from a stack at root level. Current level is '{0}'".format(self.stack_pos)) + + def __get_all_x_keys_except(self, data_key, exception): + keys = self.__get_all_x_keys(data_key) + return [i for i in keys if i != exception[0]] + + def __get_all_y_keys_except(self, data_key, exception): + keys = self.__get_all_y_keys(data_key) + return [i for i in keys if i != exception[0]] + + def __set_x_key(self, key): + if self.x_variables is None: + self.x_variables = set(key) + else: + self.x_variables.update(key) + + def __set_y_key(self, key): + if self.y_variables is None: + self.y_variables = set(key) + else: + self.y_variables.update(key) + + def _set_x_and_y_keys(self, data_key, x, y): + """ + Sets the x_variables and y_variables in the data part of the stack for this data_key, e.g. stack['Jan']. + This method can also be used to add to the current lists and it makes sure the list stays unique. + """ + if self.stack_pos == 'stack_root': + self[data_key].__set_x_key(x) + self[data_key].__set_y_key(y) + else: + raise KeyError("set_x_keys can only be called from a stack at root level. Current level is '{0}'".format(self.stack_pos)) + + def __create_combinations(self, data, data_key, x=None, y=None, weight=None, variables=None): + if isinstance(y, str): + y = [y] + if isinstance(x, str): + x = [x] + + has_metadata = self[data_key].meta is not None and not isinstance(self[data_key].meta, Stack) + + # any(...) returns true if ANY of the vars are not None + if any([x, y]) and variables is not None: + # Raise an error if variables AND x/y are BOTH supplied + raise ValueError("Either use the 'variables' OR 'x', 'y' NOT both.") + + if not any([x, y]): + if variables is None: + if not has_metadata: + # "fully-lazy" method. (variables, x and y are all None) + variables = data.columns.tolist() + + if variables is not None: + x = variables + y = variables + variables = None + + # Ensure that we actually have metadata + if has_metadata: + # THEN we try to create the combinations with metadata + combinations = self.__create_combinations_with_meta(data=data, data_key=data_key, x=x, y=y, weight=weight) + else: + # Either variables or both x AND y are supplied. Then create the combinations from that. + combinations = self.__create_combinations_no_meta(data=data, data_key=data_key, x=x, y=y, weight=weight) + + unique_list = set([item for comb in combinations for item in comb]) + + return combinations, unique_list + + def __create_combinations_with_meta(self, data, data_key, x=None, y=None, weight=None): + # TODO: These meta functions should possibly be in the helpers functions + metadata_columns = self[data_key].meta['columns'].keys() + for mask, mask_data in self[data_key].meta['masks'].iteritems(): + # TODO :: Get the static list from somewhere. not hardcoded. + if mask_data['type'].lower() in ['array', 'dichotomous set', + "categorical set"]: + metadata_columns.append(mask) + for item in mask_data['items']: + if "source" in item: + column = item["source"].split('@')[1] + metadata_columns.remove(column) + elif mask_data['type'].lower() in ["overlay"]: + pass + # Use all from the metadata, if nothing is specified (fully-lazy) + if x is None and y is None: + x = metadata_columns + y = metadata_columns + if all([x, y]): + metadata_columns = list(set(metadata_columns + x + y)) + elif x is not None: + metadata_columns = list(set(metadata_columns + x)) + elif y is not None: + metadata_columns = list(set(metadata_columns + y)) + combinations = functions.create_combinations_from_array(sorted(metadata_columns)) + + for var in [x, y]: + if var is not None: + if weight in var: + var.remove(weight) + if all([x, y]): + combinations = [(x_item, y_item) for x_item, y_item in combinations + if x_item in x and y_item in y] + elif x is not None: + combinations = [(x_item, y_item) for x_item, y_item in combinations + if x_item in x] + elif y is not None: + combinations = [(x_item, y_item) for x_item, y_item in combinations + if y_item in y] + + return combinations + + def __create_combinations_no_meta(self, data, data_key, x=None, y=None, weight=None): + if x is None: + x = data.columns.tolist() + if y is None: + y = data.columns.tolist() + for var in [x, y]: + if weight in var: + var.remove(weight) + combinations = [(x_item, y_item) for x_item in x for y_item + in y if x_item != y_item] + self._set_x_and_y_keys(data_key, x, y) + + return combinations + + def __create_links(self, data, data_key, views, variables=None, x=None, y=None, + the_filter=None, store_view_in_link=False, weights=None): + if views is not None: + has_links = True if self[data_key][the_filter].keys() else False + if has_links: + xs = self[data_key][the_filter].keys() + if x is not None: + valid_x = [xk for xk in xs if xk in x] + valid_x.extend(x) + x = set(valid_x) + else: + x = xs + ys = list(set(itertools.chain.from_iterable( + [self[data_key][the_filter][xk].keys() + for xk in xs]))) + if y is not None: + valid_y = [yk for yk in ys if yk in y] + valid_y.extend(y) + y = set(valid_y) + else: + y = ys + if self._x_and_y_keys_in_file(data_key, data, x, y): + for x_key, y_key in itertools.product(x, y): + if x_key==y_key and x_key=='@': + continue + if y_key == '@': + if not isinstance(self[data_key][the_filter][x_key][y_key], Link): + link = Link( + the_filter=the_filter, + x=x_key, + y='@', + data_key=data_key, + stack=self, + store_view=store_view_in_link, + create_views=False + ) + self[data_key][the_filter][x_key]['@'] = link + else: + link = self[data_key][the_filter][x_key]['@'] + elif x_key == '@': + if not isinstance(self[data_key][the_filter][x_key][y_key], Link): + link = Link( + the_filter=the_filter, + x='@', + y=y_key, + data_key=data_key, + stack=self, + store_view=store_view_in_link, + create_views=False + ) + self[data_key][the_filter]['@'][y_key] = link + else: + link = self[data_key][the_filter]['@'][y_key] + else: + if not isinstance(self[data_key][the_filter][x_key][y_key], Link): + link = Link( + the_filter=the_filter, + x=x_key, + y=y_key, + data_key=data_key, + stack=self, + store_view=store_view_in_link, + create_views=False + ) + self[data_key][the_filter][x_key][y_key] = link + else: + link = self[data_key][the_filter][x_key][y_key] + if views is not None: + views._apply_to(link, weights) + + def _x_and_y_keys_in_file(self, data_key, data, x, y): + data_columns = data.columns.tolist() + if '>' in ','.join(y): y = self._clean_from_nests(y) + if '>' in ','.join(x): + raise NotImplementedError('x-axis Nesting not supported.') + x_not_found = [var for var in x if not var in data_columns + and not var == '@'] + y_not_found = [var for var in y if not var in data_columns + and not var == '@'] + if x_not_found is not None: + masks_meta_lookup_x = [var for var in x_not_found + if var in self[data_key].meta['masks'].keys()] + for found_in_meta in masks_meta_lookup_x: + x_not_found.remove(found_in_meta) + if y_not_found is not None: + masks_meta_lookup_y = [var for var in y_not_found + if var in self[data_key].meta['masks'].keys()] + for found_in_meta in masks_meta_lookup_y: + y_not_found.remove(found_in_meta) + if not x_not_found and not y_not_found: + return True + elif x_not_found and y_not_found: + raise ValueError( + 'data key {}: x: {} and y: {} not found.'.format( + data_key, x_not_found, y_not_found)) + elif x_not_found: + raise ValueError( + 'data key {}: x: {} not found.'.format( + data_key, x_not_found)) + elif y_not_found: + raise ValueError( + 'data key {}: y: {} not found.'.format( + data_key, y_not_found)) + + def _clean_from_nests(self, variables): + cleaned = [] + nests = [var for var in variables if '>' in var] + non_nests = [var for var in variables if not '>' in var] + for nest in nests: + cleaned.extend([var.strip() for var in nest.split('>')]) + non_nests += cleaned + non_nests = list(set(non_nests)) + return non_nests + + def __clean_column_names(self, columns): + """ + Remove extra doublequotes if there are any + """ + cols = [] + for column in columns: + cols.append(column.replace('"', '')) + return cols + + def __generate_key_from_list_of(self, list_of_keys): + """ + Generate keys from a list (or tuple). + """ + list_of_keys = list(list_of_keys) + list_of_keys.sort() + return ",".join(list_of_keys) + + def __has_list(self, small): + """ + Check if object contains a list of strings. + """ + keys = self.keys() + for i in xrange(len(keys)-len(small)+1): + for j in xrange(len(small)): + if keys[i+j] != small[j]: + break + else: + return i, i+len(small) + return False + + def __get_all_combinations(self, list_of_items): + """Generates all combinations of items from a list """ + return [itertools.combinations(list_of_items, index+1) + for index in range(len(list_of_items))] + + def __get_stack_pointer(self, stack_pos): + """Takes a stack_pos and returns the stack with that location + raises an exception IF the stack pointer is not found + """ + if self.parent.stack_pos == stack_pos: + return self.parent + else: + return self.parent.__get_stack_pointer(stack_pos) + + def __get_chains(self, name, data_keys, filters, x, y, views, + orientation, select, rules, + rules_weight): + """ + List comprehension wrapper around .get_chain(). + """ + if orientation == 'y': + return [ + self.get_chain( + name=name, + data_keys=data_keys, + filters=filters, + x=x, + y=y_var, + views=views, + select=select, + rules=rules, + rules_weight=rules_weight + ) + for y_var in y + ] + elif orientation == 'x': + return [ + self.get_chain( + name=name, + data_keys=data_keys, + filters=filters, + x=x_var, + y=y, + views=views, + select=select, + rules=rules, + rules_weight=rules_weight + ) + for x_var in x + ] + else: + raise ValueError( + "Unknown orientation type. Please use 'x' or 'y'." + ) + + def _verify_multiple_key_types(self, data_keys=None, filters=None, x=None, + y=None, variables=None, views=None): + """ + Verify that the given keys str or unicode or a list or tuple of those. + """ + if data_keys is not None: + self._verify_key_types(name='data', keys=data_keys) + + if filters is not None: + self._verify_key_types(name='filter', keys=filters) + + if x is not None: + self._verify_key_types(name='x', keys=x) + + if y is not None: + self._verify_key_types(name='y', keys=y) + + if variables is not None: + self._verify_key_types(name='variables', keys=variables) + + if views is not None: + self._verify_key_types(name='view', keys=views) + + def _verify_key_exists(self, key, stack_path=[]): + """ + Verify that the given key exists in the stack at the path targeted. + """ + error_msg = ( + "Could not find the {key_type} key '{key}' in: {stack_path}. " + "Found {keys_found} instead." + ) + try: + dk = stack_path[0] + fk = stack_path[1] + xk = stack_path[2] + yk = stack_path[3] + vk = stack_path[4] + except: + pass + try: + if len(stack_path) == 0: + if key not in self: + key_type, keys_found = 'data', self.keys() + stack_path = 'stack' + raise ValueError + elif len(stack_path) == 1: + if key not in self[dk]: + key_type, keys_found = 'filter', self[dk].keys() + stack_path = "stack['{dk}']".format( + dk=dk) + raise ValueError + elif len(stack_path) == 2: + if key not in self[dk][fk]: + key_type, keys_found = 'x', self[dk][fk].keys() + stack_path = "stack['{dk}']['{fk}']".format( + dk=dk, fk=fk) + raise ValueError + elif len(stack_path) == 3: + meta = self[dk].meta + if self._is_array_summary(meta, xk, None) and not key == '@': + pass + elif key not in self[dk][fk][xk]: + key_type, keys_found = 'y', self[dk][fk][xk].keys() + stack_path = "stack['{dk}']['{fk}']['{xk}']".format( + dk=dk, fk=fk, xk=xk) + raise ValueError + elif len(stack_path) == 4: + if key not in self[dk][fk][xk][yk]: + key_type, keys_found = 'view', self[dk][fk][xk][yk].keys() + stack_path = "stack['{dk}']['{fk}']['{xk}']['{yk}']".format( + dk=dk, fk=fk, xk=xk, yk=yk) + raise ValueError + except ValueError: + print error_msg.format( + key_type=key_type, + key=key, + stack_path=stack_path, + keys_found=keys_found + ) + + def _force_key_as_list(self, key): + """Returns key as [key] if it is str or unicode""" + return [key] if isinstance(key, (str, unicode)) else key + + def _verify_key_types(self, name, keys): + """ + Verify that the given keys str or unicode or a list or tuple of those. + """ + if isinstance(keys, (list, tuple)): + for key in keys: + self._verify_key_types(name, key) + elif isinstance(keys, (str, unicode)): + pass + else: + raise TypeError( + "All %s keys must be one of the following types: " + "<str> or <unicode>, " + "<list> of <str> or <unicode>, " + "<tuple> of <str> or <unicode>. " + "Given: %s" % (name, keys) + ) + + def _find_groups(self, view): + groups = OrderedDict() + logic = view._kwargs.get('logic') + description = view.describe_block() + groups['codes'] = [c for c, d in description.items() if d == 'normal'] + net_names = [v for v, d in description.items() if d == 'net'] + for l in logic: + new_l = copy.deepcopy(l) + for k in l: + if k not in net_names: + del new_l[k] + groups[new_l.keys()[0]] = new_l.values()[0] + groups['codes'] = [c for c, d in description.items() if d == 'normal'] + return groups + + def sort_expanded_nets(self, view, within=True, between=True, ascending=False, + fix=None): + if not within and not between: + return view.dataframe + df = view.dataframe + name = df.index.levels[0][0] + if not fix: + fix_codes = [] + else: + if not isinstance(fix, list): + fix_codes = [fix] + else: + fix_codes = fix + fix_codes = [c for c in fix_codes if c in + df.index.get_level_values(1).tolist()] + net_groups = self._find_groups(view) + sort_col = (df.columns.levels[0][0], '@') + sort = [(name, v) for v in df.index.get_level_values(1) + if (v in net_groups['codes'] or + v in net_groups.keys()) and not v in fix_codes] + if between: + if pd.__version__ == '0.19.2': + temp_df = df.loc[sort].sort_values(sort_col, 0, ascending=ascending) + else: + temp_df = df.loc[sort].sort_index(0, sort_col, ascending=ascending) + else: + temp_df = df.loc[sort] + between_order = temp_df.index.get_level_values(1).tolist() + code_group_list = [] + for g in between_order: + if g in net_groups: + code_group_list.append([g] + net_groups[g]) + elif g in net_groups['codes']: + code_group_list.append([g]) + final_index = [] + for g in code_group_list: + is_code = len(g) == 1 + if not is_code: + fixed_net_name = g[0] + sort = [(name, v) for v in g[1:]] + if within: + if pd.__version__ == '0.19.2': + temp_df = df.loc[sort].sort_values(sort_col, 0, ascending=ascending) + else: + temp_df = df.loc[sort].sort_index(0, sort_col, ascending=ascending) + else: + temp_df = df.loc[sort] + new_idx = [fixed_net_name] + temp_df.index.get_level_values(1).tolist() + final_index.extend(new_idx) + else: + final_index.extend(g) + final_index = [(name, i) for i in final_index] + if fix_codes: + fix_codes = [(name, f) for f in fix_codes] + final_index.extend(fix_codes) + df = df.reindex(final_index) + return df + + def get_frequency_via_stack(self, data_key, the_filter, col, weight=None): + weight_notation = '' if weight is None else weight + vk = 'x|f|:||{}|counts'.format(weight_notation) + try: + f = self[data_key][the_filter][col]['@'][vk].dataframe + except (KeyError, AttributeError) as e: + try: + f = self[data_key][the_filter]['@'][col][vk].dataframe.T + except (KeyError, AttributeError) as e: + f = frequency(self[data_key].meta, self[data_key].data, x=col, weight=weight) + return f + + def get_descriptive_via_stack(self, data_key, the_filter, col, weight=None): + l = self[data_key][the_filter][col]['@'] + w = '' if weight is None else weight + mean_key = [k for k in l.keys() if 'd.mean' in k.split('|')[1] and + k.split('|')[-2] == w] + if not mean_key: + msg = "No mean view to sort '{}' on found!" + raise RuntimeError(msg.format(col)) + elif len(mean_key) > 1: + msg = "Multiple mean views found for '{}'. Unable to sort!" + raise RuntimeError(msg.format(col)) + else: + mean_key = mean_key[0] + vk = mean_key + d = l[mean_key].dataframe + return d + + def _is_array_summary(self, meta, x, y): + return x in meta['masks'] + + def _is_transposed_summary(self, meta, x, y): + return x == '@' and y in meta['masks'] + + def axis_slicer_from_vartype(self, all_rules_axes, rules_axis, dk, the_filter, x, y, rules_weight): + if rules_axis == 'x' and 'x' not in all_rules_axes: + return None + elif rules_axis == 'y' and 'y' not in all_rules_axes: + return None + meta = self[dk].meta + + array_summary = self._is_array_summary(meta, x, y) + transposed_summary = self._is_transposed_summary(meta, x, y) + + axis_slicer = None + + if rules_axis == 'x': + if not array_summary and not transposed_summary: + axis_slicer = self.get_rules_slicer_via_stack( + dk, the_filter, x=x, weight=rules_weight) + elif array_summary: + axis_slicer = self.get_rules_slicer_via_stack( + dk, the_filter, x=x, y='@', weight=rules_weight, + slice_array_items=True) + elif transposed_summary: + axis_slicer = self.get_rules_slicer_via_stack( + dk, the_filter, x='@', y=y, weight=rules_weight) + elif rules_axis == 'y': + if not array_summary and not transposed_summary: + axis_slicer = self.get_rules_slicer_via_stack( + dk, the_filter, y=y, weight=rules_weight) + elif array_summary: + axis_slicer = self.get_rules_slicer_via_stack( + dk, the_filter, x=x, y='@', weight=rules_weight, + slice_array_items=False) + elif transposed_summary: + axis_slicer = self.get_rules_slicer_via_stack( + dk, the_filter, x='@', y=y, weight=rules_weight) + + return axis_slicer + + def get_rules_slicer_via_stack(self, data_key, the_filter, + x=None, y=None, weight=None, + slice_array_items=False): + m = self[data_key].meta + array_summary = self._is_array_summary(m, x, y) + transposed_summary = self._is_transposed_summary(m, x, y) + + rules = None + + if not array_summary and not transposed_summary: + if not x is None: + try: + rules = self[data_key].meta['columns'][x]['rules']['x'] + col = x + except: + pass + elif not y is None: + try: + rules = self[data_key].meta['columns'][y]['rules']['y'] + col = y + except: + pass + + elif array_summary: + if slice_array_items: + try: + rules = self[data_key].meta['masks'][x]['rules']['x'] + col = x + except: + pass + else: + try: + rules = self[data_key].meta['masks'][x]['rules']['y'] + col = x + except: + pass + + elif transposed_summary: + try: + rules = self[data_key].meta['masks'][y]['rules']['x'] + col = y + except: + pass + + if not rules: return None + views = self[data_key][the_filter][col]['@'].keys() + w = '' if weight is None else weight + expanded_net = [v for v in views if '}+]' in v + and v.split('|')[-2] == w + and v.split('|')[1] == 'f' and + not v.split('|')[3] == 'x'] + if expanded_net: + if len(expanded_net) > 1: + if len(expanded_net) == 2: + if expanded_net[0].split('|')[2] == expanded_net[1].split('|')[2]: + expanded_net = expanded_net[0] + else: + msg = "Multiple 'expand' using views found for '{}'. Unable to sort!" + raise RuntimeError(msg.format(col)) + else: + expanded_net = expanded_net[0] + if 'sortx' in rules: + on_mean = rules['sortx'].get('sort_on', '@') == 'mean' + else: + on_mean = False + if 'sortx' in rules and on_mean: + f = self.get_descriptive_via_stack( + data_key, the_filter, col, weight=weight) + elif 'sortx' in rules and expanded_net: + within = rules['sortx'].get('within', False) + between = rules['sortx'].get('between', False) + fix = rules['sortx'].get('fixed', False) + ascending = rules['sortx'].get('ascending', False) + view = self[data_key][the_filter][col]['@'][expanded_net] + f = self.sort_expanded_nets(view, between=between, within=within, + ascending=ascending, fix=fix) + else: + f = self.get_frequency_via_stack( + data_key, the_filter, col, weight=weight) + + if transposed_summary or (not slice_array_items and array_summary): + rules_slicer = functions.get_rules_slicer(f.T, rules) + else: + if not expanded_net or ('sortx' in rules and on_mean): + rules_slicer = functions.get_rules_slicer(f, rules) + else: + rules_slicer = f.index.values.tolist() + try: + rules_slicer.remove((col, 'All')) + except: + pass + return rules_slicer + + @modify(to_list='batches') + def _check_batches(self, dk, batches='all'): + """ + Returns a list of valid ``qp.Batch`` names. + + Parameters + ---------- + batches: str/ list of str, default 'all' + Included names are checked against valid ``qp.Batch`` names. If + batches='all', all valid ``Batch`` names are returned. + + Returns + ------- + list of str + """ + if not batches: + return [] + elif batches[0] == 'all': + return self[dk].meta['sets']['batches'].keys() + else: + valid = self[dk].meta['sets']['batches'].keys() + not_valid = [b for b in batches if not b in valid] + if not_valid: + msg = '``Batch`` name not found in ``Stack``: {}' + raise KeyError(msg.format(not_valid)) + return batches + + def _x_y_f_w_map(self, dk, batches='all'): + """ + """ + def _append_loop(mapping, x, fi, w, ys): + if fi: fi = fi.encode('utf8') + fn = 'no_filter' if fi is None else fi + f = 'no_filter' if fi is None else {fi: {fi: 0}} + if not x in mapping: + mapping[x] = {fn: {'f': f, tuple(w): ys}} + elif not fn in mapping[x]: + mapping[x][fn] = {'f': f, tuple(w): ys} + elif not tuple(w) in mapping[x][fn]: + mapping[x][fn][tuple(w)] = ys + elif not all(y in mapping[x][fn][tuple(w)] for y in ys): + yks = set(mapping[x][fn][tuple(w)]).union(set(ys)) + mapping[x][fn][tuple(w)] = list(yks) + return None + + arrays = self.variable_types(dk, verbose=False)['array'] + mapping = {} + y_on_y = {} + batches = self._check_batches(dk, batches) + for batch in batches: + b = self[dk].meta['sets']['batches'][batch] + xy = b['x_y_map'] + f = b['x_filter_map'] + fy = b['y_filter_map'] + w = b['weights'] + for x, y in xy: + if x == '@': + y = y[0] + _append_loop(mapping, x, f[y], w, [y]) + else: + _append_loop(mapping, x, f[x], w, y) + for yy in b['y_on_y']: + for x in b['yks'][1:]: + _append_loop(mapping, x, fy[yy], w, b['yks']) + _append_loop(y_on_y, x, fy[yy], w, b['yks']) + return mapping, y_on_y + + @modify(to_list=['views', 'categorize', 'xs', 'batches']) + def aggregate(self, views, unweighted_base=True, categorize=[], + batches='all', xs=None, bases={}, verbose=True): + + """ + Add views to all defined ``qp.Link`` in ``qp.Stack``. + + Parameters + ---------- + views: str or list of str or qp.ViewMapper + ``views`` that are added. + unweighted_base: bool, default True + If True, unweighted 'cbase' is added to all non-arrays. + This parameter will be deprecated in future, please use bases + instead. + categorize: str or list of str + Determines how numerical data is handled: If provided, the + variables will get counts and percentage aggregations + (``'counts'``, ``'c%'``) alongside the ``'cbase'`` view. If False, + only ``'cbase'`` views are generated for non-categorical types. + batches: str/ list of str, default 'all' + Name(s) of ``qp.Batch`` instance(s) that are used to aggregate the + ``qp.Stack``. + xs: list of str + Names of variable, for which views are added. + bases: dict + Defines which bases should be aggregated, weighted or unweighted. + + Returns + ------- + None, modify ``qp.Stack`` inplace + """ + # Preparing bases if older version with unweighed_base is used + valid_bases = ['cbase', 'cbase_gross', 'ebase'] + if not bases and any(v in valid_bases for v in views): + new_bases = {} + for ba in valid_bases: + if ba in views: + new_bases[ba] = {'unwgt': False if ba=='ebase' else unweighted_base, + 'wgt': True} + views = [v for v in views if not v in valid_bases] + else: + new_bases = bases + + # Check if views are complete + if views and isinstance(views[0], ViewMapper): + views = views[0] + complete = views[views.keys()[0]]['kwargs'].get('complete', False) + elif any('cumsum' in v for v in views): + complete = True + else: + complete = False + + # get counts + net views + count_net_views = ['counts', 'counts_sum', 'counts_cumsum'] + if isinstance(views, ViewMapper) and views.keys() == ['net']: + counts_nets = qp.ViewMapper() + counts_nets.make_template('frequency', {'rel_to': [None, 'y']}) + options = {'logic': views['net']['kwargs']['logic'], + 'axis': 'x', + 'expand': views['net']['kwargs']['expand'], + 'complete': views['net']['kwargs']['complete'], + 'calc': views['net']['kwargs']['calc']} + counts_nets.add_method('net', kwargs=options) + else: + counts_nets = [v for v in views if v in count_net_views] + + x_in_stack = self.describe('x').index.tolist() + for dk in self.keys(): + batches = self._check_batches(dk, batches) + if not batches: return None + # check for unweighted_counts + batch = self[dk].meta['sets']['batches'] + unwgt_c = any(batch[b].get('unwgt_counts') for b in batches) + # get map and conditions for aggregation + x_y_f_w_map, y_on_y = self._x_y_f_w_map(dk, batches) + if not xs: + xs = [x for x in x_y_f_w_map.keys() if x in x_in_stack] + else: + xs = [x for x in xs if x in x_in_stack or isinstance(x, tuple)] + + v_typ = self.variable_types(dk, verbose=False) + numerics = v_typ['int'] + v_typ['float'] + masks = self[dk].meta['masks'] + num_arrays = [m for m in masks if masks[m]['subtype'] in ['int', 'float']] + if num_arrays: numerics = numerics + num_arrays + skipped = [x for x in xs if (x in numerics and not x in categorize) + and not isinstance(x, tuple)] + total_len = len(xs) + # loop over map and aggregate views + if total_len == 0: + msg = "Cannot aggregate, 'xs' contains no valid variables." + raise ValueError(msg) + for idx, x in enumerate(xs, start=1): + y_trans = None + if isinstance(x, tuple): + y_trans = x[1] + x = x[0] + if not x in x_y_f_w_map.keys(): + msg = "Cannot find {} in qp.Stack for ``qp.Batch`` '{}'" + raise KeyError(msg.format(x, batches)) + v = [] if x in skipped else views + for f_dict in x_y_f_w_map[x].values(): + f = f_dict['f'] + f_key = f.keys()[0] if isinstance(f, dict) else f + for weight, y in f_dict.items(): + if weight == 'f': continue + if y_trans: y = y_trans + w = list(weight) if weight else None + # add bases + for ba, weights in new_bases.items(): + ba_w = [b_w for b_w in w if not b_w is None] + if weights.get('wgt') and ba_w: + self.add_link(dk, f, x=x, y=y, views=[ba], weights=ba_w) + if (weights.get('wgt') and not ba_w) or weights.get('unwgt'): + self.add_link(dk, f, x=x, y=y, views=[ba], weights=None) + # remove existing nets for link if new view is a net + if isinstance(v, ViewMapper) and v.get('net') and not y_trans: + for ys in y: + link = self[dk][f_key][x][ys] + for view in link.keys(): + is_net = view.split('|')[-1] == 'net' + has_w = view.split('|')[-2] + if not has_w: has_w = None + if is_net and has_w in f_dict.keys(): + del link[view] + # add unweighted views for counts/ nets + if unwgt_c and counts_nets and not None in w: + self.add_link(dk, f, x=x, y=y, views=counts_nets, weights=None) + # add common views + self.add_link(dk, f, x=x, y=y, views=v, weights=w) + # remove views if complete (cumsum/ nets) + if complete: + for ys in y: + y_on_ys = y_on_y.get(x, {}).get(f_key, {}).get(tuple(w), []) + if ys in y_on_ys: continue + link = self[dk][f_key][x][ys] + for ws in w: + pct = 'x|f|:|y|{}|c%'.format('' if not ws else ws) + counts = 'x|f|:||{}|counts'.format('' if not ws else ws) + for view in [pct, counts]: + if view in link: + del link[view] + if verbose: + done = float(idx) / float(total_len) *100 + print '\r', + time.sleep(0.01) + print 'Stack [{}]: {} %'.format(dk, round(done, 1)), + sys.stdout.flush() + print '\n' + + if skipped and verbose: + msg = ("\n\nWarning: Found {} non-categorized numeric variable(s): {}.\n" + "Descriptive statistics must be added!") + print msg.format(len(skipped), skipped) + return None + + @modify(to_list=['on_vars', '_batches']) + def cumulative_sum(self, on_vars, _batches='all', verbose=True): + """ + Add cumulative sum view to a specified collection of xks of the stack. + + Parameters + ---------- + on_vars : list + The list of x variables to add the view to. + _batches: str or list of str + Only for ``qp.Links`` that are defined in this ``qp.Batch`` + instances views are added. + + Returns + ------- + None + The stack instance is modified inplace. + """ + for dk in self.keys(): + _batches = self._check_batches(dk, _batches) + if not _batches or not on_vars: return None + meta = self[dk].meta + data = self[dk].data + for v in on_vars: + if v in meta['sets']: + items = [i.split('@')[-1] for i in meta['sets'][v]['items']] + on_vars = list(set(on_vars + items)) + + self.aggregate(['counts_cumsum', 'c%_cumsum'], False, [], _batches, on_vars, verbose=verbose) + return None + + def _add_checking_chain(self, dk, cluster, name, x, y, views): + key, view, c_view = views + if isinstance(cluster, ChainManager): + c_stack = cluster.stack + else: + c_stack = qp.Stack('checks') + c_stack.add_data('checks', data=self[dk].data, meta=self[dk].meta) + c_stack.add_link(x=x, y=y, views=view, weights=None) + c_stack.add_link(x=x, y=y, views=c_view, weights=None) + c_views = c_stack.describe('view').index.tolist() + len_v_keys = len(view) + view_keys = ['x|f|x:|||cbase', 'x|f|:|||counts'][0:len_v_keys] + c_views = view_keys + [v for v in c_views + if v.endswith('{}_check'.format(key))] + if isinstance(cluster, ChainManager): + cluster.get('checks', 'no_filter', x, y, c_views, folder=name, rules=False) + else: + if name == 'stat_check': + chain = c_stack.get_chain(x=x, y=y, views=c_views, orient_on='x') + name = [v for v in c_views if v.endswith('{}_check'.format(key))][0] + cluster[name] = chain + else: + chain = c_stack.get_chain(name=name, x=x, y=y, views=c_views) + cluster.add_chain(chain) + return cluster + + @staticmethod + def recode_from_net_def(dataset, on_vars, net_map, expand, recode='auto', + text_prefix='Net:', mis_in_rec=False, + verbose=True): + """ + Create variables from net definitions. + """ + def _is_simple_net(net_map): + return all(isinstance(net.values()[0], list) for net in net_map) + + def _dissect_defs(ds, var, net_map, recode, text_prefix): + mapper = [] + if recode == 'extend_codes': + mapper += [(x, y, {var: x}) for (x,y) in ds.values(var)] + max_code = max(ds.codes(var)) + elif recode == 'drop_codes': + max_code = 0 + elif 'collect_codes' in recode: + max_code = 0 + + appends = [] + labels = {} + s_net = True + simple_nets = [] + for x, net in enumerate(net_map, 1): + n = copy.deepcopy(net) + if net.get('text'): + labs = n.pop('text') + else: + labs = {ds.text_key: n.keys()[0]} + code = max_code + x + for tk, lab in labs.items(): + if not tk in labels: labels[tk] = {} + labels[tk].update({code: '{} {}'.format(text_prefix, lab)}) + appends.append((code, str(code), {var: n.values()[0]})) + if not isinstance(n.values()[0], list): + s_net = False + simple_nets = [] + if s_net: + simple_nets.append( + ('{} {}'.format(text_prefix, labs[ds.text_key]), n.values()[0])) + mapper += appends + q_type = 'delimited set' if ds._is_delimited_set_mapper(mapper) else 'single' + return mapper, q_type, labels, simple_nets + + forced_recode = False + valid = ['extend_codes', 'drop_codes', 'collect_codes'] + if recode == 'auto': + recode = 'collect_codes' + forced_recode = True + if not any(rec in recode for rec in valid): + raise ValueError("'recode' must be one of {}".format(valid)) + + dataset._meta['sets']['to_array'] = {} + for var in on_vars[:]: + if dataset.is_array(var): continue + # get name for new variable + suffix = '_rc' + for s in [str(x) if not x == 1 else '' for x in frange('1-5')]: + suf = suffix + s + name = '{}{}'.format(dataset._dims_free_arr_item_name(var), suf) + if dataset.var_exists(name): + if dataset._meta['columns'][name]['properties'].get('recoded_net'): + break + else: + break + + # collect array items + if dataset._is_array_item(var): + to_array_set = dataset._meta['sets']['to_array'] + parent = dataset._maskname_from_item(var) + arr_name = dataset._dims_free_arr_name(parent) + suf + if arr_name in dataset: + msg = "Cannot create array {}. Variable already exists!" + if not dataset.get_property(arr_name, 'recoded_net'): + raise ValueError(msg.format(arr_name)) + no = dataset.item_no(var) + if not arr_name in to_array_set: + to_array_set[arr_name] = [parent, [name], [no]] + else: + to_array_set[arr_name][1].append(name) + to_array_set[arr_name][2].append(no) + + # create mapper to derive new variable + mapper, q_type, labels, simple_nets = _dissect_defs( + dataset, var, net_map, recode, text_prefix) + dataset.derive(name, q_type, dataset.text(var), mapper) + + # meta edits for new variable + for tk, labs in labels.items(): + dataset.set_value_texts(name, labs, tk) + text = dataset.text(var, tk) or dataset.text(var, None) + dataset.set_variable_text(name, text, tk) + + # properties + props = dataset._meta['columns'][name]['properties'] + props.update({'recoded_net': var}) + if 'properties' in dataset._meta['columns'][var]: + for pname, prop in dataset._meta['columns'][var]['properties'].items(): + if pname == 'survey': continue + props[pname] = prop + if simple_nets: + props['simple_org_expr'] = simple_nets + + if verbose: + print 'Created: {}'. format(name) + if forced_recode: + warnings.warn("'{}' was a forced recode.".format(name)) + + # order, remove codes + if 'collect_codes' in recode: + if not mis_in_rec and dataset._get_missing_list(var): + other_logic = intersection([ + {var: not_count(0)}, + {name: has_count(0)}, + {var: not_any(dataset._get_missing_list(var))}]) + else: + other_logic = intersection( + [{var: not_count(0)}, {name: has_count(0)}]) + if dataset._is_array_item(var) or dataset.take(other_logic).tolist(): + cat_name = recode.split('@')[-1] if '@' in recode else 'Other' + code = len(mapper)+1 + dataset.extend_values(name, [(code, str(code))]) + for tk in labels.keys(): + dataset.set_value_texts(name, {code: cat_name}, tk) + dataset.recode(name, {code: other_logic}) + if recode == 'extend_codes' and expand: + codes = dataset.codes(var) + new = [c for c in dataset.codes(name) if not c in codes] + order = [] + remove = [] + for x, y, z in mapper[:]: + if not x in new: + order.append(x) + else: + vals = z.values()[0] + if not isinstance(vals, list): + remove.append(vals) + vals = [vals] + if expand == 'after': + idx = order.index(codes[min([codes.index(v) for v in vals])]) + elif expand == 'before': + idx = order.index(codes[max([codes.index(v) for v in vals])]) + 1 + order.insert(idx, x) + + dataset.reorder_values(name, order) + dataset.remove_values(name, remove) + + for arr_name, arr_items in dataset._meta['sets']['to_array'].items(): + org_mask = arr_items[0] + m_items = arr_items[1] + m_order = arr_items[2] + m_items = [item[1] for item in sorted(zip(m_order, m_items))] + dataset.to_array(arr_name, m_items, '', False) + dims_name = dataset._dims_compat_arr_name(arr_name) + prop = dataset._meta['masks'][dims_name]['properties'] + prop['recoded_net'] = org_mask + if 'properties' in dataset._meta['masks'][org_mask]: + for p, v in dataset._meta['masks'][org_mask]['properties'].items(): + if p == 'survey': continue + prop[p] = v + n_i0 = dataset.sources(dims_name)[0] + simple_net = dataset._meta['columns'][n_i0]['properties'].get('simple_org_expr') + if simple_net: + dataset._meta['masks'][dims_name]['properties'].update( + {'simple_org_expr': simple_net}) + if verbose: + msg = "Array {} built from recoded view variables!" + print msg.format(dims_name) + del dataset._meta['sets']['to_array'] + + return None + + + @modify(to_list=['on_vars', '_batches']) + def add_nets(self, on_vars, net_map, expand=None, calc=None, rebase=None, + text_prefix='Net:', checking_cluster=None, _batches='all', + recode='auto', mis_in_rec=False, verbose=True): + """ + Add a net-like view to a specified collection of x keys of the stack. + + Parameters + ---------- + on_vars : list + The list of x variables to add the view to. + net_map : list of dicts + The listed dicts must map the net/band text label to lists of + categorical answer codes to group together, e.g.: + + >>> [{'Top3': [1, 2, 3]}, + ... {'Bottom3': [4, 5, 6]}] + It is also possible to provide enumerated net definition dictionaries + that are explicitly setting ``text`` metadata per ``text_key`` entries: + + >>> [{1: [1, 2], 'text': {'en-GB': 'UK NET TEXT', + ... 'da-DK': 'DK NET TEXT', + ... 'de-DE': 'DE NET TEXT'}}] + expand : {'before', 'after'}, default None + If provided, the view will list the net-defining codes after or before + the computed net groups (i.e. "overcode" nets). + calc : dict, default None + A dictionary that is attaching a text label to a calculation expression + using the the net definitions. The nets are referenced as per + 'net_1', 'net_2', 'net_3', ... . + Supported calculation expressions are add, sub, div, mul. Example: + + >>> {'calc': ('net_1', add, 'net_2'), 'text': {'en-GB': 'UK CALC LAB', + ... 'da-DK': 'DA CALC LAB', + ... 'de-DE': 'DE CALC LAB'}} + rebase : str, default None + Use another variables margin's value vector for column percentage + computation. + text_prefix : str, default 'Net:' + By default each code grouping/net will have its ``text`` label prefixed + with 'Net: '. Toggle by passing None (or an empty str, ''). + checking_cluster : quantipy.Cluster, default None + When provided, an automated checking aggregation will be added to the + ``Cluster`` instance. + _batches: str or list of str + Only for ``qp.Links`` that are defined in this ``qp.Batch`` + instances views are added. + recode: {'extend_codes', 'drop_codes', 'collect_codes', 'collect_codes@cat_name'}, + default 'auto' + Adds variable with nets as codes to DataSet/Stack. If 'extend_codes', + codes are extended with nets. If 'drop_codes', new variable only + contains nets as codes. If 'collect_codes' or 'collect_codes@cat_name' + the variable contains nets and another category that summarises all + codes which are not included in any net. If no cat_name is provided, + 'Other' is taken as default + mis_in_rec: bool, default False + Skip or include codes that are defined as missing when recoding + from net definition. + Returns + ------- + None + The stack instance is modified inplace. + """ + + def _netdef_from_map(net_map, expand, prefix, text_key): + netdef = [] + for no, net in enumerate(net_map, start=1): + if 'text' in net: + logic = net[no] + text = net['text'] + else: + logic = net.values()[0] + text = {t: net.keys()[0] for t in text_key} + if not isinstance(logic, list) and isinstance(logic, int): + logic = [logic] + if prefix and not expand: + text = {k: '{} {}'.format(prefix, v) for k, v in text.items()} + if expand: + text = {k: '{} (NET)'.format(v) for k, v in text.items()} + netdef.append({'net_{}'.format(no): logic, 'text': text}) + return netdef + + def _check_and_update_calc(calc_expression, text_key): + if not isinstance(calc_expression, dict): + err_msg = ("'calc' must be a dict in form of\n" + "{'calculation label': (net # 1, operator, net # 2)}") + raise TypeError(err_msg) + for k, v in calc_expression.items(): + if not k in ['text', 'calc_only']: exp = v + if not k == 'calc_only': text = v + if not 'text' in calc_expression: + text = {tk: text for tk in text_key} + calc_expression['text'] = text + if not isinstance(exp, (tuple, list)) or len(exp) != 3: + err_msg = ("Not properly formed expression found in 'calc':\n" + "{}\nMust be provided as (net # 1, operator, net # 2)") + raise TypeError(err_msg.format(exp)) + return calc_expression + + for dk in self.keys(): + _batches = self._check_batches(dk, _batches) + only_recode = not _batches and recode + if not _batches and not recode: return None + meta = self[dk].meta + data = self[dk].data + check_on = [] + for v in on_vars[:]: + if v in meta['sets']: + items = [i.split('@')[-1] for i in meta['sets'][v]['items']] + on_vars = list(set(on_vars)) + items + check_on.append(items[0]) + elif meta['columns'][v].get('parent'): + msg = 'Nets can not be added to a single array item: {}' + raise ValueError(msg.format(v)) + else: + check_on.append(v) + for b in _batches: + batch = meta['sets']['batches'][b] + transposed = batch.get('transposed_arrays', batch['transposed']) + if v in transposed: + on_vars += [('@', v)] + break + if not only_recode: + all_batches = copy.deepcopy(meta['sets']['batches']) + for n, b in all_batches.items(): + if not n in _batches: all_batches.pop(n) + languages = list(set(b['language'] for n, b in all_batches.items())) + netdef = _netdef_from_map(net_map, expand, text_prefix, languages) + if calc: + calc = _check_and_update_calc(calc, languages) + calc_only = calc.get('calc_only', False) + else: + calc_only = False + view = qp.ViewMapper() + if not rebase: + view.make_template('frequency', {'rel_to': [None, 'y']}) + else: + rebase = '{}.base'.format(rebase) + view.make_template('frequency', {'rel_to': [None, rebase]}) + options = {'logic': netdef, + 'axis': 'x', + 'expand': expand if expand in ['after', 'before'] else None, + 'complete': True if expand else False, + 'calc': calc, + 'calc_only': calc_only} + view.add_method('net', kwargs=options) + self.aggregate(view, False, [], _batches, on_vars, verbose=verbose) + + if recode: + ds = ds = qp.DataSet(dk, dimensions_comp=meta['info'].get('dimensions_comp')) + ds.from_stack(self, dk) + on_vars = [x for x in on_vars if x in self.describe('x').index.tolist()] + self.recode_from_net_def(ds, on_vars, net_map, expand, recode, + text_prefix, mis_in_rec, + verbose) + + if checking_cluster in [None, False] or only_recode: continue + if isinstance(checking_cluster, ChainManager): + cc_keys = checking_cluster.folder_names + else: + cc_keys = checking_cluster.keys() + view['net_check'] = view.pop('net') + view['net_check']['kwargs']['iterators'].pop('rel_to') + for v in check_on: + v_net = '{}_net'.format(v) + v_net = v_net.split('.')[-1] + if not v_net in cc_keys: + checking_cluster = self._add_checking_chain(dk, checking_cluster, + v_net, v, ['@', v], ('net', ['cbase'], view)) + + return None + + @staticmethod + def _factor_labs(values, axis, rescale, drop, exclude, factor_labels, + has_factors): + if not rescale: rescale = {} + ignore = [v['value'] for v in values if v['value'] in exclude or + (not v['value'] in rescale.keys() and drop)] + if factor_labels == '()': + new_lab = '{} ({})' + split = ('(', ')') + else: + new_lab = '{} [{}]' + split = ('[', ']') + factors_mapped = {} + for v in values: + if v['value'] in ignore: continue + has_xedits = v['text'].get('x edits', {}) + has_yedits = v['text'].get('y edits', {}) + if not has_xedits: v['text']['x edits'] = {} + if not has_yedits: v['text']['y edits'] = {} + + factor = rescale[v['value']] if rescale else v['value'] + for tk, text in v['text'].items(): + if tk in ['x edits', 'y edits']: continue + for ax in axis: + try: + t = v['text']['{} edits'.format(ax)][tk] + except: + t = text + if has_factors: + fac = t.split(split[0])[-1].replace(split[1], '') + if fac == str(factor): continue + v['text']['{} edits'.format(ax)][tk] = new_lab.format(t, factor) + return values + + @staticmethod + def _add_factor_meta(dataset, var, options): + if not dataset._has_categorical_data(var): + return None + rescale = options[0] + drop = options[1] + exclude = options[2] + dataset.clear_factors(var) + all_codes = dataset.codes(var) + if rescale: + fm = rescale + else: + fm = {c: c for c in all_codes} + if not drop and rescale: + for c in all_codes: + if not c in fm: + fm[c] = c + if exclude: + for e in exclude: + if e in fm: + del fm[e] + dataset.set_factors(var, fm) + return None + + @modify(to_list=['on_vars', 'stats', 'exclude', '_batches']) + def add_stats(self, on_vars, stats=['mean'], other_source=None, rescale=None, + drop=True, exclude=None, factor_labels=True, custom_text=None, + checking_cluster=None, _batches='all', recode=False, verbose=True): + """ + Add a descriptives view to a specified collection of xks of the stack. + + Valid descriptives views: {'mean', 'stddev', 'min', 'max', 'median', 'sem'} + + Parameters + ---------- + on_vars : list + The list of x variables to add the view to. + stats : list of str, default ``['mean']`` + The metrics to compute and add as a view. + other_source : str + If provided the Link's x-axis variable will be swapped with the + (numerical) variable provided. This can be used to attach statistics + of a different variable to a Link definition. + rescale : dict + A dict that maps old to new codes, e.g. {1: 5, 2: 4, 3: 3, 4: 2, 5: 1} + drop : bool, default True + If ``rescale`` is provided all codes that are not mapped will be + ignored in the computation. + exclude : list + Codes/values to ignore in the computation. + factor_labels : bool / str, default True + Writes the (rescaled) factor values next to the category text label. + If True, square-brackets are used. If '()', normal brackets are used. + custom_text : str, default None + A custom string affix to put at the end of the requested statistics' + names. + checking_cluster : quantipy.Cluster, default None + When provided, an automated checking aggregation will be added to the + ``Cluster`` instance. + _batches: str or list of str + Only for ``qp.Links`` that are defined in this ``qp.Batch`` + instances views are added. + recode: bool, default False + Create a new variable that contains only the values + which are needed for the stat computation. The values and the included + data will be rescaled. + + Returns + ------- + None + The stack instance is modified inplace. + """ + + def _recode_from_stat_def(dataset, on_vars, rescale, drop, exclude, verbose): + for var in on_vars: + if dataset.is_array(var): continue + suffix = '_rc' + for s in [str(x) if not x == 1 else '' for x in frange('1-5')]: + suf = suffix + s + name = '{}{}'.format(var, suf) + if dataset.var_exists(name): + if dataset._meta['columns'][name]['properties'].get('recoded_stat'): + break + else: + break + if not rescale: + rescale = {x: x for x in dataset.codes(var)} + else: + rescale = copy.deepcopy(rescale) + if drop or exclude: + for x in rescale.keys(): + if not x in dataset.codes(var) or x in exclude: + rescale.pop(x) + dataset.add_meta(name, 'float', dataset.text(var)) + for x, y in rescale.items(): + sl = dataset.take({var: x}) + dataset[sl, name] = y + if verbose: + print 'Created: {}'. format(name) + dataset._meta['columns'][name]['properties'].update({'recoded_stat': var}) + return None + + def _add_factors(v, meta, values, args): + if isinstance(values, basestring): + p = values.split('@')[-1] + p_meta = meta.get('masks', meta)[p] + p_lib = meta['lib'].get('values', meta['lib']) + has_factors = p_meta.get('properties', {}).get('factor_labels', False) + v_args = args + [has_factors] + values = p_lib[p] + p_lib[p] = self._factor_labs(values, ['x', 'y'], *v_args) + if not p_meta.get('properties'): p_meta['properties'] = {} + p_meta['properties'].update({'factor_labels': True}) + else: + v_meta = meta.get('columns', meta)[v] + has_factors = v_meta.get('properties', {}).get('factor_labels') + v_args = args + [has_factors] + v_meta['values'] = self._factor_labs(values, ['x'], *v_args) + if not v_meta.get('properties'): v_meta['properties'] = {} + v_meta['properties'].update({'factor_labels': True}) + return None + + if other_source and not isinstance(other_source, str): + raise ValueError("'other_source' must be a str!") + if not rescale: drop = False + + options = {'stats': '', + 'source': other_source, + 'rescale': rescale, + 'drop': drop, 'exclude': exclude, + 'axis': 'x', + 'text': '' if not custom_text else custom_text} + warn = "\nCannot add stats on '{}'.\n" + for dk in self.keys(): + _batches = self._check_batches(dk, _batches) + if not _batches: return None + meta = self[dk].meta + data = self[dk].data + check_on = [] + no_os = not other_source + for v in on_vars: + if v in meta['sets']: + if meta['masks'][v]['subtype'] == 'delimited set' and no_os: + w = warn + 'Stats are not valid on delimited sets!\n' + print w.format(v) + continue + items = [i.split('@')[-1] for i in meta['sets'][v]['items']] + on_vars = list(set(on_vars + items)) + check_on = list(set(check_on + [items[0]])) + elif not meta['columns'][v].get('values'): + w = warn + 'No values found!\n' + print w.format(v) + continue + elif meta['columns'][v]['type'] == 'delimited set' and no_os: + w = warn + 'Stats are not valid on delimited sets!\n' + print w.format(v) + continue + elif not isinstance(meta['columns'][v]['values'], list): + parent = meta['columns'][v]['parent'].keys()[0].split('@')[-1] + items = [i.split('@')[-1] for i in meta['sets'][parent]['items']] + check_on = list(set(check_on + [items[0]])) + else: + check_on = list(set(check_on + [v])) + for b in _batches: + batch = meta['sets']['batches'][b] + transposed = batch.get('transposed_arrays', batch['transposed']) + if v in transposed: + on_vars += [('@', v)] + break + + ds = qp.DataSet(dk, dimensions_comp=meta['info'].get('dimensions_comp')) + ds.from_stack(self, dk) + if not other_source: + self._add_factor_meta(ds, v, (rescale, drop, exclude)) + + + view = qp.ViewMapper() + view.make_template('descriptives') + for stat in stats: + options['stats'] = stat + view.add_method('stat', kwargs=options) + self.aggregate(view, False, on_vars, _batches, on_vars, verbose=verbose) + + if recode: + if other_source: + raise ValueError('Cannot recode if other_source is provided.') + ds = qp.DataSet(dk, dimensions_comp=meta['info'].get('dimensions_comp')) + ds.from_stack(self, dk) + on_vars = [x for x in on_vars if x in self.describe('x').index.tolist()] + _recode_from_stat_def(ds, on_vars, rescale, drop, exclude, verbose) + + if factor_labels: + args = [rescale, drop, exclude, factor_labels] + all_batches = meta['sets']['batches'].keys() + if not _batches: _batches = all_batches + batches = [b for b in all_batches if b in _batches] + for v in check_on: + globally = False + for b in batches: + batch_me = meta['sets']['batches'][b]['meta_edits'] + values = batch_me.get(v, {}).get('values', []) + if not values: + globally = True + else: + _add_factors(v, batch_me, values, args) + if globally: + values = meta['columns'][v]['values'] + _add_factors(v, meta, values, args) + if isinstance(checking_cluster, ChainManager): + cm_meta = checking_cluster.stack['checks'].meta + values = cm_meta['columns'][v]['values'] + _add_factors(v, cm_meta, values, args) + if checking_cluster and 'mean' in stats and check_on: + + options['stats'] = 'mean' + c_view = qp.ViewMapper().make_template('descriptives') + c_view.add_method('stat_check', kwargs=options) + + views = ('stat', ['cbase', 'counts'], c_view) + checking_cluster = self._add_checking_chain(dk, checking_cluster, + 'stat_check', check_on, ['@'], views) + + return None + + @modify(to_list=['_batches']) + def add_tests(self, _batches='all', verbose=True): + """ + Apply coltests for selected batches. + + Sig. Levels are taken from ``qp.Batch`` definitions. + + Parameters + ---------- + _batches: str or list of str + Only for ``qp.Links`` that are defined in this ``qp.Batch`` + instances views are added. + + Returns + ------- + None + """ + self._remove_coltests() + + if verbose: + start = time.time() + + for dk in self.keys(): + _batches = self._check_batches(dk, _batches) + if not _batches: return None + for batch_name in _batches: + batch = self[dk].meta['sets']['batches'][batch_name] + sigpro = batch.get('sigproperties', {}) + levels = batch.get('sigproperties', batch).get('siglevels', []) + weight = batch['weights'] + x_y = batch['x_y_map'] + x_f = batch['x_filter_map'] + y_f = batch['y_filter_map'] + yks = batch['yks'] + + if levels: + vm_tests = qp.ViewMapper().make_template( + method='coltests', + iterators={'metric': ['props', 'means'], + 'mimic': sigpro.get('mimic', ['Dim']), + 'level': levels}) + vm_tests.add_method('significance', + kwargs = {'flag_bases': sigpro.get('flag_bases', [30, 100]), + 'test_total': sigpro.get('test_total', None), + 'groups': 'Tests'}) + for yy in batch['y_on_y']: + if y_f[yy]: + fy = y_f[yy].encode('utf8') + f = {fy: {fy: 0}} + else: + f = ['no_filter'] + self.add_link(filters=f, x=yks[1:], y=yks, + views=vm_tests, weights=weight) + total_len = len(x_y) + for idx, xy in enumerate(x_y, 1): + x, y = xy + if x == '@': continue + if x_f[x]: + fx = x_f[x].encode('utf8') + f = {fx: {fx: 0}} + else: + f = ['no_filter'] + self.add_link(filters=f, x=x, y=y, + views=vm_tests, weights=weight) + if verbose: + done = float(idx) / float(total_len) *100 + print '\r', + time.sleep(0.01) + print 'Batch [{}]: {} %'.format(batch_name, round(done, 1)), + sys.stdout.flush() + if verbose and levels: print '\n' + if verbose: print 'Sig-Tests:', time.time()-start + return None + + def _remove_coltests(self, props=True, means=True): + """ + Remove coltests from stack. + + Parameters + ---------- + props : bool, default=True + If True, column proportion test view will be removed from stack. + means : bool, default=True + If True, column mean test view will be removed from stack. + """ + for dk in self.keys(): + for fk in self[dk].keys(): + for xk in self[dk][fk].keys(): + for yk in self[dk][fk][xk].keys(): + for vk in self[dk][fk][xk][yk].keys(): + del_prop = props and 't.props' in vk + del_mean = means and 't.means' in vk + if del_prop or del_mean: + del self[dk][fk][xk][yk][vk] + del self[dk][fk][xk][yk][vk] + return None diff --git a/quantipy/core/tools/dp/ascribe/reader.py b/quantipy/core/tools/dp/ascribe/reader.py index 834366d2b..e5e756d5c 100644 --- a/quantipy/core/tools/dp/ascribe/reader.py +++ b/quantipy/core/tools/dp/ascribe/reader.py @@ -24,7 +24,8 @@ def quantipy_from_ascribe(path_xml, path_txt, text_key='main'): 'name': 'responseid', 'type': 'int', 'text': {text_key: 'responseid'}, - 'parent': {} + 'parent': {}, + 'properties': {} } meta['sets']['data file']['items'] = ['columns@responseid'] @@ -86,7 +87,8 @@ def quantipy_from_ascribe(path_xml, path_txt, text_key='main'): 'type': col_type, 'text': var_text, 'values': values, - 'parent': {} + 'parent': {}, + 'properties': {} } # Add the newly defined column to the Quantipy meta diff --git a/quantipy/core/tools/dp/dimensions/_create_ddf.dms b/quantipy/core/tools/dp/dimensions/_create_ddf.dms index 8108aa3ac..a9c0bc901 100644 --- a/quantipy/core/tools/dp/dimensions/_create_ddf.dms +++ b/quantipy/core/tools/dp/dimensions/_create_ddf.dms @@ -33,7 +33,7 @@ Event(OnJobStart) 'Line separator const. Const adCR = 13, adCRLF = -1, adLF = 10 - + Set dmgrGlobal.CaseData = CreateObject("ADODB.Stream") dmgrGlobal.CaseData.CharSet = "utf-8" @@ -49,66 +49,27 @@ Event(OnJobStart) End Select dmgrGlobal.CaseData.Open() dmgrGlobal.CaseData.LoadFromFile(MASTER_INPUT+"_datastore.csv") - + Set dmgrGlobal.Columns = dmgrGlobal.CaseData.ReadText(-2) - + 'Set decimal separator Dim oExcel dmgrJob.GlobalVariables.Add("DecimalSeparator") - dmgrJob.GlobalVariables.DecimalSeparator = "." + dmgrJob.GlobalVariables.DecimalSeparator = "." Set oExcel = createobject("Excel.Application") - if oExcel.DecimalSeparator="," Then dmgrJob.GlobalVariables.DecimalSeparator = "," + if oExcel.DecimalSeparator="," Then dmgrJob.GlobalVariables.DecimalSeparator = "," + dmgrGlobal.Add("vars_failed") + dmgrGlobal.Add("var_failed") + dmgrGlobal.vars_failed = "" + End Event Event(OnNextCase) - Function DateString(string) - - Dim splitter - Dim datetime, sdate, stime - Dim date_parts, syear, smonth, sday - - If Find(string, "T") > -1 Then - splitter = "T" - Else - splitter = " " - End If - - string = Left(string, 19) - datetime = Split(string, splitter) - sdate = datetime[0] - - if Len(datetime) = 1 Then - stime = "00:00:01" - Else - stime = datetime[1] - End If - - date_parts = Split(sdate, "-") - If len(date_parts) <> 3 Then - DateString = Null - Else - syear = date_parts[0] - smonth = date_parts[1] - sday = date_parts[2] - - If Not cLong(syear) > 1900 Then - DateString = Null - Else - Select Case DATE_FORMAT - Case "DM", "DDMM", "DMY", "DDMMYY", "DDMMYYYY" - DateString = sday +" "+ smonth +" "+ syear +" "+ stime - Case "MD", "MMDD", "MDY", "MMDDYY", "MMDDYYYY" - DateString = smonth +" "+ sday +" "+ syear +" "+ stime - Case Else - Debug.Log("Unknown DATE_FORMAT.") - End Select - End If - End If - - End Function + const MaxValue = 2147483647 + const MinValue = -2147483648 Dim i, oA, oA_value Dim columns, col, data @@ -132,14 +93,32 @@ Event(OnNextCase) Set oA = dmgrJob.Questions[col] End If Select Case oA.QuestionDataType - Case 1, 6, 7 + Case 1 If data[i] = "NULL" Then oA = NULL Else oA_value=data[i] - if dmgrJob.GlobalVariables.DecimalSeparator = "," Then + if dmgrJob.GlobalVariables.DecimalSeparator = "," Then oA_value = Replace(CText(oA_value),".",",") - End If + End If + If CDouble(oA_value) > MaxValue or CDouble(oA_value) < MinValue then + Debug.Log("Value: " + CText(oA_value) + " for variable: '" + oA.label + "' exceeds limit for variable of type Long. Dropping set variable") + If dmgrGlobal.var_failed <> oA.label Then + dmgrGlobal.vars_failed = dmgrGlobal.vars_failed + oA.label + ", " + dmgrGlobal.var_failed = oA.label + End If + Else + oA = oA_value + End If + End If + Case 6, 7 + If data[i] = "NULL" Then + oA = NULL + Else + oA_value=data[i] + if dmgrJob.GlobalVariables.DecimalSeparator = "," Then + oA_value = Replace(CText(oA_value),".",",") + End If oA = oA_value End If Case 2 @@ -160,10 +139,27 @@ Event(OnNextCase) If data[i] = "" Then oA = Null Else - oA = DateString(data[i]) + Dim parts + parts = data[i].Split(".") + oA = cDate(parts[0]) End If End Select i = i + 1 Next End Event + +Event (OnJobEnd) + + If dmgrGlobal.vars_failed <> "" Then + Debug.Log("**************************************************************************************************") + Debug.Log("Please note: ") + Debug.Log("For one or more cases a value exceeded the limit for Dimensions variable type 'Long'.") + Debug.Log("For those cases setting the variable were skipped.") + Debug.Log("The variables affected are: " + dmgrGlobal.vars_failed) + Debug.Log("If you need those variables then change DataType from 'mr.Long' to 'mr.Double' by editing 'create_mdd [].mrs' for affected variables") + Debug.Log("") + End If + +End Event + diff --git a/quantipy/core/tools/dp/dimensions/dimlabels.py b/quantipy/core/tools/dp/dimensions/dimlabels.py index c3cd12874..781621b09 100644 --- a/quantipy/core/tools/dp/dimensions/dimlabels.py +++ b/quantipy/core/tools/dp/dimensions/dimlabels.py @@ -16,7 +16,11 @@ 'fi-FI': 'FIN', 'nb-NO': 'NOR', 'de-DE': 'DEU', - 'fr-FR': 'FRA' + 'fr-FR': 'FRA', + 'zh-CN': 'CHS', + 'id-ID': 'IND', + 'ms-MY': 'MSL', + 'th-TH': 'THA' } diff --git a/quantipy/core/tools/dp/dimensions/reader.py b/quantipy/core/tools/dp/dimensions/reader.py index e1257fe02..2added187 100644 --- a/quantipy/core/tools/dp/dimensions/reader.py +++ b/quantipy/core/tools/dp/dimensions/reader.py @@ -362,7 +362,7 @@ def get_meta_values(xml, column, data, map_values=True): byProperty_values = [] for cat in categories: cat_name = cat.get('name') - mapped_value = re.search('a[0-9]+$', cat_name) + mapped_value = re.search('a(minus)?[0-9]+$', cat_name) if mapped_value is None: byName = False else: @@ -383,7 +383,7 @@ def get_meta_values(xml, column, data, map_values=True): if len(byName_values) != len(set(byName_values)): byName = False try: - byName_values = [int(v) for v in byName_values] + byName_values = [int(v.replace('minus', '-')) for v in byName_values] except: byName = False @@ -394,7 +394,7 @@ def get_meta_values(xml, column, data, map_values=True): if len(byProperty_values) != len(set(byProperty_values)): byProperty = False byProperty_values = [] - byProperty_key = None + byProperty_key = None elif all(['Value' in bpv for bpv in byProperty_values]): byProperty_key = 'Value' byProperty_values = [bpv['Value'] for bpv in byProperty_values] @@ -997,6 +997,26 @@ def quantipy_from_dimensions(path_mdd, path_ddf, fields='all', grids=None): if not item is None ] + # clean datafile set + datafile = meta['sets']['data file']['items'] + for item in datafile[:]: + collection = item.split('@')[0] + variable = item.split('@')[1] + parents = meta[collection][variable].get('parent', {}) + if collection == 'masks': + for s in meta['sets'][variable]['items']: + while s in datafile: + datafile.remove(s) + elif parents and parents.keys()[0].split('@')[1] in meta['masks']: + parent = parents.keys()[0].split('@')[1] + if not parent in datafile: + idx = datafile.index(item) + datafile[idx] = parent + while item in datafile: + datafile.remove(item) + meta['sets']['data file']['items'] = datafile + + for key, col in meta['columns'].iteritems(): if col['type']=='string' and key in ddf: ddf[key] = ddf[key].apply(qp.core.tools.dp.io.unicoder) diff --git a/quantipy/core/tools/dp/dimensions/writer.py b/quantipy/core/tools/dp/dimensions/writer.py index 91340a342..3e3072178 100644 --- a/quantipy/core/tools/dp/dimensions/writer.py +++ b/quantipy/core/tools/dp/dimensions/writer.py @@ -190,7 +190,10 @@ def get_categories_mrs(meta, vtype, vvalues, child, child_name, text_key): mval = 1 if vtype == 'single' else len(vvalues) var_code.append(MaxValue(0, child, mval)) for value in vvalues: - name = '{}a{}'.format(child_name, value['value']) + if value['value'] < 0: + name = '{}aminus{}'.format(child_name, -1 * value['value']) + else: + name = '{}a{}'.format(child_name, value['value']) labels = DimLabels(name, text_key) labels.add_text(value['text']) var_code.extend([ @@ -246,7 +249,7 @@ def mask_to_mrs(meta, name, text_key): mask = meta['masks'][name] mtype = mask['subtype'] mask_name = name.split('.')[0] - field_name = '{}_grid'.format(mask_name) + field_name = '{}{}'.format(mask_name, meta['info']['dimensions_suffix']) mask_code = [ section_break(20), @@ -298,19 +301,18 @@ def mask_to_mrs(meta, name, text_key): return mask_code, lang, ltype -def create_ddf(master_input, path_dms, CRLF, date_format): +def create_ddf(master_input, path_dms, CRLF): dms_dummy_path = os.path.dirname(__file__) dms = open(os.path.join(dms_dummy_path, '_create_ddf.dms'), 'r') header = [ - '#define MASTER_INPUT "{}"'.format(master_input), - '#define DATE_FORMAT "{}"'.format(date_format), + u'#define MASTER_INPUT "{}"'.format(master_input).encode('utf-8'), '#define CRLF "{}"'.format(CRLF), ] full_dms = header + [line.replace('\n', '') for line in dms] # NOTE: #------------------------------------------------------------------------- # dropping the second "line" which is an invisible line-break char - del full_dms[3] + del full_dms[2] with open(path_dms, 'w') as f: f.write('\n'.join(full_dms)) @@ -359,7 +361,7 @@ def _datastore_csv(meta, data, columns): datastore[col] = replace_comma_in_string(datastore[col]) datastore[col] = remove_newlines_in_string(datastore[col]) datastore[col].replace('nan', '', inplace=True) - + return datastore def _extract_grid_element_name(gridslice): @@ -397,7 +399,7 @@ def remove_newlines_in_string(string): """ """ s = string.copy() - s = s.apply(lambda x: str(x).replace('\n', '')) + s = s.apply(lambda x: str(x).replace('\r\n', '').replace('\n', '')) return s def convert_categorical(categorical): @@ -411,18 +413,21 @@ def convert_categorical(categorical): resp_prefix = categorical.name + 'a' if not cat.dtype == 'object': cat = cat.apply(lambda x: - '{}{}'.format(resp_prefix, int(x)) + '{}{}'.format(resp_prefix, + int(x) if int(x) > -1 else + 'minus{}'.format(-1 * int(x))) if not np.isnan(x) else np.NaN) else: cat = cat.apply(lambda x: str(x).split(';')[:-1]) - cat = cat.apply(lambda x: ['{}{}'.format(resp_prefix, code) + cat = cat.apply(lambda x: ['{}{}'.format(resp_prefix, + code.replace('-', 'minus')) for code in x]) cat = cat.apply(lambda x: str(x).replace('[', '').replace(']', '')) cat = cat.apply(lambda x: x.replace("'", '').replace(', ', ';')) return cat -def dimensions_from_quantipy(meta, data, path_mdd, path_ddf, text_key=None, - CRLF="CR", date_format='DMY', run=True, clean_up=True): +def dimensions_from_quantipy(meta, data, path_mdd, path_ddf, text_key=None, + CRLF="CR", run=True, clean_up=True, reuse_mdd=False): """ DESCP @@ -436,24 +441,30 @@ def dimensions_from_quantipy(meta, data, path_mdd, path_ddf, text_key=None, name = path_mdd.split('/')[-1].split('.')[0] path = '/'.join(path_mdd.split('/')[:-1]) if '/' in path_mdd: path = path + '/' - path_mrs = '{}create_mdd [{}].mrs'.format(path, name) - path_dms = '{}create_ddf [{}].dms'.format(path, name) - path_paired_csv = '{}{}_paired.csv'.format(path, name) - path_datastore = '{}{}_datastore.csv'.format(path, name) + if reuse_mdd: + path_mrs = u'{}create_mdd [{}] (MDD WAS REUSED).mrs'.format(path, name) + else: + path_mrs = u'{}create_mdd [{}].mrs'.format(path, name) + path_dms = u'{}create_ddf [{}].dms'.format(path, name) + path_paired_csv = u'{}{}_paired.csv'.format(path, name) + path_datastore = u'{}{}_datastore.csv'.format(path, name) all_paths = (path_dms, path_mrs, path_datastore, path_paired_csv) if not text_key: text_key = meta['lib']['default text'] create_mdd(meta, data, path_mrs, path_mdd, text_key, run) - create_ddf(name, path_dms, CRLF, date_format) + create_ddf(name, path_dms, CRLF) get_case_data_inputs(meta, data, path_paired_csv, path_datastore) print 'Case and meta data validated and transformed.' if run: from subprocess import check_output, STDOUT, CalledProcessError try: print 'Converting to .ddf/.mdd...' - command = 'mrscriptcl "{}"'.format(path_mrs) - check_output(command, stderr=STDOUT, shell=True) - print '.mdd file generated successfully.' + if reuse_mdd: + print '.mdd file was reused: "{}"'.format(path_mdd) + else: + command = 'mrscriptcl "{}"'.format(path_mrs) + check_output(command, stderr=STDOUT, shell=True) + print '.mdd file generated successfully.' command = 'DMSRun "{}"'.format(path_dms) check_output(command, stderr=STDOUT, shell=True) print '.ddf file generated successfully.\n' diff --git a/quantipy/core/tools/dp/io.py b/quantipy/core/tools/dp/io.py index 5b591835f..4ef89af94 100644 --- a/quantipy/core/tools/dp/io.py +++ b/quantipy/core/tools/dp/io.py @@ -297,7 +297,8 @@ def read_dimensions(path_mdd, path_ddf): return meta, data def write_dimensions(meta, data, path_mdd, path_ddf, text_key=None, - CRLF="CR", date_format="DMY", run=True, clean_up=True): + CRLF="CR", run=True, clean_up=True, + reuse_mdd=False): default_stdout = sys.stdout default_stderr = sys.stderr @@ -306,8 +307,10 @@ def write_dimensions(meta, data, path_mdd, path_ddf, text_key=None, sys.stdout = default_stdout sys.stderr = default_stderr - out = dimensions_from_quantipy(meta, data, path_mdd, path_ddf, - text_key, CRLF, date_format, run, clean_up) + out = dimensions_from_quantipy( + meta, data, path_mdd, path_ddf, text_key, CRLF, run, + clean_up, reuse_mdd + ) default_stdout = sys.stdout default_stderr = sys.stderr diff --git a/quantipy/core/tools/dp/prep.py b/quantipy/core/tools/dp/prep.py index 08a907250..e867471b0 100644 --- a/quantipy/core/tools/dp/prep.py +++ b/quantipy/core/tools/dp/prep.py @@ -1093,21 +1093,62 @@ def merge_column_metadata(left_column, right_column, overwrite=False): """ Merge the metadata from the right column into the left column. """ + _compatible_types(left_column, right_column) left_column['text'] = merge_text_meta( left_column['text'], right_column['text'], overwrite=overwrite) - try: - if 'values' in left_column: - left_column['values'] = merge_values_meta( - left_column['values'], - right_column['values'], - overwrite=overwrite) - except KeyError: - msg = "Found 'values' object in left {}, but not in right dataset!" - print msg.format(left_column['name']) + if 'values' in left_column and 'values' in right_column: + left_column['values'] = merge_values_meta( + left_column['values'], + right_column['values'], + overwrite=overwrite) return left_column +def _compatible_types(left_column, right_column): + l_type = left_column['type'] + r_type = right_column['type'] + if l_type == r_type: return None + all_types = ['array', 'int', 'float', 'single', 'delimited set', 'string', + 'date', 'time', 'boolean'] + err = { + 'array': all_types, + 'int': [ + 'float', 'delimited set', 'string', 'date', 'time', 'array'], + 'float': [ + 'delimited set', 'string', 'date', 'time', 'array'], + 'single': all_types, + 'delimited set': [ + 'string', 'date', 'time', 'array', 'int', 'float'], + 'string': [ + 'int', 'float', 'single', 'delimited set', 'date', 'time', 'array'], + 'date': [ + 'int', 'float', 'single', 'delimited set', 'string', 'time', 'array'], + 'time': [ + 'int', 'float', 'single', 'delimited set', 'string', 'time', 'array'], + } + warn = { + 'int': [ + 'single'], + 'float': [ + 'int', 'single'], + 'delimited set': [ + 'single'], + 'string': [ + 'boolean'] + } + if r_type in err.get(l_type, all_types): + msg = "\n'{}': Trying to merge incompatibe types: Found '{}' in left " + msg += "and '{}' in right dataset." + raise TypeError(msg.format(left_column['name'], l_type, r_type)) + elif r_type in warn.get(l_type, all_types): + msg = "\n'{}': Merge inconsistent types: Found '{}' in left " + msg += "and '{}' in right dataset." + warnings.warn(msg.format(left_column['name'], l_type, r_type)) + else: + msg = "\n'{}': Found '{}' in left and '{}' in right dataset." + raise TypeError(msg.format(left_column['name'], l_type, r_type)) + def _update_mask_meta(left_meta, right_meta, masks, verbose, overwrite=False): """ """ @@ -1170,7 +1211,8 @@ def merge_meta(meta_left, meta_right, from_set, overwrite_text=False, s, n = item['source'].split('@') if s == 'columns': cols.append(n) - mask_items[n] = 'lib@values@{}'.format(name) + if meta_right['masks'][name].get('values'): + mask_items[n] = 'lib@values@{}'.format(name) cols = uniquify_list(cols) if masks: @@ -1220,6 +1262,9 @@ def merge_meta(meta_left, meta_right, from_set, overwrite_text=False, for col_name in cols: if verbose: print '...', col_name + # store properties + props = copy.deepcopy( + meta_right['columns'][col_name].get('properties', {})) # emulate the right meta right_column = emulate_meta( meta_right, @@ -1241,7 +1286,10 @@ def merge_meta(meta_left, meta_right, from_set, overwrite_text=False, right_column['properties']['merged'] = True else: right_column['properties'] = {'merged': True} + meta_left['columns'][col_name] = right_column + if 'properties' in meta_left['columns'][col_name]: + meta_left['columns'][col_name]['properties'].update(props) if col_name in mask_items: meta_left['columns'][col_name]['values'] = mask_items[col_name] @@ -1381,7 +1429,7 @@ def get_sets_from_set(meta, set_name): return sets def hmerge(dataset_left, dataset_right, on=None, left_on=None, right_on=None, - overwrite_text=False, from_set=None, verbose=True): + overwrite_text=False, from_set=None, merge_existing=None, verbose=True): """ Merge Quantipy datasets together using an index-wise identifer. @@ -1411,6 +1459,9 @@ def hmerge(dataset_left, dataset_right, on=None, left_on=None, right_on=None, from_set : str, default=None Use a set defined in the right meta to control which columns are merged from the right dataset. + merge_existing : str/ list of str, default None, {'all', [var_names]} + Specify if codes should be merged for delimited sets for defined + variables. verbose : bool, default=True Echo progress feedback to the output pane. @@ -1419,6 +1470,19 @@ def hmerge(dataset_left, dataset_right, on=None, left_on=None, right_on=None, meta, data : dict, pandas.DataFrame Updated Quantipy dataset. """ + def _merge_delimited_sets(x): + codes = [] + x = str(x).replace('nan', '') + for c in x.split(';'): + if not c: + continue + if not c in codes: + codes.append(c) + if not codes: + return np.NaN + else: + return ';'.join(sorted(codes)) + ';' + if all([kwarg is None for kwarg in [on, left_on, right_on]]): raise TypeError("You must provide a column name for either 'on' or " "both 'left_on' AND 'right_on'") @@ -1436,10 +1500,11 @@ def hmerge(dataset_left, dataset_right, on=None, left_on=None, right_on=None, data_left = dataset_left[1].copy() if isinstance(dataset_right, tuple): dataset_right = [dataset_right] - for ds_right in dataset_right: meta_right = copy.deepcopy(ds_right[0]) data_right = ds_right[1].copy() + slicer = data_right[right_on].isin(data_left[left_on].values.tolist()) + data_right = data_right.loc[slicer, :] if verbose: print '\n', 'Checking metadata...' @@ -1463,34 +1528,40 @@ def hmerge(dataset_left, dataset_right, on=None, left_on=None, right_on=None, if verbose: print '\n', 'Merging data...' + # update columns which are in left and in right data if col_updates: - updata_left = data_left.set_index([left_on])[col_updates].copy() - - if update_right_on: - updata_right = data_right.set_index(right_on, drop=False)[col_updates].copy() - else: - updata_right = data_right.set_index(right_on)[col_updates].copy() + updata_left = data_left.copy() + updata_left['org_idx'] = updata_left.index.tolist() + updata_left = updata_left.set_index([left_on])[col_updates+['org_idx']] + updata_right = data_right.set_index( + right_on, drop=not update_right_on)[col_updates].copy() + sets = [c for c in col_updates + if meta_left['columns'][c]['type'] == 'delimited set'] + non_sets = [c for c in col_updates if not c in sets] if verbose: print '------ updating data for known columns' - updata_left.update(updata_right) - for update_col in col_updates: - if verbose: - print "..{}".format(update_col) - try: - data_left[update_col] = updata_left[update_col].astype( - data_left[update_col].dtype).values - except: - data_left[update_col] = updata_left[update_col].astype( - 'object').values - + updata_left.update(updata_right[non_sets]) + if merge_existing: + for col in sets: + if not (merge_existing == 'all' or col in merge_existing): + continue + if verbose: + print "..{}".format(col) + updata_left[col] = updata_left[col].combine( + updata_right[col], + lambda x, y: _merge_delimited_sets(str(x)+str(y))) + updata_left.reset_index(inplace=True) + for col in col_updates: + data_left[col] = updata_left[col].astype(data_left[col].dtype) + + # append completely new columns if verbose: print '------ appending new columns' new_cols = [col for col in cols if not col in col_updates] if update_right_on: new_cols.append(right_on) - # This will be passed into pd.DataFrame.merge() kwargs = {'left_on': left_on, 'right_on': right_on, 'how': 'left'} @@ -1511,8 +1582,6 @@ def hmerge(dataset_left, dataset_right, on=None, left_on=None, right_on=None, return meta_left, data_left - - def vmerge(dataset_left=None, dataset_right=None, datasets=None, on=None, left_on=None, right_on=None, row_id_name=None, left_id=None, right_id=None, row_ids=None, @@ -1724,6 +1793,13 @@ def vmerge(dataset_left=None, dataset_right=None, datasets=None, vmerge_slicer = data_right[left_on].isin(data_left[right_on]) data_right = data_right.loc[~vmerge_slicer] + # convert right cols to delimited set if depending left col is delimited set + for col in data_right.columns.tolist(): + if (meta_left['columns'].get(col, {}).get('type') == 'delimited set' + and not meta_right['columns'][col]['type'] == 'delimited set'): + data_right[col] = data_right[col].apply( + lambda x: str(int(x)) + ';' if not np.isnan(x) else np.NaN) + vdata = pd.concat([ data_left, data_right diff --git a/quantipy/core/tools/dp/spss/reader.py b/quantipy/core/tools/dp/spss/reader.py index cd3e91aca..be4c2e3d3 100644 --- a/quantipy/core/tools/dp/spss/reader.py +++ b/quantipy/core/tools/dp/spss/reader.py @@ -89,6 +89,7 @@ def extract_sav_meta(sav_file, name="", data=None, ioLocale='en_US.UTF-8', meta['columns'][column] = {} meta['columns'][column]['name'] = column meta['columns'][column]['parent'] = {} + meta['columns'][column]['properties'] = {} if column in metadata.valueLabels: # ValueLabels is type = 'single' (possibry 1-1 map) meta['columns'][column]['values'] = [] @@ -203,6 +204,7 @@ def extract_sav_meta(sav_file, name="", data=None, ioLocale='en_US.UTF-8', 'name': mrset, 'type': 'delimited set', 'text': {text_key: metadata.multRespDefs[mrset]['label']}, + 'properties': {}, 'parent': {}, 'values': values} # Add the new delimited set to the 'data file' set diff --git a/quantipy/core/tools/qp_decorators.py b/quantipy/core/tools/qp_decorators.py index 06f4d8045..3831dc996 100644 --- a/quantipy/core/tools/qp_decorators.py +++ b/quantipy/core/tools/qp_decorators.py @@ -1,5 +1,6 @@ -from decorator import (decorator, getargspec) +from decorator import decorator +from inspect import getargspec # ------------------------------------------------------------------------ # decorators @@ -25,6 +26,10 @@ def _var_in_ds(func, *args, **kwargs): all_args = getargspec(func)[0] ds = args[0] for variable, collection in variables.items(): + nested = False + if collection.endswith('_nested'): + nested = True + collection = collection.split('_')[0] # get collection for argument if collection == 'both': collection = ['columns', 'masks'] @@ -34,10 +39,21 @@ def _var_in_ds(func, *args, **kwargs): # get the variable argument to check v_index = all_args.index(variable) var = kwargs.get(variable, args[v_index]) - if var is None: return func(*args, **kwargs) - if not isinstance(var, list): var = [var] + if var is None: + return func(*args, **kwargs) + if not isinstance(var, list): + var = [var] + if nested: + valid = [] + for v in var: + if ' > ' in v: + valid.extend(v.replace(' ', '').split('>')) + else: + valid.append(v) + else: + valid = var # check the variable - not_valid = [v for v in var if not v in c + ['@']] + not_valid = [v for v in valid if not v in c + ['@']] if not_valid: msg = "'{}' argument for {}() must be in {}.\n" msg += '{} is not in {}.' @@ -56,9 +72,14 @@ def _var_is_cat(func, *args, **kwargs): var = kwargs.get(cat, args[v_index]) if var is None: return func(*args, **kwargs) if not isinstance(var, list): var = [var] - var = [v for v in var if not v == '@'] + valid = [] + for v in var: + if ' > ' in v: + valid.extend(v.replace(' ', '').split('>')) + elif not '@' == v: + valid.append(v) # check if varaibles are categorical - not_cat = [v for v in var if not ds._has_categorical_data(v)] + not_cat = [v for v in valid if not ds._has_categorical_data(v)] if not_cat: msg = "'{}' argument for {}() must reference categorical " msg += 'variable.\n {} is not categorical.' diff --git a/quantipy/core/view.py b/quantipy/core/view.py index ecd73cd68..1fce0ee3c 100644 --- a/quantipy/core/view.py +++ b/quantipy/core/view.py @@ -711,6 +711,42 @@ def _metric_name_map(): 'sum': 'Totalsum', 'lower_q': 'Quartile inférieur', 'upper_q': 'Quartile supérieur'}, + # Italian + 'it-IT': { + '@': 'Total', + 'All': 'Base', + 'no_w_All': 'Unweighted base', + 'gross All': 'Gross base', + 'no_w_gross_All': 'Unweighted gross base', + 'mean': 'Mean', + 'min': 'Min', + 'max': 'Max', + 'median': 'Median', + 'var': 'Sample variance', + 'varcoeff': 'Coefficient of variation', + 'stddev': 'Std. dev', + 'sem': 'Std. err. of mean', + 'sum': 'Total Sum', + 'lower_q': 'Lower quartile', + 'upper_q': 'Upper quartile'}, + # Spanish + 'es-ES': { + '@': 'Total', + 'All': 'Base', + 'no_w_All': 'Unweighted base', + 'gross All': 'Gross base', + 'no_w_gross_All': 'Unweighted gross base', + 'mean': 'Mean', + 'min': 'Min', + 'max': 'Max', + 'median': 'Median', + 'var': 'Sample variance', + 'varcoeff': 'Coefficient of variation', + 'stddev': 'Std. dev', + 'sem': 'Std. err. of mean', + 'sum': 'Total Sum', + 'lower_q': 'Lower quartile', + 'upper_q': 'Upper quartile'}, # German 'de-DE': { '@': 'Gesamt', diff --git a/quantipy/core/view_generators/view_maps.py b/quantipy/core/view_generators/view_maps.py index e9bb9c185..b8bb36433 100644 --- a/quantipy/core/view_generators/view_maps.py +++ b/quantipy/core/view_generators/view_maps.py @@ -23,6 +23,7 @@ import quantipy as qp from quantipy.core.cache import Cache +from quantipy.core.quantify.engine import Level import time class QuantipyViews(ViewMapper): @@ -290,7 +291,7 @@ def frequency(self, link, name, kwargs): axis, condition, rel_to, weights, text = view.get_std_params() logic, expand, complete, calc, exclude, rescale = view.get_edit_params() # ==================================================================== - # this block of kwargs should be removed + # This block of kwargs should be removed # parameter overwriting should be done using the template # NOT QP core code! if kwargs.get('combine', False): @@ -302,6 +303,26 @@ def frequency(self, link, name, kwargs): logic_def['expand'] = None logic[no] = logic_def view._kwargs['logic'] = logic + # -------------------------------------------------------------------- + # This block of code resolves the rel_to arg. in order to be able to use + # rebased % computations. We are also adjusting for the regular notation + # string here... + # We need to avoid the forced overwriting of the kwarg and use the actual + # rel_to != 'x', 'y', 'counts_sum' string... + per_cell = False + if not rel_to in ['', None, 'x', 'y', 'counts_sum']: + view._kwargs['rel_to'] = 'y' + rel_to_kind = rel_to.split('.') + if len(rel_to_kind) == 2: + rel_to = rel_to_kind[0] + if rel_to_kind[1] == 'cells': + per_cell = True + elif rel_to_kind[1] == 'y': + per_cell = False + try: + link['x|f|:||{}|counts'.format(weights)]._kwargs['rebased'] = True + except: + pass # ==================================================================== w = weights if weights is not None else None ignore = True if name == 'cbase_gross' else False @@ -309,7 +330,16 @@ def frequency(self, link, name, kwargs): if q.type == 'array' and not q.y == '@': pass else: - if logic is not None: + if q.leveled: + leveled = Level(q) + if rel_to is not None: + leveled.percent() + elif axis == 'x': + leveled.base() + else: + leveled.count() + view.dataframe = leveled.lvldf + elif logic is not None: try: q.group(groups=logic, axis=axis, expand=expand, complete=complete) except NotImplementedError, e: @@ -328,7 +358,7 @@ def frequency(self, link, name, kwargs): if rel_to is not None: if q.type == 'array': rel_to = 'y' - q.normalize(rel_to) + q.normalize(rel_to, per_cell=per_cell) q.to_df() view.cbases = q.cbase view.rbases = q.rbase @@ -341,11 +371,13 @@ def frequency(self, link, name, kwargs): method_nota = 'f' notation = view.notation(method_nota, condition) view._notation = notation - if q.type == 'array': - view.dataframe = q.result.T if link.y == '@' else q.result - else: - view.dataframe = q.result + if not q.leveled: + if q.type == 'array': + view.dataframe = q.result.T if link.y == '@' else q.result + else: + view.dataframe = q.result view._kwargs['exclude'] = q.miss_x + link[notation] = view def descriptives(self, link, name, kwargs): diff --git a/quantipy/core/view_generators/view_specs.py b/quantipy/core/view_generators/view_specs.py index d9c9c5638..41aaa0b73 100644 --- a/quantipy/core/view_generators/view_specs.py +++ b/quantipy/core/view_generators/view_specs.py @@ -839,7 +839,8 @@ def _request_views(self, data_key=None, filter_key=None, weight=None, vk for vk in item if vk.split('|')[1] not in ['d.median', 'd.stddev', - 'd.sem', 'd.max', 'd.min', 'd.mean'] or + 'd.sem', 'd.max', 'd.min', 'd.mean', + 'd.upper_q', 'd.lower_q'] or vk.split('|')[1] == 'd.mean' and coltests ] diff --git a/quantipy/core/weights/rim.py b/quantipy/core/weights/rim.py index 21deaed59..964fffc8c 100644 --- a/quantipy/core/weights/rim.py +++ b/quantipy/core/weights/rim.py @@ -9,6 +9,14 @@ import warnings import time +from quantipy.core.tools.view.logic import ( + has_any, has_all, has_count, + not_any, not_all, not_count, + is_lt, is_ne, is_gt, + is_le, is_eq, is_ge, + union, intersection, get_logic_index) + + class Rim: def __init__(self, name, @@ -44,6 +52,8 @@ def __init__(self, # Constants self._FILTER_DEF = 'filters' + self._FILTER_DEF_ORG = 'filters_org' + self._FILTER_VARS = 'filter_vars' self._TARGETS = 'targets' self._TARGETS_INDEX = 'targets_index' self._REPORT = 'report' @@ -58,6 +68,8 @@ def __init__(self, self.groups[self._DEFAULT_NAME] = {} self.groups[self._DEFAULT_NAME][self._REPORT] = None self.groups[self._DEFAULT_NAME][self._FILTER_DEF] = None + self.groups[self._DEFAULT_NAME][self._FILTER_DEF_ORG] = None + self.groups[self._DEFAULT_NAME][self._FILTER_VARS] = [] self.groups[self._DEFAULT_NAME][self._TARGETS] = self._empty_target_list() self.groups[self._DEFAULT_NAME][self._TARGETS_INDEX] = None self.groups[self._DEFAULT_NAME][self._ITERATIONS_] = None @@ -136,6 +148,7 @@ def add_group(self, name=None, filter_def=None, targets=None): if targets is not None: self.set_targets(targets=targets, group_name=gn) self.groups[gn][self._FILTER_DEF] = filter_def + self.groups[gn][self._FILTER_DEF_ORG] = filter_def def _compute(self): self._get_base_factors() @@ -238,7 +251,7 @@ def _get_wdf(self, group): weight_var = self._weight_name() if filters is not None: wdf = self._df.copy().query(filters) - filter_vars = list(set(self._get_group_filter_cols(filters))) + filter_vars = self.groups[group][self._FILTER_VARS] selected_cols = target_vars + filter_vars + [weight_var] else: wdf = self._df.copy() @@ -282,8 +295,7 @@ def impute_method(self, method, target=None): self._specific_impute[target] = method def _get_scheme_filter_cols(self): - scheme_filter_cols = [self._get_group_filter_cols( - self.groups[group][self._FILTER_DEF]) + scheme_filter_cols = [self.groups[group][self._FILTER_VARS] for group in self.groups] scheme_filter_cols = list(set([filter_col for sublist in scheme_filter_cols @@ -344,11 +356,12 @@ def group_targets(self, group_targets): None """ if isinstance(group_targets, dict): + if all (group_targets[group] < 1 for group in group_targets): + div_by = 1.0 + else: + div_by = 100.0 for group in group_targets: - if group_targets[group] < 1: - self._group_targets[group] = group_targets[group] - else: - self._group_targets[group] = group_targets[group] / 100.0 + self._group_targets[group] = group_targets[group] / div_by else: raise ValueError(('Group_targets must be of type %s NOT %s ') % \ (type({}), type(group_targets))) @@ -410,7 +423,8 @@ def _check_targets(self, verbose): sample_codes = check_df[target_col].value_counts(sort=False).index.tolist() miss_in_sample = [code for code in target_codes - if code not in sample_codes] + if code not in sample_codes + and not target.values()[0][code] == 0.0] miss_in_targets = [code for code in sample_codes if code not in target_codes] diff --git a/quantipy/core/weights/weight_engine.py b/quantipy/core/weights/weight_engine.py index 30594cc24..0331a1a9f 100644 --- a/quantipy/core/weights/weight_engine.py +++ b/quantipy/core/weights/weight_engine.py @@ -4,6 +4,9 @@ import pandas as pd from rim import Rim from collections import OrderedDict +import re + +from quantipy.core.dataset import DataSet class WeightEngine: @@ -19,7 +22,7 @@ def __init__(self, "\n You must pass a pandas.DataFrame to the 'data' argument of the WeightEngine" "\n constructor. If your DataFrame is serialized please load it first." ) - + self.dataset = None self._df = data.copy() self.schemes = {} @@ -41,6 +44,9 @@ def __init__(self, "\n constructor. If your meta is serialized please load it first." ) self._meta = meta + self.dataset = DataSet('__weights__', False) + self.dataset.from_components(self._df.copy(), self._meta) + def get_report(self): """ @@ -151,7 +157,7 @@ def run(self, schemes=[]): weights = the_scheme._compute() self._df[the_scheme._weight_name()] = weights - + else: raise Exception(("Scheme '%s' not found." % scheme)) else: @@ -187,5 +193,54 @@ def dataframe(self, scheme=None): def add_scheme(self, scheme, key, verbose=True): if scheme.name in self.schemes: print "Overwriting existing scheme '%s'." % scheme.name + self._resolve_filters(scheme, key) self.schemes[scheme.name] = {self._SCHEME: scheme, self._KEY: key} scheme._minimize_columns(self._df, key, verbose) + + def _resolve_filters(self, scheme, key): + grps = scheme.groups + for grp in grps: + f = grps[grp]['filters'] + if f is not None: + grps[grp]['filter_vars'] = self._find_filter_variables(f) + if not isinstance(f, (str, unicode)): + f = self.dataset._logic_as_pd_expr(f, grp) + filter_var = f.split('=')[0] + + # make sure scheme df is sorted by key variable + self._df.set_index(key, inplace=True) + self._df.sort_index(inplace=True) + # make sure dataset is sorted by key variable + self.dataset._data.set_index(key, inplace=True) + self.dataset._data.sort_index(inplace=True) + # assign filter + self._df[filter_var] = self.dataset._data[filter_var].copy() + # restore key as column + self._df.reset_index(inplace=True) + self.dataset._data.reset_index(inplace=True) + self.dataset.drop(filter_var) + + msg = 'Converted {} filter to logical dummy expression: {}' + print msg.format(grp, f) + grps[grp]['filter_vars'].append(filter_var) + grps[grp]['filters'] = f + return None + + def _find_filter_variables(self, filter_expression): + """ + """ + filter_variables = [] + for col in self._df.columns: + if re.search(r"\b"+col+r"\b", unicode(filter_expression)): + filter_variables.append(col) + return filter_variables + + # def _replace_logical_filter(self, filter_expression, grp_name): + # """ + # """ + # varname = '{}__logic_dummy__'.format(grp_name) + # category = [(1, 'select', filter_expression)] + # meta = (varname, 'single', '', category) + # self.dataset.derive(*meta) + # self._df[varname] = self.dataset._data[varname].copy() + # return '{}==1'.format(varname) diff --git a/quantipy/sandbox/excel.py b/quantipy/sandbox/excel.py index 18ed2e504..04088a1df 100644 --- a/quantipy/sandbox/excel.py +++ b/quantipy/sandbox/excel.py @@ -1,11 +1,11 @@ # -* coding: utf-8 -*- -import ctypes import numpy as np import pandas as pd import quantipy as qp import cPickle as cp +from PIL import ImageFont from excel_formats import ExcelFormats, _Format from excel_formats_constants import _DEFAULTS, _VIEWS_GROUPS from difflib import SequenceMatcher @@ -58,6 +58,8 @@ row_height_label = 12.75, start_column = 0, start_row = 0, + start_column_annotations = 0, + start_row_annotations = 0, stat_0_rep = '-', y_header_height = 33.75, y_row_height = 50) @@ -122,47 +124,55 @@ class Excel(Workbook): The following table shows the default sheet properties: - Property Default value Definition - ~~~~~~~~ ~~~~~~~~~~~~~ ~~~~~~~~~~ - ``alternate_bg`` ``True`` Alternate bg_color in freq views - ``arrow_color_high`` ``'#2EB08C'`` High arrow color - ``arrow_rep_high`` ``u'\u25B2'`` High arrow representation for column - proportion tests - ``arrow_color_low`` ``'#FC8EAC'`` Low arrow color - ``arrow_rep_low`` ``u'\u25BC'`` Low arrow representation for column - proportion tests - ``column_width`` ``9`` Column width - column 1, ..., N - ``column_width_label`` ``35`` Column width - column 0 - ``column_width_frame`` ``15`` Column width - Chain.structure - ``column_width_specific`` balh blah - ``dummy_tests`` ``False`` If column proportion/ mean tests in - views add dummy test rows for view - ``freq_0_rep`` ``'-'`` Representation of zero data in - frequency views - ``img_insert_x`` ``0`` Cell row to insert image - (zero indexed) - ``img_insert_y`` ``0`` Cell column to insert image - (zero indexed) - ``img_size`` ``[130, 130]`` Resize image to [width, height] - ``img_x_offset`` ``0`` Offset image by pixels - x axis - ``img_y_offset`` ``0`` Offset image by pixels - y axis - ``row_height_label`` ``12.75`` Row height for view rows - ``start_column`` ``0`` Start column (zero indexed) - ``start_row`` ``0`` Start row (zero indexed) - ``stat_0_rep`` ``'-'`` Representation of zero data in - descriptive views - ``y_header_height`` ``33.75`` y row hieght - header (pands.DataFrame.index.level #0) - ``y_row_height`` ``50`` y row height (pands.DataFrame.index.level #1) + Property Default value Definition + ~~~~~~~~ ~~~~~~~~~~~~~ ~~~~~~~~~~ + ``alternate_bg`` ``True`` Alternate bg_color in freq views + ``arrow_color_high`` ``'#2EB08C'`` High arrow color + ``arrow_rep_high`` ``u'\u25B2'`` High arrow representation for column + proportion tests + ``arrow_color_low`` ``'#FC8EAC'`` Low arrow color + ``arrow_rep_low`` ``u'\u25BC'`` Low arrow representation for column + proportion tests + ``column_width`` ``9`` Column width - column 1, ..., N + ``column_width_label`` ``35`` Column width - column 0 + ``column_width_frame`` ``15`` Column width - Chain.structure + ``column_width_specific`` ``dict`` Column width - specific column override + ``dummy_tests`` ``False`` If column proportion/ mean tests in + views add dummy test rows for view + ``freq_0_rep`` ``'-'`` Representation of zero data in + frequency views + ``img_insert_x`` ``0`` Cell row to insert image + (zero indexed) + ``img_insert_y`` ``0`` Cell column to insert image + (zero indexed) + ``img_size`` ``[130, 130]`` Resize image to [width, height] + ``img_x_offset`` ``0`` Offset image by pixels - x axis + ``img_y_offset`` ``0`` Offset image by pixels - y axis + ``row_height_label`` ``12.75`` Row height for view rows + ``start_column`` ``0`` Start column (zero indexed) + ``start_row`` ``0`` Start row (zero indexed) + ``start_column_annotations`` ``0`` Start column for annotations (zero indexed) + ``start_row_annotations`` ``0`` Start row for annotations (zero indexed) + ``stat_0_rep`` ``'-'`` Representation of zero data in + descriptive views + ``y_header_height`` ``33.75`` y row hieght - header (pands.DataFrame.index.level #0) + ``y_row_height`` ``50`` y row height (pands.DataFrame.index.level #1) To change the values pass a dict with the property / new value as key/ value pair. + To modify a property for a specific sheet, pass a dict to the kwargs parameter in the ``quantipy.Excel.add_chains`` method. + When you have a ``quantipy.ChainManager`` with many sheets the kwargs dict should contain a key with the sheet name and a value of the sheet properties as previously described. Otherwise you are simply updateing the property for every sheet. + If ``start_row_annotations`` + number of annotations is greater than + ``start_row`` then the start_row will become the row after the last + annotation. + 2. ``formats`` The following cell properties can be modified, globally or by view type: @@ -480,7 +490,7 @@ def _write_toc(self): raise NotImplementedError('_write_toc') @lru_cache() - def _add_format(self, format_): + def _add_format(self, **format_): return self.add_format(format_) @@ -498,6 +508,8 @@ def __init__(self, excel, chains, sheet_name, annotations, **kwargs): self._row = self.start_row self._column = self.start_column + self._row_annotations = self.start_row_annotations + self._column_annotations = self.start_column_annotations self._formats = None self._freeze_loc = None self._columns = None @@ -527,7 +539,7 @@ def default_annotation_format(self): format_spec = dict([(k, v) for k, v in _DEFAULTS.iteritems() if k not in exclude_keys]) - return self.excel._add_format(_Format(**format_spec)) + return self.excel._add_format(**_Format(**format_spec)) @property def column_edges(self): @@ -543,21 +555,21 @@ def columns_set(self): def write(self, *args): if isinstance(args[-1], dict): - args = args[:-1] + (self.excel._add_format(args[-1]), ) + args = args[:-1] + (self.excel._add_format(**args[-1]), ) super(_Sheet, self).write(*args) def write_rich_string(self, *args): args, rich_text = ((args[0], args[1]), ), args[2:] for arg in rich_text: if isinstance(arg, dict): - args = args + (self.excel._add_format(arg), ) + args = args + (self.excel._add_format(**arg), ) else: args = args + (arg, ) args = (xl_rowcol_to_cell(*args[0]), ) + args[1:] super(_Sheet, self).write_rich_string(*args) def merge_range(self, *args): - args = args[:-1] + (self.excel._add_format(args[-1]), ) + args = args[:-1] + (self.excel._add_format(**args[-1]), ) super(_Sheet, self).merge_range(*args) def write_chains(self): @@ -568,11 +580,15 @@ def write_chains(self): for annotation in self.annotations: try: annotation, format_spec = annotation - format_ = self.excel._add_format(_Format(**format_spec)) + format_ = self.excel._add_format(**_Format(**format_spec)) except ValueError: format_ = self.default_annotation_format - write(self._row, self._column, annotation, format_) - self._row += 1 + write(self._row_annotations, self._column_annotations, + annotation, format_) + self._row_annotations += 1 + + if self._row_annotations > self._row: + self._row = self._row_annotations for i, chain in enumerate(self.chains): @@ -581,11 +597,17 @@ def write_chains(self): # make y-axis writing availbale to all chains if i == 0: - self._set_freeze_loc(columns) - self._set_column(columns) + levels = columns.nlevels + self._set_freeze_loc(chain.shapes, columns.nlevels, + chain.structure, + chain.array_style == 0) + if chain.structure is None: + self._set_column(columns) except AttributeError: columns = chain.structure.columns + self._set_freeze_loc(chain.shapes, columns.nlevels, + chain.structure, chain.array_style == 0) # write frame box = _Box(self, chain, self._row, self._column) @@ -622,12 +644,12 @@ def write_chains(self): write(self._row + 1, self._column + 1, cd, format_) if arrow_descriptions: arrow_format = _Format(**{'font_color': self.arrow_color_high}) - arrow_format = self.excel._add_format(arrow_format) + arrow_format = self.excel._add_format(**arrow_format) write_rich_string(self._row + 2, self._column + 1, arrow_format, self.arrow_rep_high, format_, cds[1], format_) arrow_format = _Format(**{'font_color': self.arrow_color_low}) - arrow_format = self.excel._add_format(arrow_format) + arrow_format = self.excel._add_format(**arrow_format) write_rich_string(self._row + 3, self._column + 1, arrow_format, self.arrow_rep_low, format_, cds[2], format_) @@ -667,53 +689,46 @@ def _set_column(self, columns): width = self.column_width_specific.get(relative, self.column_width) self.set_column(relative, relative, width) - def set_row(self, row, height, label=None): + @lazy_property + def truetype(self): + fn = self.excel._formats.default_attributes['font_name'] + fs = self.excel._formats.default_attributes['font_size'] + return ImageFont.truetype('%s.ttf' % fn.lower(), fs) + + def set_row(self, row, height, label=None, font_name=None, font_size=None): padding = 5 - units_to_pixels = 4.0 / 3.0 + units_to_pixels = 1.4213480314960607 # 4/3 if isinstance(label, basestring): - font_size = self.excel._formats.default_attributes['font_size'] - font_name = self.excel._formats.default_attributes['font_name'] + if font_size is not None: + fact = float(font_size)/ float(self.excel._formats.default_attributes['font_size']) + else: + fact = 1 - column_dimensions = self._size_col(self.start_column) - label_dimensions = self._label_dimension(label, - font_size, - font_name) - if (label_dimensions[1] * units_to_pixels) - padding > font_size: + dimensions = self.truetype.getsize(label) + + if (dimensions[1] * units_to_pixels) - padding > height: # text too tall return - if (label_dimensions[0] + padding) > column_dimensions: + if (dimensions[0] * fact) >= int(self._size_col(self.start_column)/units_to_pixels): # text too long return super(_Sheet, self).set_row(row, height) - def _label_dimension(self, text, points, font): - - class SIZE(ctypes.Structure): - _fields_ = [("cx", ctypes.c_long), ("cy", ctypes.c_long)] - - hdc = ctypes.windll.user32.GetDC(0) - gdi32 = ctypes.windll.gdi32 - hfont = gdi32.CreateFontA(points, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - font) - hfont_old = gdi32.SelectObject(hdc, hfont) - size = SIZE(0, 0) - gdi32.GetTextExtentPoint32A(hdc, text, len(text), ctypes.byref(size)) - gdi32.SelectObject(hdc, hfont_old) - gdi32.DeleteObject(hfont) - - return (size.cx, size.cy) - - def _set_freeze_loc(self, columns): - if list(columns.labels[-1]).count(0) == 1: - offset = 1 + def _set_freeze_loc(self, shapes, nlevels, structure, arr_style_0): + offset = 0 + if shapes: + if shapes[0][1] == 1: + offset = 1 + if structure is not None: + self._freeze_loc = ((self._row + nlevels + 1), + (self._column + offset)) else: - offset = 0 - self._freeze_loc = ((self._row + columns.nlevels), - (self._column + offset + 1)) + self._freeze_loc = ((self._row + nlevels - arr_style_0), + (self._column + offset + 1)) class _Box(object): @@ -843,20 +858,74 @@ def to_sheet(self, columns): self._write_rows() def _write_data(self): + + def __write_label(index): + offset = 2 if (write_index and index == 'column') else 0 + + if index == 'index': + l = self.sheet._row + left + r = self.sheet._row + right + else: + l = self.sheet._column + left + offset + r = self.sheet._column + right + offset + + if merge_columns and (index == 'column'): + if left == right: + merge_range(fixed, l, fixed + 1, l, label, format_) + else: + for column in xrange(l, r+1): + merge_range(fixed, column, fixed + 1, column, label, format_) + else: + if left == right: + if index == 'index': + write(l, fixed, label, format_) + else: + write(fixed, l, label, format_) + else: + if index == 'index': + merge_range(l, fixed, r, fixed, label, format_) + else: + merge_range(fixed, l, fixed, r, label, format_) + write = self.sheet.write merge_range = self.sheet.merge_range format_ = self.formats._data_header - for rel_y, label in enumerate(self.chain.structure.columns): - column = self.sheet._column + rel_y - merge_range(self.sheet._row, column, - self.sheet._row + 1, column, - label, format_) + frame = self.chain.structure + + width = self.sheet.column_width_frame + + merge_columns = int(not isinstance(frame.columns, pd.MultiIndex)) + write_index = int(isinstance(frame.columns, pd.MultiIndex)) + + nlevels = frame.columns.nlevels + for level_id in xrange(nlevels): + fixed = self.sheet._row + level_id + flat = self.columns.get_level_values(level_id).values.flat + left = right = flat.coords[0] + label = flat.next() + while True: + try: + next_ = flat.next() + if next_ == label: + right += 1 + else: + __write_label('column') + left = right = flat.coords[0] - 1 + label = next_ + except StopIteration: + __write_label('column') + right += 1 + break - width = self.sheet.column_width_specific.get( - column, - self.sheet.column_width_frame) + for idx in xrange(right): + width = self.sheet.column_width_frame + column = self.sheet._column + idx + if write_index: + column += 2 + width = self.sheet.column_width_specific.get(column, width) self.sheet.set_column(column, column, width) + self.sheet.set_row(self.sheet._row, self.sheet.y_header_height) self.sheet.set_row(self.sheet._row + 1, self.sheet.y_row_height) @@ -864,9 +933,31 @@ def _write_data(self): self.sheet._row += 3 + if write_index: + nlevels = frame.index.nlevels + for level_id in xrange(nlevels): + fixed = self.sheet._column + level_id + flat = self.index.get_level_values(level_id).values.flat + left = right = flat.coords[0] + label = flat.next() + while True: + try: + next_ = flat.next() + if next_ == label: + right += 1 + else: + __write_label('index') + left = right = flat.coords[0] - 1 + label = next_ + except StopIteration: + __write_label('index') + right += 1 + break + self.sheet._column += 2 + row_max = self.chain.structure.shape[0] - 1 - flat = self.chain.structure.values.flat + flat = frame.values.flat rel_x, rel_y = flat.coords for data in flat: name = 'left^right^' @@ -878,14 +969,28 @@ def _write_data(self): format_ = self.formats[name] if data != data: data = '' + elif isinstance(data, float): + try: + decs = str(data).split('.')[1] + d = len(decs) + if not(d == 1 and decs == '0'): + format_ = cp.loads(cp.dumps(format_, cp.HIGHEST_PROTOCOL)) + format_['num_format'] = '0.%s' % ('0' * d) + except IndexError: + pass write(self.sheet._row + rel_x, self.sheet._column + rel_y, data, format_) rel_x, rel_y = flat.coords for i in xrange(rel_x): - self.sheet.set_row(self.sheet._row + i, - self.sheet.row_height_label) + if write_index: + self.sheet.set_row(self.sheet._row + i, + self.sheet.row_height_label, + label=frame.index.levels[-1][i]) + else: + self.sheet.set_row(self.sheet._row + i, + self.sheet.row_height_label) def _write_columns(self): contents = dict() @@ -894,7 +999,12 @@ def _write_columns(self): nlevels = self.columns.nlevels write = self.sheet.write merge_range = self.sheet.merge_range + arr_style_0 = self.chain.array_style == 0 + sizes = map(lambda x: x[1], self.chain.shapes) for level_id in xrange(nlevels): + write_labels = not (arr_style_0 and level_id == 0) + borders = [sum(sizes[:i+1]) for i in xrange(len(sizes))] + border = borders.pop(0) row = self.sheet._row + level_id is_tests = self.has_tests and (level_id == (nlevels - 1)) is_values = (level_id % 2) or is_tests @@ -904,8 +1014,19 @@ def _write_columns(self): left = flat.coords[0] data = flat.next() while True: + if borders: + if left >= border: + border = borders.pop(0) next_ = data - while data == next_: + if (level_id + 1) < (nlevels - int(self.has_tests)): + while data == next_: + try: + next_ = flat.next() + if flat.coords[0] > border: + break + except StopIteration: + next_ = None + else: try: next_ = flat.next() except StopIteration: @@ -918,23 +1039,27 @@ def _write_columns(self): if left == right: level = -(1 + self.has_tests) lowest_label = self.columns.get_level_values(level)[left] - if lowest_label == 'Total': + if lowest_label in ['Total', 'Gesamt']: self.single_columns.append(left) self.column_edges.append(right + 1) if left not in self.single_columns: if group_sizes and not is_values: r = 0 while r != right: - merge_range(row, column + group_sizes[0][0], - row, column + group_sizes[0][1], - data, format_) + if write_labels: + merge_range(row, column + group_sizes[0][0], + row, column + group_sizes[0][1], + data, format_) _, r = group_sizes.pop(0) elif left == right: - write(row, column + left, data, format_) + if write_labels: + write(row - int(arr_style_0), column + left, + data, format_) else: - merge_range(row, column + left, - row, column + right, - data, format_) + if write_labels: + merge_range(row - int(arr_style_0), column + left, + row - int(arr_style_0), column + right, + data, format_) if is_values: group_sizes.append((left, right)) data = next_ @@ -945,19 +1070,23 @@ def _write_columns(self): has_tests = self.has_tests if not has_tests or (((level_id + 1) != nlevels) and has_tests): if (row % 2) == 0: - self.sheet.set_row(row, self.sheet.y_header_height) + if write_labels: + self.sheet.set_row(row, self.sheet.y_header_height) else: - self.sheet.set_row(row, self.sheet.y_row_height) + self.sheet.set_row(row - int(arr_style_0), self.sheet.y_row_height) for cindex in self.single_columns: level = -(1 + self.has_tests) data = self._cell(self.columns.get_level_values(level)[cindex], **contents) - merge_range(row - nlevels + 1, column + cindex, - row, column + cindex, - data, format_) + if write_labels: + merge_range(row - nlevels + 1 - int(arr_style_0), + column + cindex, + row - int(arr_style_0), + column + cindex, + data, format_) - self.sheet._row = row + 1 + self.sheet._row = row + 1 - int(arr_style_0) def _write_rows(self): write = self.sheet.write @@ -992,7 +1121,6 @@ def _write_rows(self): level_1, values, contents = (levels(1).values, self.values, self.contents) - row_max = max(contents.keys()) flat = np.c_[level_1.T, values].flat rel_x, rel_y = flat.coords @@ -1017,10 +1145,15 @@ def _write_rows(self): else: x_contents = contents[rel_x] - name = self._row_format_name(**x_contents) + if rel_y == 0 and self.chain.array_style == 0: + name = 'counts' + else: + name = self._row_format_name(**x_contents) + if rel_y == 0: - if data == '': + sig_level_row = data != '' and name in ['propstest', 'meanstest'] + if data == '' or sig_level_row: view_border = False else: view_border = True @@ -1039,11 +1172,11 @@ def _write_rows(self): arr_summ_ital = True else: arr_summ_ital = False - if arr_summ_ital: - if rel_y not in self._italic: - self._italic.append(rel_y) - elif rel_y in self._italic: - self._italic.remove(rel_y) + if arr_summ_ital: + if rel_y not in self._italic: + self._italic.append(rel_y) + elif rel_y in self._italic: + self._italic.remove(rel_y) else: if rel_y not in self._columns: if base and not x_contents['is_weighted']: @@ -1051,6 +1184,7 @@ def _write_rows(self): self._italic.append(rel_y) self._columns.append(rel_y) if rel_y in self._italic: + format_ = cp.loads(cp.dumps(format_, cp.HIGHEST_PROTOCOL)) format_['italic'] = True if rel_y and bg_from: @@ -1102,20 +1236,25 @@ def _write_annotations(self, names): for name in names: anno = getattr(self, name) if anno: + format_ = self.formats[name] + label = anno[0] self.sheet.write(self.sheet._row, self.sheet._column, - anno[0], self.formats[name]) - self._format_row(self.formats[name]) + label, format_) + self._format_row(format_) self.sheet.set_row(self.sheet._row, - self.sheet.row_height_label) + self.sheet.row_height_label, + label=label, + font_name=format_.get('font_name'), + font_size=format_.get('font_size')) + self.sheet._row += 1 def _format_row(self, format_): - value = '' write = self.sheet.write row = self.sheet._row column = self.sheet._column for rel_y in xrange(1, self.values.shape[1] + 1): - write(row, column + rel_y, value, format_) + write(row, column + rel_y, '', format_) def _alternate_bg(self, name, bg): freq_view_group = self.excel.views_groups.get(name, '') == 'freq' @@ -1126,6 +1265,7 @@ def _alternate_bg(self, name, bg): if ((is_freq_test and not_net_sum) or freq_view_group) or \ (not is_mean and self.chain.array_style == 0): return not bg, bg + return self.sheet.alternate_bg, True def _row_format_name(self, **contents): @@ -1206,6 +1346,8 @@ def _row_format_name(self, **contents): return 'sem' elif contents['is_percentile']: return contents['stat'] + elif contents['is_viewlike']: + return 'counts' def _format_x(self, name, rel_x, rel_y, row_max, dummy, bg, view_border, border_from, **kwargs): @@ -1214,12 +1356,16 @@ def _format_x(self, name, rel_x, rel_y, row_max, dummy, bg, view_border, else: format_name = self._format_position(rel_x, rel_y, row_max) if view_border and 'top' not in format_name: - format_name += 'view_border.%s^' % border_from + if self.chain.array_style != 0: + format_name += 'view_border.%s^' % border_from format_name += name if not bg: format_name += '_no_bg_color' + if self.chain.array_style > -1: + format_name += '_array_style_%s' % self.sheet.sheet_name format_ = self.formats[format_name] if kwargs: + format_ = cp.loads(cp.dumps(format_, cp.HIGHEST_PROTOCOL)) for key, value in kwargs.iteritems(): format_[key] = value return format_ @@ -1248,10 +1394,11 @@ def _get_dummies(self, index, values): while True: try: ndx, next_ = next(it) - if next_ == '': + sig_level_row = self.contents[ndx]['siglevel'] and next_ != '' + if next_ == '' or sig_level_row: if not group: group = data - elif self._is('test', **self.contents[idx]): + if self._is('test', **self.contents[ndx]): dummy = False else: if group and self._is('test', **self.contents[idx]): @@ -1266,8 +1413,7 @@ def _get_dummies(self, index, values): if group and dummy: append(ndx + len(dummy_idx) + 1) break - dummy_arr = np.array([[u'' for _ in xrange(len(values[0]))]], - dtype=str) + dummy_arr = np.array([[np.NaN for _ in xrange(len(values[0]))]]) for idx in dummy_idx: try: index = np.insert(index, idx, u'') diff --git a/quantipy/sandbox/excel_formats.py b/quantipy/sandbox/excel_formats.py index fb2776e22..52a9aecf6 100644 --- a/quantipy/sandbox/excel_formats.py +++ b/quantipy/sandbox/excel_formats.py @@ -75,43 +75,22 @@ def _extract_from(name, source, kwargs): class ExcelFormats(_ExcelFormats): - __slots__ = ('_lazy__base', - '_lazy__block_calc_propstest', - '_lazy__block_expanded_propstest', - '_lazy__block_net_propstest', - '_lazy__block_normal_propstest', - '_lazy__bottom', - '_lazy__cell_details', - '_lazy__data_header', - '_lazy__data', - '_lazy__header_left', - '_lazy__header_center', - '_lazy__header_title', - '_lazy__interior', - '_lazy__left', - '_lazy__meanstest', - '_lazy__net_propstest', - '_lazy__notes', - '_lazy__propstest', - '_lazy__right', - '_lazy__top', - '_lazy__ubase', - '_lazy__y', - '_lazy_slots', - '_view_border', - '_format_builder', - '_method', - '_template') - def __init__(self, views_groups, **kwargs): super(ExcelFormats, self).__init__(views_groups, **kwargs) def __getitem__(self, name): - return self._format_builder(name) + value = getattr(self, name, None) + if value is None: + value = self._format_builder(name) + setattr(self, name, value) + return value def _format_builder(self, name): format_ = self._template + if '_array_style_' in name: + name = name.split('_array_style_')[0] + parts = name.split('_no_') methods, no = parts[0].split('^'), parts[1:] @@ -123,7 +102,7 @@ def _format_builder(self, name): method, alt = item[0], None if method in ('bottom', 'interior', 'left', 'right', 'top'): - updates = getattr(self, '_' + method) + updates = getattr(self, '_' + method)() if ('left' in name) and (method == 'right'): updates = {k: v for k, v in updates.iteritems() if k != 'left'} @@ -134,15 +113,14 @@ def _format_builder(self, name): except AttributeError: pass - if '_lazy__' + method in self.slots: - format_.update(getattr(self, '_' + method)) - - if '_' + method in self.slots: - format_.update( - getattr(self, '_' + method)(methods[-1], alt) - ) + if '_' + method in dir(self): + try: + updates = getattr(self, '_' + method)(methods[-1], alt) + except TypeError: + updates = getattr(self, '_' + method)() + format_.update(updates) - if 'num_format_' + method in self.slots: + if 'num_format_' + method in dir(self): format_['num_format'] = getattr(self, 'num_format_' + method) for attr in no: @@ -153,22 +131,24 @@ def _format_builder(self, name): return _Format(**format_) - @lazy_property - def slots(self): - return self.__slots__ + tuple(super(ExcelFormats, self).__slots__) + @property + def _template(self): + return dict([(a, getattr(self, a)) for a in _Format.__attributes__]) def _method(self, method): - result = dict(text_wrap=self.text_wrap) - for name in ('bold', 'bg_color', 'font_color', 'font_name', - 'font_size', 'italic', 'text_v_align', 'text_h_align'): + result = dict() + for name in ('bold', 'bg_color', 'font_color', 'font_name', 'font_size', + 'italic', 'text_v_align', 'text_h_align', 'text_wrap'): attr = getattr(self, name + '_' + method, None) - if attr: + if attr is not None: result[name] = attr return result - @property - def _template(self): - return dict([(a, getattr(self, a)) for a in _Format.__attributes__]) + def _view_border(self, name, alt): + border = getattr(self, 'view_border_' + name) + if border or alt is None: + return dict(top=border) + return dict(top=getattr(self, 'view_border_' + alt)) @lazy_property def _cell_details(self): @@ -190,7 +170,6 @@ def _y(self): return _Format(**format_) - @lazy_property def _header_left(self): format_ = self._template @@ -198,7 +177,6 @@ def _header_left(self): return _Format(**format_) - @lazy_property def _header_center(self): format_ = self._template @@ -206,7 +184,6 @@ def _header_center(self): return _Format(**format_) - @lazy_property def _header_title(self): format_ = self._template @@ -214,7 +191,6 @@ def _header_title(self): return _Format(**format_) - @lazy_property def _notes(self): format_ = self._template @@ -234,66 +210,45 @@ def _data_header(self): return _Format(**format_) - @lazy_property def _data(self): return dict(text_wrap=False) - @lazy_property def _left(self): return dict(left=self.border_style_ext) - @lazy_property def _right(self): return dict(left=self.border_style_int, right=self.border_style_ext) - @lazy_property def _top(self): return dict(top=self.border_style_ext) - @lazy_property def _bottom(self): return dict(bottom=self.border_style_ext) - @lazy_property def _interior(self): return dict(left=self.border_style_int) - @lazy_property def _propstest(self): return dict(font_script=self.font_script_propstest) - @lazy_property def _net_propstest(self): return dict(font_script=self.font_script_net_propstest) - @lazy_property def _block_calc_net_propstest(self): return dict(font_script=self.font_script_block_calc_net_propstest) - @lazy_property def _block_calc_propstest(self): return dict(font_script=self.font_script_block_calc_propstest) - @lazy_property def _block_expanded_propstest(self): return dict(font_script=self.font_script_block_expanded_propstest) - @lazy_property def _block_net_propstest(self): return dict(font_script=self.font_script_block_net_propstest) - @lazy_property def _block_normal_propstest(self): return dict(font_script=self.font_script_block_normal_propstest) - @lazy_property def _meanstest(self): return dict(font_script=self.font_script_meanstest) - - def _view_border(self, name, alt): - border = getattr(self, 'view_border_' + name) - if border or alt is None: - return dict(top=border) - return dict(top=getattr(self, 'view_border_' + alt)) - diff --git a/quantipy/sandbox/excel_formats_constants.py b/quantipy/sandbox/excel_formats_constants.py index 219a0c25c..6b637c67d 100644 --- a/quantipy/sandbox/excel_formats_constants.py +++ b/quantipy/sandbox/excel_formats_constants.py @@ -96,6 +96,9 @@ num_format_block_normal_counts=_DEFAULTS['num_format_counts'], num_format_block_normal_c_pct=_DEFAULTS['num_format_c_pct'], num_format_block_normal_r_pct=_DEFAULTS['num_format_c_pct'], + num_format_block_calc_normal_counts=_DEFAULTS['num_format_counts'], + num_format_block_calc_normal_c_pct=_DEFAULTS['num_format_c_pct'], + num_format_block_calc_normal_r_pct=_DEFAULTS['num_format_c_pct'], num_format_mean=_DEFAULTS['num_format_mean'], num_format_stddev=_DEFAULTS['num_format_mean'], num_format_min=_DEFAULTS['num_format_mean'], @@ -122,7 +125,8 @@ text_v_align_text=2, text_h_align_text=3) _CELL_ATTRIBUTES = ('bg_color', 'bold', 'font_color', - 'font_name', 'font_size', 'italic') + 'font_name', 'font_size', 'italic', + 'text_wrap') _VIEWS_GROUPS = dict(default='default', label='label', @@ -143,6 +147,10 @@ block_normal_c_pct='freq', block_normal_r_pct='freq', block_normal_propstest='freq', + block_calc_normal_counts='freq', + block_calc_normal_c_pct='freq', + block_calc_normal_r_pct='freq', + block_calc_normal_propstest='freq', propstest='freq', net_counts='net', net_c_pct='net', @@ -187,7 +195,8 @@ 'header_left', 'header_center', 'header_title', - 'notes') + 'notes', + 'data') for view in _VIEWS_GROUPS.keys(): _CELLS += (view, ) if view in _NO_TEXT else (view, view + '_text') diff --git a/quantipy/sandbox/pptx/PptxChainClass.py b/quantipy/sandbox/pptx/PptxChainClass.py new file mode 100644 index 000000000..cfe8f2ddc --- /dev/null +++ b/quantipy/sandbox/pptx/PptxChainClass.py @@ -0,0 +1,1374 @@ +# encoding: utf-8 +import re +import warnings +import numpy as np +import pandas as pd +import sys + +default_stdout = sys.stdout +default_stderr = sys.stderr +reload(sys) +sys.setdefaultencoding('utf-8') +sys.stdout = default_stdout +sys.stderr = default_stderr + +BASE_COL = '@' +BASE_ROW = ['is_counts', 'is_c_base'] +PCT_TYPES = ['is_c_pct', 'is_r_pct'] +NOT_PCT_TYPES = ['is_stat'] +CONTINUATION_STR = "(continued {})" +MAX_PIE_ELMS = 4 + + +def float2String(input, ndigits=0): + """ + Round and converts the input, if int/float or list of, to a string. + + Parameters + ---------- + input: int/float or list of int/float + ndigits: int + number of decimals to round to + + Returns + ------- + output: string or list of strings + depending on the input + """ + + output = input + if not isinstance(input, list): + output = [output] + output = map(lambda x: round(x, ndigits), output) + output = map(int, output) + output = map(str, output) + if not isinstance(input, list): + output = output[0] + return output + +def uniquify(l): + """ + Return the given list without duplicates, retaining order. + + See Dave Kirby's order preserving uniqueifying list function + http://www.peterbe.com/plog/uniqifiers-benchmark + """ + + seen = set() + seen_add = seen.add + uniques = [x for x in l if x not in seen and not seen_add(x)] + + return uniques + + +def strip_levels(df, rows=None, columns=None): + """ + Function that strips a MultiIndex DataFrame for specified row and column index + + Parameters + ---------- + df: pandas.DataFrame + rows: int + Row index to remove, default None + columns: int + Column index to remove, default None + + Returns + ------- + df_strip: pandas.DataFrame + The input dataframe stripped for specified levels + + """ + df_strip = df.copy() + if rows is not None: + if df_strip.index.nlevels > 1: + df_strip.index = df_strip.index.droplevel(rows) + if columns is not None: + if df_strip.columns.nlevels > 1: + df_strip.columns = df_strip.columns.droplevel(columns) + return df_strip + + +def as_numeric(df): + """ + Runs through all values in input DataFrame and replaces + ',' to '.' + '%' to '' + '-' to '0' + '*' to '0' + + Parameters + ---------- + df : pandas.DataFrame + + Returns + ------- + pandas.DataFrame + with values as float + + """ + + if not df.values.dtype in ['float64', 'int64']: + data = [[float(str(value).replace(',','.').replace('%','').replace('-','0').replace('*','0')) for value in values] for values in df.values] + df = pd.DataFrame(data, index=df.index, columns=df.columns) + return df.copy() + + +def is_grid_slice(chain): + """ + Returns True if chain is a grid slice + + Parameters + ---------- + chain: quantipy.Chain + + Returns + ------- + bool + True if grid slice + + """ + pattern = '\[\{.*?\}\].' + found = re.findall(pattern, chain.name) + if len(found) > 0 and chain._array_style == -1: + return True + + +def get_indexes_from_list(lst, find, exact=True): + """ + Helper function that search for element in a list and + returns a list of indexes for element match + E.g. + get_indexes_from_list([1,2,3,1,5,1], 1) returns [0,3,5] + get_indexes_from_list(['apple','banana','orange','lemon'], 'orange') -> returns [2] + get_indexes_from_list(['apple','banana','lemon',['orange', 'peach']], 'orange') -> returns [] + get_indexes_from_list(['apple','banana','lemon',['orange', 'peach']], ['orange'], False) -> returns [3] + + Parameters + ---------- + lst: list + The list to look in + find: any + the element to find, can be a list + exact: bool + If False then index are returned if find in lst-item otherwise + only if find = lst-item + + Returns + ------- + list of int + + """ + if exact == True: + return [index for index, value in enumerate(lst) if value == find] + else: + if isinstance(find,list): + return [index for index, value in enumerate(lst) if set(find).intersection(set(value))] + else: + return [index for index, value in enumerate(lst) if find in value] + + +def auto_charttype(df, array_style, max_pie_elms=MAX_PIE_ELMS): + """ + Auto suggest chart type based on dataframe analysis + TODO Move this to Class PptxDataFrame() + + Parameters + ---------- + df: pandas.DataFrame + Not multiindex + array_style: int + array_style as returned from Chain Class + max_pie_elms: int + Max number of elements in Pie chart + + Returns + ------- + str + One of charttypes ('bar_clustered', 'bar_stacked_100', 'pie') + + """ + if array_style == -1: # Not array summary + chart_type = 'bar_clustered' + if len(df.index.get_level_values(-1)) <= max_pie_elms: + if len(df.columns.get_level_values(-1)) == 1: + chart_type = 'pie' + elif array_style == 0: + chart_type = 'bar_stacked_100' + # TODO _auto_charttype - return 'bar_stacked' if rows not sum to 100 + else: + chart_type = 'bar_clustered' + + return chart_type + + +def fill_gaps(l): + """ + Return l replacing empty strings with the value from the previous position. + + Parameters + ---------- + l: list + + Returns + ------- + list + """ + + lnew = [] + for i in l: + if i == '': + lnew.append(lnew[-1]) + else: + lnew.append(i) + return lnew + + +def fill_index_labels(df): + """ + Fills in blank labels in the second level of df's multi-level index. + + Parameters + ---------- + df: pandas.DataFrame + + Returns + ------- + pandas.DataFrame + """ + + _0, _1 = zip(*df.index.values.tolist()) + _1new = fill_gaps(_1) + dfnew = df.copy() + dfnew.index = pd.MultiIndex.from_tuples(zip(_0, _1new), names=df.index.names) + return dfnew + + +def fill_column_values(df, icol=0): + """ + Fills empty values in the targeted column with the value above it. + + Parameters + ---------- + df: pandas.DataFrame + icol: int + + Returns + ------- + pandas.DataFrame + """ + + v = df.iloc[:,icol].fillna('').values.tolist() + vnew = fill_gaps(v) + dfnew = df.copy() # type: pd.DataFrame + dfnew.iloc[:,icol] = vnew + return dfnew + + +class PptxDataFrame(object): + """ + Class for handling the dataframe to be charted. + The class is instantiated from the class PptxChain and holds + the chains dataframe, flattened and ready for charting. + A series of get cell-types methods can be used to select specific cell-types. + + Parameters: + ---------- + df: pandas.DataFrame + The actual dataframe ready to use with PptxPainter + array_style: int + Array style as given by quantipy.chain.array_style + cell_types: list + The dataframes cell types as given by quantipy.chain.contents + + """ + + def __init__(self, dataframe, cell_types, array_style): + + self.array_style = array_style + self.cell_items = cell_types + self.df = dataframe # type: pd.DataFrame + self.__frames = [] + + def __call__(self): + return self.df + + def to_table(self, decimals=2, pct_decimals=2, decimal_separator='.'): + """ + Returns self.df formatted to be added to a table in a slide. + Basically just rounds values and if cell type = % then multiply values with 100 + # todo : should'nt be here, move to PptxPainter + + Parameters + ---------- + decimals: int + Number of decimals for not percentage cell_types + pct_decimals: int + Number of decimals for percentage cell_types + decimal_separator: str + + Returns + ------- + self + + """ + + df = self.df + if df.empty: + return self + if self.array_style == -1: + df = df.T + + df = df.fillna('') + + # Percent type cells + pct_indexes = get_indexes_from_list(self.cell_items, PCT_TYPES, exact=False) + df.iloc[:, pct_indexes] *= 100 + df.iloc[:, pct_indexes] = df.iloc[:, pct_indexes].round(decimals=pct_decimals) + + # Not percent type cells + not_pct_indexes = get_indexes_from_list(self.cell_items, NOT_PCT_TYPES, exact=False) + df.iloc[:, not_pct_indexes] = df.iloc[:, not_pct_indexes].round(decimals=decimals) + + df = df.astype('str') + + if pct_decimals == 0 or decimals == 0: + pct_columns = df.columns[pct_indexes].tolist() if pct_decimals == 0 else [] + not_pct_columns = df.columns[not_pct_indexes].tolist() if decimals == 0 else [] + columns = pct_columns + not_pct_columns + df[columns] = df[columns].replace('\.0', '', regex=True) + + if not decimal_separator == '.': + df = df.replace('\.', ',', regex=True) + + if self.array_style == -1: + df = df.T + + self.df = df + + return self + + def _select_categories(self, categories): + """ + Returns a copy of self.df having only the categories requested + + Parameters + ---------- + categories : list + A list of ints specifying the categories from self.df to return + + Returns + ------- + pptx_df_copy : PptxDataFrame + + """ + + if self.array_style == -1: + df_copy=self.df.iloc[categories] + else: + df_copy = self.df.iloc[:,categories] + + pptx_df_copy = PptxDataFrame(df_copy,self.cell_items,self.array_style) + pptx_df_copy.cell_items = [self.cell_items[i] for i in categories] + + return pptx_df_copy + + def get_means(self): + """ + Return a copy of the PptxDataFrame containing only mean type categories + + Returns + ------- + PptxDataFrame + + """ + return self.get('means') + + def get_nets(self): + """ + Return a copy of the PptxDataFrame only containing net type categories + + Returns + ------- + PptxDataFrame + + """ + return self.get('net') + + + def get_cpct(self): + """ + Return a copy of the PptxDataFrame only containing column percentage categories + + Returns + ------- + PptxDataFrame + + """ + return self.get('c_pct') + + def get_propstest(self): + """ + Return a copy of the PptxDataFrame only containing sig testing type categories + + Returns + ------- + PptxDataFrame + + """ + return self.get('tests') + + def get_stats(self): + """ + Return a copy of the PptxDataFrame only containing stat type categories + + Returns + ------- + PptxDataFrame + + """ + return self.get('stats') + + def _get_propstest_index(self): + """ + Return a list of index numbers from self.cell_items of type 'is_propstest' + + Returns + ------- + row_list : list + + """ + row_list = get_indexes_from_list(self.cell_items, 'is_propstest', exact=False) + return row_list + + def _get_stats_index(self): + """ + Return a list of index numbers from self.cell_items of type 'is_stat' + + Returns + ------- + row_list : list + + """ + row_list = get_indexes_from_list(self.cell_items, 'is_stat', exact=False) + return row_list + + def _get_cpct_index(self): + """ + Return a list of index numbers from self.cell_items of type 'is_c_pct' and not types + 'is_net', 'net', 'is_c_pct_sum' + + Returns + ------- + row_list : list + + """ + + row_list = get_indexes_from_list(self.cell_items, 'is_c_pct', exact=False) + dont_want = get_indexes_from_list(self.cell_items, ['is_net', 'net', 'is_c_pct_sum'], exact=False) + not_net = get_indexes_from_list(self.cell_items, ['normal', 'expanded'], exact=False) + + for x in dont_want: + if x in row_list and x not in not_net: + row_list.remove(x) + + return row_list + + def _get_nets_index(self): + """ + Return a list of index numbers from self.cell_items of types 'is_net' or 'net' and not types + 'is_propstest', 'calc', 'normal', 'is_c_pct_sum', 'is_counts', 'expanded' + + Returns + ------- + row_list : list + + """ + + row_list = get_indexes_from_list(self.cell_items, ['is_net', 'net'], exact=False) + dont_want = get_indexes_from_list(self.cell_items, + ['is_propstest', 'calc', 'normal', 'is_c_pct_sum', 'is_counts', 'expanded'], + exact=False) + + for x in dont_want: + if x in row_list: + row_list.remove(x) + + return row_list + + def _get_means_index(self): + """ + Return a list of index numbers from self.cell_items of type 'is_mean' and not type + 'is_meanstest' + + Returns + ------- + row_list : list + + """ + + row_list = get_indexes_from_list(self.cell_items, ['is_mean'], exact=False) + dont_want = get_indexes_from_list(self.cell_items, ['is_meanstest'], exact=False) + + for x in dont_want: + if x in row_list: + row_list.remove(x) + + return row_list + + def get(self, cell_types, original_order=True): + """ + Method to get specific cell types from chains dataframe. + Will return a copy of the PptxDataFrame instance containing only + the requested cell types. + Available types are 'c_pct, net, mean, test, stat' + + Parameters + ---------- + cell_types : str + A string of comma separated cell types to return. + original_order: Bool + Only relevant if more than one cell type is requested. + If True, cell types are returned in the same order as input dataframe. + If False, cell types will be returned in the order they are requested. + + Returns + ------- + PptxDataFrame + + """ + method_map = {'c_pct': self._get_cpct_index, + 'pct': self._get_cpct_index, + 'net': self._get_nets_index, + 'nets': self._get_nets_index, + 'mean': self._get_means_index, + 'means': self._get_means_index, + 'test': self._get_propstest_index, + 'tests': self._get_propstest_index, + 'stats': self._get_stats_index, + 'stat': self._get_stats_index} + # TODO Add methods for 'stddev', 'min', 'max', 'median', 't_means' + available_cell_types = set(method_map.keys()) + if isinstance(cell_types, basestring): + cell_types = re.sub(' +', '', cell_types) + cell_types = cell_types.split(',') + value_test = set(cell_types).difference(available_cell_types) + if value_test: + raise ValueError("Cell type: {} is not an available cell type. \n Available cell types are {}".format(cell_types, available_cell_types)) + + cell_types_list = [] + + for cell_type in cell_types: + cell_types_list.extend(method_map[cell_type]()) + + if original_order: cell_types_list.sort() + + new_pptx_df = self._select_categories(cell_types_list) + + return new_pptx_df + + +class PptxChain(object): + """ + This class is a wrapper around Chain class to prepare for PPTX charting. + + Parameters + ---------- + chain: quantipy.sandbox.sandbox.Chain + is_varname_in_qtext: Bool + Is question name is included in question text? + False: No question name included in question text + True: Question name included in question text, mask items has short question name included. + 'Full': Question name included in question text, mask items has full question name included. + crossbreak: str + Select a crossbreak to include in charts. Default is None + base_type: str + Select the base type to show in base descriptions: 'weighted' or 'unweighted' + decimals: int + Select the number of decimals to include from Chain.dataframe + verbose: Bool + + """ + + def __init__(self, chain, is_varname_in_qtext=True, crossbreak=None, base_type='weighted', decimals=2, verbose=True): + + self._chart_type = None + self._sig_test = None # type: list # is updated by ._select_crossbreak() + self.crossbreak_qtext = None # type: str # is updated by ._select_crossbreak() + self.verbose = verbose + self._decimals = decimals + self._chain = chain + self.name = chain.name + self.xkey_levels = chain.dataframe.index.nlevels + self.ykey_levels = chain.dataframe.columns.nlevels + self.index_map = self._index_map() + self.is_mask_item = chain._is_mask_item + self.x_key_name = chain._x_keys[0] + self.source = chain.source + self._var_name_in_qtext = is_varname_in_qtext + self.array_style = chain.array_style + self.is_grid_summary = True if chain.array_style in [0,1] else False + self.crossbreak = self._check_crossbreaks(crossbreak) if crossbreak else [BASE_COL] + self.x_key_short_name = self._get_short_question_name() + self.chain_df = self._select_crossbreak() # type: pd.DataFrame + self.xbase_indexes = self._base_indexes() + self.xbase_labels = ["Base"] if self.xbase_indexes is None else [x[0] for x in self.xbase_indexes] + self.xbase_count = "" + self.xbase_label = "" + self.xbase_index = 0 + self.ybases = None + self.select_base(base_type=base_type) + self.base_description = "" if chain.base_descriptions is None else chain.base_descriptions + if self.base_description[0:6].lower() == "base: ": self.base_description = self.base_description[6:] + self._base_text = None + self.question_text = self.get_question_text(include_varname=False) + self.chart_df = self.prepare_dataframe() + self.continuation_str = CONTINUATION_STR + self.vals_in_labels = False + + def __str__(self): + str_format = ('Table name: {}' + '\nX key name: {}' + '\nShort x key name: {}' + '\nGrid summary: {}' + '\nQuestion text: {}' + '\nBase description: {}' + '\nBase label: {}' + '\nBase size: {}' + '\nRequested crossbreak: {}' + '\n') + return str_format.format(getattr(self, 'name', 'None'), + getattr(self, 'x_key_name', 'None'), + getattr(self, 'x_key_short_name', 'None'), + getattr(self, 'is_grid_summary', 'None'), + getattr(self, 'question_text', 'None'), + getattr(self, 'base_description', 'None'), + getattr(self, 'xbase_labels', 'None'), + getattr(self, 'ybases', 'None'), + getattr(self, 'crossbreak', 'None')) + + def __repr__(self): + return self.__str__() + + @property + def sig_test(self): + + # Get the sig testing + sig_df = self.prepare_dataframe() + sig_df = sig_df.get_propstest() + _sig_test = sig_df.df.values.tolist() + + # Assume that all items in the list of sig tests has same length + check_list = map(lambda x: len(x), _sig_test) + assert check_list.count(check_list[0]) == len(check_list), 'List of sig test results is not uniform' + + self._sig_test = [zip(*_sig_test)[i] for i in range(len(_sig_test[0]))] + return self._sig_test + + @property + def chart_type(self): + if self._chart_type is None: + self._chart_type = auto_charttype(self.chart_df.get('pct,net').df, self.array_style) + + return self._chart_type + + @chart_type.setter + def chart_type(self, chart_type): + self._chart_type = chart_type + + def _base_indexes(self): + """ + Finds all categories of type 'is_counts' and 'is_c_base' and then returns + a list of tuples holding (label, index, cell_content, value) for each base. + Method only used when instantiating Class. + Poppulates self.xbase_indexes + + Eg. [(u'Unweighted base', 0, ['is_counts', 'is_c_base'], 1003.0), + (u'Base', 1, ['weight_1', 'is_weighted', 'is_counts', 'is_c_base'], 1002.9999999398246)] + + Returns + ------- + list + + """ + cell_contents = self._chain.describe() + if self.array_style == 0: + row = min([k for k, va in cell_contents.items() + if any(pct in v for v in va for pct in PCT_TYPES)]) + cell_contents = cell_contents[row] + + # Find base rows + bases = get_indexes_from_list(cell_contents, BASE_ROW, exact=False) + skip = get_indexes_from_list(cell_contents, ['is_c_base_gross'], exact=False) + base_indexes = [idx for idx in bases if not idx in skip] or bases + + # Show error if no base elements found + if not base_indexes: + #msg = "No 'Base' element found, base size will be set to None" + #warnings.warn(msg) + return None + + cell_contents = [cell_contents[x] for x in base_indexes] + + if self.array_style == -1 or self.array_style == 1: + + xlabels = self._chain.dataframe.index.get_level_values(-1)[base_indexes].tolist() + base_counts = self._chain.dataframe.iloc[base_indexes, 0] + + else: + + xlabels = self._chain.dataframe.columns.get_level_values(-1)[base_indexes].tolist() + base_counts = self._chain.dataframe.iloc[0, base_indexes] + + return zip(xlabels, base_indexes, cell_contents, base_counts) + + def select_base(self,base_type='weighted'): + """ + Uses self.xbase_indexes to set + self.xbase_label, + self.xbase_count, + self.xbase_index + self.ybases + + Parameters + ---------- + base_type: str + String to define which base type to use: 'weighted' or 'unweighted' + + Returns + ------- + None, sets self + + """ + + if not self.xbase_indexes: + msg = "No 'Base' element found" + warnings.warn(msg) + return None + + if base_type: base_type = base_type.lower() + if not base_type in ['unweighted','weighted']: + raise TypeError('base_type misspelled, choose weighted or unweighted') + + cell_contents = [x[2] for x in self.xbase_indexes] + if base_type == 'weighted': + index = [x for x, items in enumerate(cell_contents) if 'is_weighted' in items] + else: + index = [x for x, items in enumerate(cell_contents) if not 'is_weighted' in items] + + if not index: index=[0] + + # print "self.xbase_indexes: ", self.xbase_indexes + total_base = self.xbase_indexes[index[0]][3] + total_base = np.around(total_base, decimals=self._decimals) + self.xbase_count = float2String(total_base) + self.xbase_label = self.xbase_labels[index[0]] + self.xbase_index = self.xbase_indexes[index[0]][1] + self.ybases = self._get_y_bases() + + def _get_y_bases(self): + """ + Retrieves the y-keys base label and base size from the dataframe. + If no crossbreak is requested the output is a list with one tuple, eg. [(u'Total', '1003')]. + If eg. 'gender' is selected as crossbreak the output is [(u'Female', '487'), (u'Male', '516')] + + Only used in method select_base to poppulate self.ybases. + + Returns + ------- + list + List of tuples [(base label, base size)] + + """ + base_index = self.xbase_index + + if not self.is_grid_summary: + + # Construct a list of tuples with (base label, base size, test letter) + base_values = self.chain_df.iloc[base_index, :].values.tolist() + base_values = np.around(base_values, decimals=self._decimals).tolist() + base_values = float2String(base_values) + base_labels = list(self.chain_df.columns.get_level_values('Values')) + if self._chain.sig_levels: + base_test = list(self.chain_df.columns.get_level_values('Test-IDs')) + bases = zip(base_labels, base_values, base_test) + else: + bases = zip(base_labels, base_values) + + else: # Array summary + # Find base columns + + # Construct a list of tuples with (base label, base size) + base_values = self.chain_df.T.iloc[base_index,:].values.tolist() + base_values = np.around(base_values, decimals=self._decimals).tolist() + base_values = float2String(base_values) + base_labels = list(self.chain_df.index.get_level_values(-1)) + bases = zip(base_labels, base_values) + + #print ybases + return bases + + def _index_map(self): + """ + Map not painted self._chain.dataframe.index with painted index into + a list of tuples (notpainted, painted). + If grid summary, self._chain.dataframe.columns are map'ed instead. + + Example: + [('All', u'Base'), (1, u'Yes'), ('', u''), (2, u'No'), ('', u''), (8, u'Dont know'), + ('', u''), ('sum', u'Totalsum')] + + Only used to poppulate self.index_map in __init__ + + Returns + ------- + list + + """ + if self._chain.painted: # UnPaint if painted + self._chain.toggle_labels() + if self._chain.array_style == -1: + unpainted_index = self._chain.dataframe.index.get_level_values(-1).tolist() + else: + unpainted_index = self._chain.dataframe.columns.get_level_values(-1).tolist() + if not self._chain.painted: # Paint if not painted + self._chain.toggle_labels() + if self._chain.array_style == -1: + painted_index = self._chain.dataframe.index.get_level_values(-1).tolist() + else: + painted_index = self._chain.dataframe.columns.get_level_values(-1).tolist() + + return zip(unpainted_index, painted_index) + + def _select_crossbreak(self): + """ + Takes self._chain.dataframe and returns a copy with only the columns + stated in self.crossbreak. + + Only used to poppulate self.chain_df in __init__. + + Returns + ------- + pd.DataFrame + + """ + cell_items = self._chain.cell_items.split('_') + + if not self.is_grid_summary: + # Keep only requested columns + if self._chain.painted: # UnPaint if painted + self._chain.toggle_labels() + + all_columns = self._chain.dataframe.columns.get_level_values(0).tolist() # retrieve a list of the not painted column values for outer level + if self._chain.axes[1].index(BASE_COL) == 0: + all_columns[0] = BASE_COL # Need '@' as the outer column label + + column_selection = [] + for cb in self.crossbreak: + column_selection = column_selection + (get_indexes_from_list(all_columns, cb)) + + if not self._chain.painted: # Paint if not painted + self._chain.toggle_labels() + + all_columns = self._chain.dataframe.columns.get_level_values(0).tolist() # retrieve a list of painted column values for outer level + + col_qtexts = [all_columns[x] for x in column_selection] # determine painted column values for requested crossbreak + self.crossbreak_qtext = uniquify(col_qtexts) # Save q text for crossbreak in class atribute + + # Slice the dataframes columns based on requested crossbreaks + df = self._chain.dataframe.iloc[:, column_selection] + + if len(cell_items) > 1: + df = fill_index_labels(df) + + else: + if len(cell_items) > 1: + cell_contents = self._chain.describe() + rows = [k for k, va in cell_contents.items() + if any(pct in v for v in va for pct in PCT_TYPES)] + df_filled = fill_index_labels(fill_column_values(self._chain.dataframe)) + df = df_filled.iloc[rows, :] + #for index in base_indexes: + # base_values = self.chain.dataframe.iloc[rows_bad, index].values + # base_column = self.chain.dataframe.columns[index] + # df.loc[:,[base_column]] = base_values + else: + df = self._chain.dataframe + + df_rounded = np.around(df, decimals=self._decimals, out=None) + return df_rounded + + @property + def ybase_values(self): + """ + Returns a list with y base values picked from self.ybases. + + Returns + ------- + list + + """ + if not hasattr(self, "_ybase_values"): + self._ybase_values=[x[1] for x in self.ybases] + return self._ybase_values + + @property + def ybase_value_labels(self): + """ + Returns a list with y base labels picked from self.ybases. + + Returns + ------- + list + + """ + if not hasattr(self, "_ybase_value_labels"): + self._ybase_value_labels=[x[0] for x in self.ybases] + return self._ybase_value_labels + + @property + def ybase_test_labels(self): + """ + Returns a list with y base test labels picked from self.ybases. + Eg. ['A', 'B'] + Returns + ------- + list + + """ + + if not hasattr(self, "_ybase_test_labels"): + if self.is_grid_summary: + self._ybase_test_labels = None + return None + self._ybase_test_labels=[x[2] for x in self.ybases] + return self._ybase_test_labels + + def add_test_letter_to_column_labels(self, sep=" ", prefix=None, circumfix='()'): + """ + Adds test letter to dataframe column labels. + + Parameters + ---------- + sep: str + A string to separate the column label from the test letter, default is a single space. + prefix: str + An optional prefix. + circumfix: str + A two char string used to enclose the test letter. + Default '()' + + Returns + ------- + None + changes self.chain_df + + """ + # Checking input + if circumfix is None: + circumfix = list(('',) * 2) + else: + if not isinstance(circumfix, str) or len(circumfix) <> 2: + raise TypeError("Parameter circumfix needs a string with length 2") + circumfix = list(circumfix) + + str_parameters = ['sep', 'prefix'] + for i in str_parameters: + if not isinstance(eval(i), (str, type(None))): + raise TypeError("Parameter {} must be a string".format(i)) + + if self.is_grid_summary: + pass + + else: + + column_labels = self.chain_df.columns.get_level_values('Values') + + # Edit labels + new_labels_list = {} + for x, y in zip(column_labels, self.ybase_test_labels): + new_labels_list.update({x: x + (sep or '') + circumfix[0] + (prefix or '') + y + circumfix[1]}) + + self.chain_df = self.chain_df.rename(columns=new_labels_list) + + def place_vals_in_labels(self, base_position=0, orientation='side', values=None, sep=" ", prefix="n=", circumfix="()", setup='if_differs'): + """ + Takes values from input list and adds them to self.chain_df's categories, + Meaning rows if grid summary, otherwise columns. + + Can be used to insert base values in side labels for a grid summary. + + Parameters + ---------- + base_position: for future usage + orientation: for future usage + values: list + a list with same number of values as categories in self.chain_df + sep: str + A string to separate the categories from the insert, default is a single space. + prefix: str + A prefix to add to the insert. Default 'n=' + circumfix: str + A two char string used to enclose the insert. + Default '()' + setup: str + A string telling when to insert value ('always', 'if_differs', 'never') + + Returns + ------- + None + Changes self.chain_df + + """ + if setup=='never': return + + # Checking input + if circumfix is None: + circumfix = list(('',) * 2) + else: + if not isinstance(circumfix, str) or len(circumfix) <> 2: + raise TypeError("Parameter circumfix needs a string with length 2") + circumfix = list(circumfix) + + str_parameters = ['sep', 'prefix', 'orientation', 'setup'] + for i in str_parameters: + if not isinstance(eval(i), (str, type(None))): + raise TypeError("Parameter {} must be a string".format(i)) + + valid_orientation = ['side', 'column'] + if orientation not in valid_orientation: + raise ValueError("Parameter orientation must be either of {}".format(valid_orientation)) + + valid_setup = ['always', 'if_differs', 'never'] + if setup not in valid_setup: + raise ValueError("Parameter setup must be either of {}".format(valid_setup)) + + if self.is_grid_summary: + if (len(uniquify(self.ybase_values))>1 and setup=='if_differs') or setup=='always': + + # grab row labels + index_labels = self.chain_df.index.get_level_values(-1) + + # Edit labels + new_labels_list = {} + for x, y in zip(index_labels, values): + new_labels_list.update({x: x + (sep or '') + circumfix[0]+ (prefix or '') + str(y) + circumfix[1]}) + + self.chain_df = self.chain_df.rename(index=new_labels_list) + self.vals_in_labels = True + + else: + + # grab row labels + index_labels = self.chain_df.columns.get_level_values('Values') + + # Edit labels + new_labels_list = {} + for x, y in zip(index_labels, values): + new_labels_list.update({x: x + (sep or '') + circumfix[0] + (prefix or '') + str(y) + circumfix[1]}) + + # Saving column index for level 'Question' in case it accidentially gets renamed + index_level_values = self.chain_df.columns.get_level_values('Question') + + self.chain_df = self.chain_df.rename(columns=new_labels_list) + + # Returning column index for level 'Question' in case it got renamed + self.chain_df.columns.set_levels(index_level_values, level='Question', inplace=True) + + self.vals_in_labels = True + + @property + def base_text(self): + return self._base_text + + @base_text.setter + def base_text(self, base_text): + self._base_text = base_text + + def set_base_text(self, base_value_circumfix="()", base_label_suf=":", base_description_suf=" - ", base_value_label_sep=", ", base_label=None): + """ + Returns the full base text made up of base_label, base_description and ybases, with some delimiters. + Setup is "base_label + base_description + base_value" + + Parameters + ---------- + base_value_circumfix: str + Two chars to surround the base value + base_label_suf: str + A string to add after the base label + base_description_suf: str + A string to add after the base_description + base_value_label_sep: str + A string to separate base_values if more than one + base_label: str + An optional string to use instead of self.xbase_label + + Returns + ------- + str + Sets self._base_text + + """ + # Checking input + if base_value_circumfix is None: + base_value_circumfix = list(('',) * 2) + else: + if not isinstance(base_value_circumfix, str) or len(base_value_circumfix) <> 2: + raise TypeError("Parameter base_value_circumfix needs a string with length 2") + base_value_circumfix = list(base_value_circumfix) + + str_parameters = ['base_label_suf', 'base_description_suf', 'base_value_label_sep', 'base_label'] + for i in str_parameters: + if not isinstance(eval(i), (str, type(None))): + raise TypeError("Parameter {} must be a string".format(i)) + + # Base_label + if base_label is None: + base_label = self.xbase_label + + if self.base_description: + base_label = u"{}{}".format(base_label,base_label_suf or '') + else: + base_label = u"{}".format(base_label) + + # Base_values + if self.xbase_indexes: + base_values = self.ybase_values[:] + for index, base in enumerate(base_values): + base_values[index] = u"{}{}{}".format(base_value_circumfix[0], base, base_value_circumfix[1]) + else: + base_values=[""] + + # Base_description + base_description = "" + if self.base_description: + if len(self.ybases) > 1 and not self.vals_in_labels and self.array_style==-1: + base_description = u"{}{}".format(self.base_description, base_description_suf or '') + else: + base_description = u"{} ".format(self.base_description) + + # ybase_value_labels + base_value_labels = self.ybase_value_labels[:] + + # Include ybase_value_labels in base values if more than one base value + base_value_text = "" + if base_value_label_sep is None: base_value_label_sep = '' + if len(base_values) > 1: + if not self.vals_in_labels: + if self.xbase_indexes: + for index, label in enumerate(zip(base_value_labels, base_values)): + base_value_text=u"{}{}{} {}".format(base_value_text, base_value_label_sep, label[0], label[1]) + base_value_text = base_value_text[len(base_value_label_sep):] + else: + for index, label in enumerate(base_value_labels): + base_value_text=u"{}{}{}".format(base_value_text, base_value_label_sep, label) + base_value_text = base_value_text[len(base_value_label_sep):] + else: + if not self.is_grid_summary: + base_value_text = u"({})".format(self.xbase_count) + + # Final base text + if not self.is_grid_summary: + if len(self.ybases) == 1: + if base_description: + base_text = u"{} {}{}".format(base_label,base_description,base_values[0]) + else: + base_text = u"{} {}".format(base_label, base_values[0]) + else: + if base_description: + base_text = u"{} {}{}".format(base_label,base_description,base_value_text) + else: + base_text = u"{} {}".format(base_label,base_value_text) + else: # Grid summary + if len(uniquify(self.ybase_values)) == 1: + if base_description: + base_text = u"{} {}{}".format(base_label,base_description,base_values[0]) + else: + base_text = u"{} {}".format(base_label, base_values[0]) + else: + if base_description: + base_text = u"{} {}".format(base_label, base_description) + else: + base_text = "" + + self._base_text = base_text + + def _check_crossbreaks(self, crossbreaks): + """ + Checks the crossbreaks input for duplicates and that crossbreak exist in the chain. + + Parameters + ---------- + crossbreaks: list + List of strings + + Returns + ------- + list + The crossbreaks list stripped for duplicates and not existing crossbreaks + + """ + if not isinstance(crossbreaks, list): + crossbreaks = [crossbreaks] + + if not self.is_grid_summary: + for cb in crossbreaks[:]: + if cb not in self._chain.axes[1]: + crossbreaks.remove(cb) + if self.verbose: + msg = 'Requested crossbreak: \'{}\' is not found for chain \'{}\' and will be ignored'.format(cb, chain.name) + warnings.warn(msg) + if crossbreaks == []: crossbreaks = None + else: + pass # just ignore checking if Grid Summary + #crossbreaks = None + + return uniquify(crossbreaks) if crossbreaks is not None else [BASE_COL] + + def _get_short_question_name(self): + """ + Retrieves 'short' question name. + Used in __init__ to poppulate self.x_key_short_name + + Returns + ------- + str + + """ + if not self.is_grid_summary: # Not grid summary + if self.is_mask_item: # Is grid slice + pattern = '(?<=\[\{).*(?=\}\])' + result_list = re.findall(pattern, self.x_key_name) + if result_list: + return result_list[0] # TODO Hmm what if grid has more than one level + else: + return self.x_key_name + + else: # Not grid slice + return self.x_key_name + + else: # Is grid summary + find_period = self.x_key_name.find('.') + if find_period > -1: + return self.x_key_name[:find_period] + else: + return self.x_key_name + + def get_question_text(self, include_varname=False): + """ + Retrieves the question text from the dataframe. + If include_varname=True then the question text will be prefixed the var name. + + Parameters + ---------- + include_varname: Bool + + Returns + ------- + str + + """ + # Get variable name + var_name = self.x_key_name + if self.is_mask_item: + if self._var_name_in_qtext == True: + var_name = self.x_key_short_name + + # Get question text, stripped for variable name + question_text = self.chain_df.index[0][0] + if self._var_name_in_qtext: + question_text = question_text[len(var_name) + 2:] + + # Include the full question text for mask items if missing + if self.is_mask_item: + question_text = self._mask_question_text(question_text) + + # Add variable name to question text if requested + if include_varname: + question_text = u'{}. {}'.format(self.x_key_short_name, question_text) + + # Remove consecutive line breaks and spaces + question_text = re.sub('\n+', '\n', question_text) + question_text = re.sub('\r+', '\r', question_text) + question_text = re.sub(' +', ' ', question_text) + + return question_text.strip() + + def _mask_question_text(self, question_text): + """ + If chain is a mask item (a grid slice), then the parent question text + is added to question text unless already included. + + Final question text in the form "parent_question_text - mask_question_text" + + Only used in self.get_question_text(). + + Parameters + ---------- + question_text: str + + Returns + ------- + str + + """ + if self.source == "native": + if self.is_mask_item: + meta = self._chain._meta + cols = meta['columns'] + masks = meta['masks'] + parent = cols[self.x_key_name]['parent'].keys()[0].split('@')[-1] + m_text = masks[parent]['text'] + text = m_text.get('x edit', m_text).get(meta['lib']['default text']) + if not text.strip() in question_text: + question_text = u'{} - {}'.format(text, question_text) + + return question_text + + def prepare_dataframe(self): + """ + Prepares self.chain_df for charting, that is removes all outer levels + and prepares the dataframe for PptxPainter. + + Returns + ------- + pd.DataFrame + An edited copy of self.chain_df + + """ + # Strip outer level + df = strip_levels(self.chain_df, rows=0, columns=0) + df = strip_levels(df, columns=1) + + # Strip HTML TODO Is 'Strip HTML' at all nessecary? + + # Check that the dataframe is numeric + all_numeric = all(df.applymap(lambda x: isinstance(x, (int, float)))) == True + if not all_numeric: + df = as_numeric(df) + + # For rows that are type '%' divide by 100 + indexes = [] + cell_contents = self._chain.describe() + if self.is_grid_summary: + colpct_row = min([k for k, va in cell_contents.items() + if any(pct in v for v in va for pct in PCT_TYPES)]) + cell_contents = cell_contents[colpct_row] + + for i, row in enumerate(cell_contents): + for type in row: + for pct_type in PCT_TYPES: + if type == pct_type: + indexes.append(i) + if not self.is_grid_summary: + df.iloc[indexes] /= 100 + else: + df.iloc[:, indexes] /= 100 + + # Make a PptxDataFrame instance + chart_df = PptxDataFrame(df, cell_contents, self.array_style) + # Choose a basic Chart type that will fit dataframe TODO Move this to init of Class PptxDataFrame + chart_df.chart_type = auto_charttype(df, self.array_style) + + return chart_df + diff --git a/quantipy/sandbox/pptx/PptxDefaultsClass.py b/quantipy/sandbox/pptx/PptxDefaultsClass.py new file mode 100644 index 000000000..ce31d8119 --- /dev/null +++ b/quantipy/sandbox/pptx/PptxDefaultsClass.py @@ -0,0 +1,131 @@ +# encoding: utf-8 + +from pptx.util import ( + Emu, + Pt, + Cm, + Inches) + +import pptx_defaults as pptx +import re + +def update_dict_from_dict(update_dict, from_dict): + """ + Updates keys in dict with values from other dict + :param + update_dict: + from_dict: + :return: None, update_dict are updated inplace + """ + for key, value in from_dict.iteritems(): + if isinstance(value, dict): + update_dict_from_dict(update_dict[key], from_dict[key]) + else: + update_dict[key] = from_dict[key] + + +class PptxDefaults(object): + """ + Handles all defaults for Class PptxPainter + """ + + def __init__(self): + self._shapes = pptx.shapes + self._chart = pptx.default_chart + self._charts = pptx.shapes['charts'] + self._textbox = pptx.default_textbox + self._textboxes = pptx.shapes['textboxes'] + self._table = pptx.default_table + self._side_table = pptx.default_side_table + self._tables = pptx.shapes['tables'] + self._chart_bar = pptx.shapes['charts']['bar'] + self._chart_bar_stacked100 = pptx.shapes['charts']['bar_stacked100'] + self._chart_line = pptx.shapes['charts']['line'] + self._chart_column = pptx.shapes['charts']['column'] + self._chart_pie = pptx.shapes['charts']['pie'] + self._textbox_header = pptx.shapes['textboxes']['header'] + self._textbox_footer = pptx.shapes['textboxes']['footer'] + self._text_frame = pptx.default_textframe + + @property + def shapes(self): + return self._shapes + + @property + def chart(self): + return self._chart + + @property + def charts(self): + return self._charts + + @property + def table(self): + return self._table + + @property + def side_table(self): + return self._side_table + + @property + def tables(self): + return self._tables + + @property + def textbox(self): + return self._textbox + + @property + def textboxes(self): + return self._textboxes + + @property + def textbox_header(self): + return self._textbox_header + + @property + def textbox_footer(self): + return self._textbox_footer + + @property + def text_frame(self): + return self._text_frame + + def update_shape(self, shape, settings): + """ + Updates self._[shape] with settings from matching dict + + Parameters + ---------- + shape : str + A string with the shape to update + + settings : dict + A dictionary matching one or more keys in self._[shape] + + Returns + ------- + None + self._[shape] is updated + """ + parameter_map = {'shapes': self._shapes, + 'charts': self._charts, + 'tables': self._tables, + 'textboxes': self._textboxes, + 'chart_bar': self._chart_bar, + 'chart_bar_stacked100': self._chart_bar_stacked100, + 'chart_line': self._chart_line, + 'chart_column': self._chart_column, + 'chart_pie': self._chart_pie, + 'textbox_header': self._textbox_header, + 'textbox_footer': self._textbox_footer, + 'side_table': self._side_table, + } + + available_shapes = parameter_map.keys() + shape = re.sub(' +', '', shape) + if shape not in available_shapes: + error_text = "Shape: {} is not an available shape. \n Available shapes are {}" + raise ValueError(error_text.format(shape, available_shapes)) + + update_dict_from_dict(parameter_map[shape], settings) \ No newline at end of file diff --git a/quantipy/sandbox/pptx/PptxPainterClass.py b/quantipy/sandbox/pptx/PptxPainterClass.py new file mode 100644 index 000000000..9980a01a1 --- /dev/null +++ b/quantipy/sandbox/pptx/PptxPainterClass.py @@ -0,0 +1,1602 @@ +# encoding: utf-8 + +import re +from lxml import etree +import warnings + +# Imports from Python-PPTX +from pptx import Presentation +from pptx.chart.data import CategoryChartData +from pptx.util import ( + Emu, + Pt, + Cm, + Inches) + +try: + from pptx import table +except: + from pptx.shapes import table + +from pptx.chart.data import ChartData +from pptx.enum.chart import XL_CHART_TYPE +from pptx.dml.color import RGBColor + +from enumerations import ( + fill_type_dct, + data_label_pos_dct, + legend_pos_dct, + tick_label_pos_dct, + tick_mark_pos_dct, + vertical_alignment_pos_dct, + paragraph_alignment_pos_dct, + theme_color_index_dct, + chart_type_dct +) + +from PptxDefaultsClass import PptxDefaults +from PptxChainClass import float2String +import pandas as pd +import copy + + +def chartdata_from_dataframe(df, number_format="0%", xl_number_format='0.00%'): + """ + Return a CategoryChartData instance from the given Pandas DataFrame. + + Parameters + ---------- + df : pandas.DataFrame + The dataframe instance from which ChartData will be created. + number_format : str, default="0%" + The pptx number format for the intended ChartData. See: + http://python-pptx.readthedocs.io/en/latest/api/chart-data.html?highlight=number_format#pptx.chart.data.CategoryChartData.number_format + xl_number_format : str, default="0.00%" + The xlsx number format for the Excel sheet behind the intended Chart. See: + + Returns + ------- + cd : pptx.chart.data.CategoryChartData + The ChartData instance created from the given dataframe. + """ + + def get_parent(sub_categories, line, pos): + """ + Return the sub_category's parent given its lineage position. + """ + + for subcat in sub_categories: + if subcat.label == line[pos]: + return subcat + + cd = CategoryChartData(number_format=number_format) + + if isinstance(df.index, pd.MultiIndex): + cats = [] + for line in df.index.unique().tolist(): + for l, lvl in enumerate(line): + if l == 0: + if not any([lvl == cat.label for cat in cats]): + cats.append(cd.add_category(lvl)) + else: + parent = get_parent(cats, line, 0) + if l > 1: + for i in range(1, l): + parent = get_parent(parent.sub_categories, line, i) + sub_categories = parent.sub_categories + seen = [lvl == subcat.label for subcat in sub_categories] + if not any(seen): + parent.add_sub_category(lvl) + else: + categories = tuple(df.index.values.tolist()) + cd.categories = categories + + for col in df.columns: + values = [ + value if value == value else None + for value in df[col].values.tolist() + ] + series = (col, tuple(values)) + cd.add_series(*series, number_format=xl_number_format) + + return cd + + +def return_slide_layout_by_name(pptx, slide_layout_name): + """ + Loop over the slide layout object and find slide layout by name, return slide layout + object. + + example: myslide = get_slide_layout_by_name(prs, 'Inhaltsverzeichnis') + slide = prs.slides.add_slide(myslide) + """ + + for slide_layout in pptx.slide_layouts: + if slide_layout.name == slide_layout_name: + return slide_layout + else: + raise Exception( + 'Slide layout: {sld_layout} not found\n'.format( + sld_layout=slide_layout_name)) + + +def convertable(obj, func): + """ + Returns True if obj can be converted by func without an error. + """ + + try: + func(obj) + return True + except ValueError: + return False + + +class PptxPainter(object): + """ + A convenience wrapper around the python-pptx library + + Makes a Presentation instance and also defines a default slide layout if specified. + + Parameters + ---------- + path_to_presentation: str + Full path to PowerPoint template + slide_layout: int + A PowerPoint slide layout. + To see available Slide Layouts in a PPTX, select the Viev menu and click Slide Master. + shape_properties: quantipy.sandbox.pptx.PptxDefaultsClass.PptxDefaults + An instance of PptxDefaults + + """ + + def __init__(self, path_to_presentation, slide_layout=None, shape_properties=None): + + self.presentation = Presentation(path_to_presentation) # TODO PptxPainter - Path checking # type: Presentation + if slide_layout is None: + self.default_slide_layout = None + else: + self.default_slide_layout = self.set_slide_layout(slide_layout) + + # Add all the dafault dicts to the class - + if shape_properties: + self._shape_properties = shape_properties + else: + self._shape_properties = PptxDefaults() + + self.textbox = self._shape_properties.textbox + self.textbox_header = self._shape_properties.textbox_header + self.textbox_footer = self._shape_properties.textbox_footer + self.chart = self._shape_properties.chart + self.table = self._shape_properties.table + self.side_table = self._shape_properties.side_table + + charts = self._shape_properties.charts + self.chart_bar = charts['bar'] + self.chart_bar_stacked100 = charts['bar_stacked100'] + self.chart_line = charts['line'] + self.chart_column = charts['column'] + self.chart_pie = charts['pie'] + + self.slide_kwargs = { + 'textboxs': {}, + 'charts': {}, + 'tables': {}, + 'side_tables': {}, + } + + @staticmethod + def get_plot_values(plot): + """ + Return a list of dicts with serie name as dict-key and serie values as dict-value + + Parameters + ---------- + plot: pptx.chart.plot._BasePlot + + Returns + ------- + list + + """ + series = [ + {series.name: [str(s) for s in series.values]} + for series in plot.series + ] + + return series + + def show_data_labels(self, plot, decimals=0): + """ + Explicitly sets datalabels to allow for datalabel editing. + + Parameters + ---------- + plot: pptx.chart.plot._BasePlot + The plot object for which datalabels need should be shown. + decimals: the number of decimals to show + + Returns + ------- + None + """ + + # Get number format and font from data labels + data_labels = plot.data_labels + number_format = data_labels.number_format # '0%' + font = data_labels.font + + plot_values = self.get_plot_values(plot) + for s, series in enumerate(plot_values): + values = [ + value + for value in series.values()[0] + if convertable(value, float) + ] + for v, value in enumerate(values): + if value is not None: + if number_format == '0%': + value = round(float(value) * 100, decimals) + + str_value = float2String(value) + '%' + else: + str_value = str(value) + else: + str_value = "" + point = plot.series[s].points[v] + data_label = point.data_label + frame = data_label.text_frame + frame.text = str_value + pgraph = frame.paragraphs[0] + for run in pgraph.runs: + run.font.bold = font.bold + # run.font.color.rgb = font.color.rgb + # run.font.fill.fore_color.rgb = font.fill.fore_color.rgb + + run.font.italic = font.italic + run.font.name = font.name + run.font.size = font.size + run.font.underline = font.underline + + def edit_datalabel(self, plot, series, point, text, prepend=False, append=False, rgb=None): + """ + Add/append data label text. + + Parameters + ---------- + plot: pptx.chart.plot._BasePlot + An instance of a Chart object. + serie: int + The serie where the data label should be edited + chart.series[serie] + point: int + The point where the data label should be edited + chart.series[serie].points[point] + text: basestring + The text to add/append to data label + prepend: bool + Set to True to prepend text to existing data label + append: bool + Set to True to append text to existing data label + rgb: tuple + Tuple with three ints defining each RGB color + + Returns + ------- + None + + """ + data_label = plot.series[series].points[point].data_label + frame = data_label.text_frame + + run = frame.paragraphs[0].runs[0] + original_text = frame.text + if prepend: + run.text = u'{}{}'.format(text, original_text) + elif append: + run.text = u'{}{}'.format(original_text, text) + else: + run.text = text + if rgb is not None: + run.font.color.rgb = RGBColor(*rgb) + + def queue_slide_items(self, pptx_chain, slide_items, + decimal_separator='.', + pct_decimals=0, + decimals=2, + ): + """ + Helper function to queue a full automated slide. + Includes queueing of header with question text, a table or chart with optional side table, + and footer with base description. + + Parameters + ---------- + pptx_chain: quantipy.sandbox.pptx.PptxChainClass.PptxChain + An instance of a PptxChain + slide_items: basestring + A string of slide items with cell types in the form 'slide_item:cell_types'. + Available slide items are: + 'chart' + 'sidetable' + 'table' + Every slide item needs a comma separated list of cell types to include in the chart or table. + Available cell types are: 'pct, net, mean, stats, tests' + + A slide_items_string could look like: 'chart:pct,net' + Separate multiple slide items with '+' eg. : 'chart:pct+side_table:net' + One slide item type can only appear once in a slide_items_string. + + Returns + ------- + None + calls: + self.draft_textbox_header() + self.draft_textbox_footer() + self.queue_textbox() + self.draft_table() + self.queue_table() + self.draft_side_table() + self.queue_side_table() + self.draft_autochart() + self.queue_chart() + self._check_shapes() + + """ + + valid_slide_items = ['chart','table','side_table'] + slide_items = re.sub(' +', '', slide_items) + # TODO check for valid slide_items input + + # Question text + draft = self.draft_textbox_header(pptx_chain.question_text) + self.queue_textbox(settings=draft) + + # Base description + draft = self.draft_textbox_footer(pptx_chain.base_text) + self.queue_textbox(settings=draft) + + slide_items = slide_items.split('+') + + for slide_item in slide_items: + if slide_item.startswith('table'): + cell_items = slide_item.split(':')[1] + pptx_frame = pptx_chain.chart_df.get(cell_items).to_table(pct_decimals=pct_decimals, + decimals=decimals, + decimal_separator=decimal_separator, + ) + if not pptx_frame().empty: + table_draft = self.draft_table(pptx_frame()) + self.queue_table(settings=table_draft) + if slide_item.startswith('side_table'): + cell_items = slide_item.split(':')[1] + pptx_frame = pptx_chain.chart_df.get(cell_items).to_table(pct_decimals=pct_decimals, + decimals=decimals, + decimal_separator=decimal_separator, + ) + if not pptx_frame().empty: + side_table_draft = self.draft_side_table(pptx_frame()) + pct_index = [index for index, value in enumerate(pptx_frame.cell_items) if 'is_c_pct' in value] + if pct_index: + side_table_draft['values_suffix'] = '%' + side_table_draft['values_suffix_columns'] = pct_index + self.queue_side_table(settings=side_table_draft) + if slide_item.startswith('chart'): + sig_test = False + cell_items = slide_item.split(':')[1] + + ''' + Makes no sense to actually have 'test' as a cell_item. + Will remove it from cell_items and set flag sig_test as True + ''' + cell_items = cell_items.split(',') + if 'test' in cell_items: + sig_test = True + pptx_chain.add_test_letter_to_column_labels() + pptx_chain.chart_df = pptx_chain.prepare_dataframe() + cell_items.remove('test') + cell_items = ','.join(cell_items) + + pptx_frame = pptx_chain.chart_df.get(cell_items) + if not pptx_frame().empty: + chart_draft = self.draft_autochart(pptx_frame(), pptx_chain.chart_type) + if sig_test: + chart_draft['sig_test_visible'] = True + chart_draft['sig_test_results'] = pptx_chain.sig_test + + self.queue_chart(settings=chart_draft) + + self._check_shapes() + + return None + + def _check_shapes(self, adjust='chart'): + """ + Purpose is to check and adjust all queued items for any collisions: + Currently checks if charts and side_tables colide and then adjust the chart. + + Parameters + ---------- + adjust: str + A not implemented future option to select what to adjust. + + Returns + ------- + None + edits self.slide_kwargs + + """ + + # Find the side_table with the lowest 'left' number + table_max_left=12240000 + table_width=0 + for table, table_settings in self.slide_kwargs['side_tables'].iteritems(): + if table_settings['left'] < table_max_left: + table_max_left = table_settings['left'] + table_width = table_settings['width'] + + # If any charts overlay a side_table then adjust width of chart + for chart, chart_settings in self.slide_kwargs['charts'].iteritems(): + if chart_settings['left'] + chart_settings['width'] > table_max_left: + chart_settings['width'] -= table_width + + def clear_tables(self): + """ + Initilalize the slide_kwargs "tables" dict + + Returns + ------- + None + Removes all keys from self.slide_kwargs['tables'] + """ + self.clear_queue('tables') + + def clear_side_tables(self): + """ + Initilalize the slide_kwargs "side_tables" dict + + Returns + ------- + None + Removes all keys from self.slide_kwargs['side_tables'] + """ + self.clear_queue('side_tables') + + def clear_charts(self): + """ + Initilalize the slide_kwargs "charts" dict + + Returns + ------- + None + Removes all keys from self.slide_kwargs['charts'] + """ + self.clear_queue('charts') + + def clear_textboxes(self): + """ + Initilalize the slide_kwargs "text_boxes" dict + + Returns + ------- + None + Removes all keys from self.slide_kwargs['text_boxes'] + """ + self.clear_queue('textboxs') + + def clear_queue(self, key): + """ + Initialize the requested shape dict in slide_kwargs + + Parameters + ---------- + key: str + 'all', 'charts', textboxes','tables', 'side_tables' + + Returns + ------- + None + Removes requested keys from self.slide_kwargs + + """ + if key=='all': + for item in self.slide_kwargs.keys(): + self.slide_kwargs[item].clear() + elif key=='charts': + self.slide_kwargs['charts'].clear() + elif key=='textboxes': + self.slide_kwargs['textboxs'].clear() + elif key=='tables': + self.slide_kwargs['tables'].clear() + elif key=='side_tables': + self.slide_kwargs['side_tables'].clear() + + def set_slide_layout(self, slide_layout): + """ + Method to set a Slide Layout. + + Parameters + ---------- + slide_layout: int or str + To see available Slide Layouts in a PPTX, select the Viev menu and click Slide Master. + + Returns + ------- + pptx.slide.SlideLayout + Instance of SlideLayout set to the specified slide layout + + """ + if isinstance(slide_layout, int): + return self.presentation.slide_layouts[slide_layout] + else: + return return_slide_layout_by_name(self.presentation, slide_layout) + + def add_slide(self, slide_layout=None): + """ + Method that creates a Slide instance. + + Parameters + ---------- + slide_layout: int or str + To see available Slide Layouts in a PPTX, select the Viev menu and click Slide Master. + + Returns + ------- + + """ + if slide_layout is None: + if self.default_slide_layout is None: + raise ValueError('No slide layout found! Specify a slide layout or set a default slide layout') + else: + slide_layout = self.default_slide_layout + else: + slide_layout = self.set_slide_layout(slide_layout=slide_layout) + + return self.presentation.slides.add_slide(slide_layout) + + def draft_textbox(self, settings=None, text=None): + """ + Method for drafting a textboc + + Parameters + ---------- + settings: dict + A dict of textbox settings, see dict default_textbox in pptx_defaults.py + text: basestring + Text to show in textbox + Returns: self.textbox + ------- + """ + if settings: + draft = copy.deepcopy(settings) + else: + draft = copy.deepcopy(self.textbox) + draft['text'] = text + return draft + + def draft_textbox_header(self, text=None): + """ + Simplified method for drafting a header textbox that wont require the settings dict, + but will instead pick the default textbox_header setting + + Parameters + ---------- + text: basestring + Text to show in textbox + Returns: dict + Returns settings for a textbox, which can be used for method queue_textbox + ------- + """ + + draft = copy.deepcopy(self.textbox_header) + draft['text'] = text + + return draft + + def draft_textbox_footer(self, text=None): + """ + Simplified method for drafting a footer textbox that wont require the settings dict, + but will instead pick the default textbox_footer setting + + Parameters + ---------- + text: basestring + Text to show in textbox + Returns: dict + Returns settings for a textbox, which can be used for method queue_textbox + ------- + """ + + draft = copy.deepcopy(self.textbox_footer) + draft['text'] = text + + return draft + + def draft_chart(self, dataframe, settings=None): + """ + Sets attribute self.chart + + Parameters + ---------- + settings: dict + A dict of chart settings, see dict default_chart in pptx_defaults.py + dataframe: pandas.core.frame.DataFrame + the pandas.dataframe to chart + Returns: self.chart + ------- + """ + + if settings: + draft = copy.deepcopy(settings) + else: + draft = copy.deepcopy(self.chart) + draft['dataframe'] = dataframe + return draft + + def draft_autochart(self, dataframe, chart_type): + """ + Simplified caller for method draft_chart that wont require the settings dict, + but will instead pick the default chart setting for the chart type requested + + Parameters + ---------- + dataframe: pandas.core.frame.DataFrame + chart_type: str + A string corresponding to the keys in Dict "chart_type_dct" from "enumerations.py" + Returns: self.chart + ------- + """ + valid_chart_types = ['pie', + 'bar_clustered', + 'bar_stacked_100', + 'bar', + 'column', + 'column_clustered', + 'line', + ] + # Validate the user-provided chart types. + if not isinstance(chart_type, basestring): + raise ValueError('The chart_type argument must be a string') + if chart_type not in valid_chart_types: + error_msg ='Invalid chart_type {}. Valid chart types are {}' + raise ValueError(error_msg.format(chart_type, valid_chart_types)) + + # Make draft + if chart_type == 'pie': + draft = copy.deepcopy(self.chart_pie) + elif chart_type == 'bar_clustered' or chart_type == 'bar': + draft = copy.deepcopy(self.chart_bar) + if len(dataframe.columns) > 1: + draft['has_legend'] = True + elif chart_type == 'column_clustered' or chart_type == 'column': + draft = copy.deepcopy(self.chart_column) + if len(dataframe.columns) > 1: + draft['has_legend'] = True + elif chart_type == 'line': + draft = copy.deepcopy(self.chart_line) + if len(dataframe.columns) > 1: + draft['has_legend'] = True + elif chart_type == 'bar_stacked_100': + draft = copy.deepcopy(self.chart_bar_stacked100) + else: + draft = copy.deepcopy(self.chart_bar) + + draft['dataframe'] = dataframe + return draft + + def draft_table(self, dataframe, text=None, settings=None): + """ + Sets attribute self.tables + + Parameters + ---------- + settings: dict + A dict of chart settings, see dict default_chart in pptx_defaults.py + dataframe: pandas.core.frame.DataFrame + the pandas.dataframe to make a table of + Returns: self.tables + ------- + """ + + if settings: + draft = copy.deepcopy(settings) + else: + draft = copy.deepcopy(self.table) + draft['dataframe'] = dataframe + draft['text'] = text + return draft + + def draft_side_table(self, dataframe): + """ + Draft a table + + Parameters + ---------- + dataframe: pandas.core.frame.DataFrame + the pandas.dataframe to make a table of + Returns: self.tables + ------- + """ + + draft = copy.deepcopy(self.side_table) + draft['dataframe'] = dataframe + + # set table width based on number of columns in dataframe + cols = len(draft['dataframe'].columns) + col_width = draft['values_column_width'] + table_width = cols * col_width + + # position table + rows = len(draft['dataframe'].index) + draft['left'] = draft['left'] + draft['width'] - table_width + draft['width'] = table_width + height = draft['height'] + top = draft['top'] + top_member_row_height = draft['top_member_row_height'] + + if rows == 1: + top = top + int(round(height * (0.3 / rows)) - top_member_row_height) + draft['values_cell_kwargs']['margin_top'] = Cm(1.6) + else: + top = top + int(round(height * (0.45 / rows)) - top_member_row_height) + draft['values_cell_kwargs']['margin_top'] = Cm(0.1) + + draft['top'] = top + + plot_area = int(round(height * 0.86)) + value_row_height = int(round(plot_area / rows)) + height = top_member_row_height + rows * value_row_height + + draft['height'] = height + draft['values_row_height'] = value_row_height + + return draft + + def queue_chart(self, settings, name=None): + """ + Will add a chart to the Slide properties Dict + :param + settings: A dictionary of chart settings, default is self.chart + name: Optionally give the chart a name. If none the chart will be named 'chart[n]' + :return: + None, Adds a key to self.slide_kwargs['charts'] + """ + + self._add('chart', settings, name=name) + + def queue_textbox(self, settings, name=None): + """ + Will add a textbox to the Slide properties Dict + :param + settings: A dictionary of textbox settings, deafult is self.textbox + name: Optionally give the textbox a name. If none the textbox will be named 'textbox[n]' + :return: + None, adds a key to self.slide_kwargs['textboxes'] + """ + + self._add('textbox', settings, name=name) + + def queue_table(self, settings, name=None): + """ + Will add a table to the Slide properties Dict + :param + settings: A dictionary of table settings, default is self.table + name: Optionally give the table a name. If none the table will be named 'table[n]' + :return: + None, Adds a key to self.slide_kwargs['tables'] + """ + + self._add('table', settings, name=name) + + def queue_side_table(self, settings, name=None): + """ + Will add a table to the Slide properties Dict + :param + settings: A dictionary of table settings, default is self.table + name: Optionally give the table a name. If none the table will be named 'table[n]' + :return: + None, Adds a key to self.slide_kwargs['tables'] + """ + + self._add('side_table', settings, name=name) + + def add_slide_from_queue(self, slide_layout=None): + """ + Method that creates a Slide instance and inserts + textboxes and charts as queued in self.slide_kwargs + :param + slide_layout: Int + The Slide Layout to use. + To see available Slide Layouts in a PPTX, select the Viev menu and click Slide Master. + If no Slide layout is specified then self.default_slide_layout will be used + :return: + """ + slide= self.add_slide(slide_layout=slide_layout) + kwargs = self.slide_kwargs + for _type, draft in kwargs.iteritems(): + # Add text boxes + if _type == 'textboxs': + for name, settings in draft.iteritems(): + textbox=self.add_textbox(slide, **settings) + # Add charts + if _type == 'charts': + for name, settings in draft.iteritems(): + chart=self.add_chart(slide, **settings) + # Add tables + if _type == 'tables': + for name, settings in draft.iteritems(): + table=self.add_table(slide, **settings) + # Add side tables + if _type == 'side_tables': + for name, settings in draft.iteritems(): + side_table=self.add_table(slide, **settings) + return slide + + def _add(self, shape, settings, name=None): + """ + Internal for adding a new shape (textbox or chart) to self.slide_kwargs + :param + shape: String ('chart', 'textbox', 'table') + settings: A dictionary of settings + name: + :return: + """ + + shapes='{}s'.format(shape) + + if name is None: + name='{}{}'.format(shape, len(self.slide_kwargs[shapes]) + 1) + + self.slide_kwargs[shapes][name] = settings.copy() + + @staticmethod + def set_cell_properties(cell, # type: table._Cell + margin_left=Cm(0.1), + margin_right=Cm(0.1), + margin_top=Cm(0.1), + margin_bottom=Cm(0.1), + vertical_alignment='top', + shading=False, + shading_color=(0,0,0)): + + cell.margin_left = margin_left + cell.margin_right = margin_right + cell.margin_top = margin_top + cell.margin_bottom = margin_bottom + cell.vertical_anchor = vertical_alignment_pos_dct[vertical_alignment] + fill = cell.fill + if shading: + fill.solid() + fill.fore_color.rgb = RGBColor(*shading_color) + else: + fill.background() + + @staticmethod + def add_table(slide, + dataframe=None, + text=None, + left=Cm(4), top=Cm(8), width=Cm(5), height=Cm(8), + + show_side_member=True, + side_member_column_width=Cm(1), + side_member_textframe_kwargs=None, # type: dict + side_member_cell_kwargs=None, # type: dict + + show_top_member=True, + top_member_row_height=Cm(1), + top_member_textframe_kwargs=None, # type: dict + top_member_cell_kwargs=None, # type: dict + + values_row_height=Cm(1), + values_column_width=Cm(2), + values_textframe_kwargs=None, # type: dict + values_cell_kwargs=None, # type: dict + values_prefix=None, + values_prefix_columns='all', # or a list of column indexes + values_suffix=None, + values_suffix_columns = 'all', # or a list of column indexes + + top_left_corner_textframe_kwargs=None, # type: dict + top_left_corner_cell_kwargs=None, # type: dict + ): + # ------------------------------------------------------------------------- + + rows = len(dataframe.index) + if show_top_member: rows +=1 + cols = len(dataframe.columns) + if show_side_member: cols +=1 + + shapes = slide.shapes + table = shapes.add_table(rows, cols, left, top, width, height).table + + # row specific properties + if show_side_member: + table.columns[0].width = side_member_column_width + row_labels = list(dataframe.index) + for idx, row_label in enumerate(row_labels): + row_idx = idx + 1 if show_top_member else idx + cell = table.cell(row_idx, 0) + PptxPainter.set_cell_properties(cell,**side_member_cell_kwargs) + PptxPainter.add_textframe(cell, row_label, **side_member_textframe_kwargs) + + # col specific properties + if show_top_member: + table.rows[0].height = top_member_row_height + col_labels = list(dataframe.columns) + for idx, col_label in enumerate(col_labels): + col_idx = idx + 1 if show_side_member else idx + cell = table.cell(0, col_idx) + PptxPainter.set_cell_properties(cell,**top_member_cell_kwargs) + PptxPainter.add_textframe(cell, col_label, **top_member_textframe_kwargs) + + # add values + df_cols_range = range(len(dataframe.columns)) + if values_prefix_columns =='all': values_prefix_columns = df_cols_range + if values_suffix_columns == 'all': values_suffix_columns = df_cols_range + table_values = dataframe.values + datatypes = dataframe.dtypes.tolist() + for i, val in enumerate(table_values): + row_idx = i +1 if show_top_member else i + table.rows[row_idx].height = values_row_height + for x, subval in enumerate(val): + col_idx = x + 1 if show_side_member else x + table.columns[col_idx].width = values_column_width + cell = table.cell(row_idx, col_idx) + PptxPainter.set_cell_properties(cell, **values_cell_kwargs) + if subval <> '': + prefix = None + if x in values_prefix_columns: prefix = values_prefix + suffix = None + if x in values_suffix_columns: suffix = values_suffix + if datatypes[x].kind == 'i': + subval = int(subval) + subval = (prefix or '') + str(subval) + (suffix or '') + PptxPainter.add_textframe(cell, subval, **values_textframe_kwargs) + + # for i in range(len(dataframe.columns)): + # col_idx = i + 1 if show_side_member else i + # table.columns[col_idx].width = values_column_width + # for x in range(len(dataframe.index)): + # row_idx = x + 1 if show_top_member else x + # table.rows[row_idx].height = values_row_height + # cell = table.cell(row_idx, col_idx) + # PptxPainter.set_cell_properties(cell, **values_cell_kwargs) + # prefix = None + # if i in values_prefix_columns: prefix = values_prefix + # suffix = None + # if i in values_suffix_columns: suffix = values_suffix + # value = dataframe.iloc[x,i] + # subval = (prefix or '') + str(value) + (suffix or '') + # PptxPainter.add_textframe(cell, subval, **values_textframe_kwargs) + + # add question label + if show_side_member and show_top_member: + cell = table.cell(0, 0) + PptxPainter.set_cell_properties(cell,**top_left_corner_cell_kwargs) + PptxPainter.add_textframe(cell, text, **top_left_corner_textframe_kwargs) + + return table + + def add_chart(self, slide, + dataframe=None, + chart_type='bar_stacked_100', + left=Cm(2.31), top=Cm(5.93), width=Cm(29.23), height=Cm(10.5), + chart_style=2, + + # Title + has_chart_title=False, + titletext=None, + textframe_kwargs=None, # type: dict + + # Legend properties + has_legend=True, + legend_position='right', + legend_in_layout=False, # will we ever set this True? + legend_horz_offset=0.1583, + legend_font_kwargs=None, # type: dict + + # Category axis properties + caxis_visible=True, + caxis_tick_label_position='next_to_axis', + caxis_tick_labels_offset=730, + caxis_has_major_gridlines=False, + caxis_has_minor_gridlines=False, + caxis_major_tick_mark='outside', + caxis_minor_tick_mark='none', + caxis_font_kwargs=None, # type: dict + + # Value axis properties + vaxis_visible=True, + vaxis_tick_label_position='low', + vaxis_has_major_gridlines=True, + vaxis_has_minor_gridlines=False, + vaxis_major_tick_mark='outside', + vaxis_minor_tick_mark='none', + vaxis_max_scale=1.0, + vaxis_min_scale=0.0, + vaxis_major_unit=0.1, + vaxis_minor_unit=None, + vaxis_tick_labels_num_format='0%', + vaxis_tick_labels_num_format_is_linked=False, + vaxis_font_kwargs=None, # type: dict + + # Fix yaxis (False, 'center', ?). Currently only an option for bar chart + fix_yaxis = False, + + # Datalabel properties + plot_has_data_labels=True, + data_labels_position='center', + data_labels_num_format='0%', + data_labels_num_format_is_linked=False, + data_labels_font_kwargs=None, # type: dict + + # Plot properties + plot_vary_by_cat=False, + plot_gap_width=150, + plot_overlap=100, + smooth_line=False, + + # Number format + number_format='0.00%', + xl_number_format='0.00%', + + # Sig test + sig_test_visible = False, + sig_test_results = None, + ): + """ + Adds a chart to the given slide and sets all properties for the chart + :param + slide: + dataframe: + chart_type: + left: + top: + width: + height: + chart_style: + has_chart_title: + titletext: + textframe_kwargs: + has_legend: + legend_position: + legend_in_layout: + legend_horz_offset: + legend_font_kwargs: + caxis_visible: + caxis_tick_label_position: + caxis_tick_labels_offset: + caxis_has_major_gridlines: + caxis_has_minor_gridlines: + caxis_major_tick_mark: + caxis_minor_tick_mark: + caxis_font_kwargs: + vaxis_visible: + vaxis_tick_label_position: + vaxis_has_major_gridlines: + vaxis_has_minor_gridlines: + vaxis_major_tick_mark: + vaxis_minor_tick_mark: + vaxis_max_scale: + vaxis_min_scale: + vaxis_major_unit: + vaxis_minor_unit: + vaxis_tick_labels_num_format: + vaxis_tick_labels_num_format_is_linked: + vaxis_font_kwargs: + plot_has_data_labels: + data_labels_position: + data_labels_num_format: + data_labels_num_format_is_linked: + data_labels_font_kwargs: + plot_vary_by_cat: + plot_gap_width: + plot_overlap: + smooth_line: + number_format: + xl_number_format: + :return: + """ + + # Switch rows and columns if bar chart + if chart_type == "bar_clustered": + dataframe = dataframe[::-1] + dataframe = dataframe[dataframe.columns[::-1]] + # Switch rows if bar stacked + if chart_type == "bar_stacked_100": + dataframe = dataframe[::-1] + + # =============================== chart data from pandas dataframe + chart_data = chartdata_from_dataframe(dataframe, number_format=number_format, xl_number_format=number_format) + + # =============================== Create chart + # For all chart types + x, y, cx, cy = left, top, width, height + graphic_frame = slide.shapes.add_chart( + chart_type_dct[chart_type], x, y, cx, cy, chart_data) + + chart = graphic_frame.chart + chart.chart_style = chart_style + + # =============================== Fixed y axis + # TODO Will affect legend, will have to adjust legend manually (mainly a grid summary issue) + if fix_yaxis: + if has_legend: + self.fix_yaxis(chart, 'center', legend=legend_position) + else: + self.fix_yaxis(chart, 'center') + + # =============================== Chart title + # Hmm, added but not sure if ever needed + # For all chart types + if has_chart_title: + charttitle = chart.chart_title + self.add_textframe(charttitle, titletext, **textframe_kwargs) + + # =============================== legend properties + # For all chart types + chart.has_legend = has_legend + if has_legend: + legend = chart.legend + legend.include_in_layout = legend_in_layout + legend.position = legend_pos_dct[legend_position] + legend.horz_offset = legend_horz_offset + self.set_font(legend.font, **legend_font_kwargs) + + # ================================ category axis (horizontal axis) properties + # Not relevant for Pie + try: + category_axis = chart.category_axis + except ValueError: + pass + else: + category_axis.has_major_gridlines = caxis_has_major_gridlines + category_axis.has_minor_gridlines = caxis_has_minor_gridlines + category_axis.major_tick_mark = tick_mark_pos_dct[caxis_major_tick_mark] + category_axis.minor_tick_mark = tick_mark_pos_dct[caxis_minor_tick_mark] + category_axis.tick_label_position = tick_label_pos_dct[caxis_tick_label_position] + + category_axis.visible = caxis_visible + if caxis_visible: + caxis_tick_labels = category_axis.tick_labels + caxis_tick_labels.offset = caxis_tick_labels_offset + self.set_font(caxis_tick_labels.font, **caxis_font_kwargs) + + # ================================= value axis (vertical axis) properties + # Not relevant for Pie + try: + value_axis = chart.value_axis + except ValueError: + pass + else: + value_axis.has_major_gridlines = vaxis_has_major_gridlines + value_axis.has_minor_gridlines = vaxis_has_minor_gridlines + value_axis.minor_tick_mark = tick_mark_pos_dct[vaxis_minor_tick_mark] + value_axis.major_tick_mark = tick_mark_pos_dct[vaxis_major_tick_mark] + value_axis.maximum_scale = vaxis_max_scale + value_axis.minimum_scale = vaxis_min_scale + value_axis.major_unit = vaxis_major_unit + value_axis.minor_unit = vaxis_minor_unit + value_axis.tick_label_position = tick_label_pos_dct[vaxis_tick_label_position] + + value_axis.visible = vaxis_visible + if vaxis_visible: + vaxis_tick_labels = value_axis.tick_labels + self.set_font(vaxis_tick_labels.font, **vaxis_font_kwargs) + + if vaxis_tick_labels_num_format is not None: + vaxis_tick_labels.number_format = vaxis_tick_labels_num_format + vaxis_tick_labels.number_format_is_linked = vaxis_tick_labels_num_format_is_linked + + # ================================= set plot area properties + # Not relevant for Pie + plot = chart.plots[0] + plot.vary_by_categories = plot_vary_by_cat + plot.has_data_labels = plot_has_data_labels + plot.gap_width = plot_gap_width + plot.overlap = plot_overlap + + # ================================= data labels + # For all chart types + if plot_has_data_labels: + data_labels = plot.data_labels + data_labels.position = data_label_pos_dct[data_labels_position] + self.set_font(data_labels.font, **data_labels_font_kwargs) + + if data_labels_num_format is not None: + data_labels.number_format = data_labels_num_format + data_labels.number_format_is_linked = data_labels_num_format_is_linked + + if not sig_test_results: sig_test_visible = False + if len(dataframe.columns) == 1: sig_test_visible = False + if sig_test_visible: + self.show_data_labels(plot, decimals=0) + for serie, column in enumerate(sig_test_results[::-1]): + for point, test_result in enumerate(column[::-1]): + if not isinstance(test_result, basestring): continue + for text in ['*.', + '*', + '**.', + '**', + '\'@L\'.', + '\'@L\'', + '\'@H\'.', + '\'@H\'', + ]: + test_result = test_result.replace(text,'') + if test_result == '': continue + text = u' ({})'.format(test_result) + self.edit_datalabel(plot, serie, point, text, prepend=False, append=True) + + # # ================================ series + # for i, ser in enumerate(dataframe.columns): + # ser = plot.series[i] + # try: + # ser.smooth = smooth_line + # except: + # pass + + return chart + + def add_text(self, text): + """ + Adds text to self.textbox['text'] + :param + text: Text to show in self.textbox + :return: None, sets self.textbox + """ + self.textbox['text'] = text + + @staticmethod + def add_textbox(slide, + text=None, + left=Cm(2.33), top=Cm(3.35), width=Cm(29.21), height=Cm(1.78), + rotation=0, + # Are next three below needed? + textbox_fill_solid=False, + textbox_color=(100, 0, 0), + textbox_color_brightness=0, + textframe_kwargs=None, # type: dict + ): + """ + Adds a text box to the given slide and sets all properties for the text box + :param slide: + :param text: + :param left: + :param top: + :param width: + :param height: + :param rotation: + :param textbox_fill_solid: + :param textbox_color: + :param textbox_color_brightness: + :param textframe_kwargs: + :return: + """ + + # ============================== Text Box + # Add and Position text box + textbox = slide.shapes.add_textbox( + left, top, width, height) + + # Clockwise rotation of text box + textbox.rotation = rotation + + # Adds Solid fill to text box + if textbox_fill_solid: + txfill = textbox.fill + txfill.solid() + txfill.fore_color.rgb = RGBColor(*textbox_color) + txfill.fore_color.brightness = textbox_color_brightness + + PptxPainter.add_textframe(textbox, text, **textframe_kwargs) + + return textbox + + @staticmethod + def add_textframe(textbox, + text=None, + fit_text=True, + margin_left=Cm(0.25), + margin_right=Cm(0.25), + margin_top=Cm(0.13), + margin_bottom=Cm(0.13), + vertical_alignment='middle', + horizontal_alignment='left', + font_kwargs=None # type: dict + ): + """ + Adds a textframe to the given textbox and sets all properties for the text frame + + :param textbox: + :param text: + :param fit_text: + :param margin_left: + :param margin_right: + :param margin_top: + :param margin_bottom: + :param vertical_alignment: + :param horizontal_alignment: + :return: textframe + """ + + textframe = textbox.text_frame + + # Text to show + if text is not None: + textframe.text = text + + # Vertical alignment of text in text frame + textframe.vertical_anchor = vertical_alignment_pos_dct[vertical_alignment] + + # Text margin in text frame + textframe.margin_left = margin_left + textframe.margin_bottom = margin_bottom + textframe.margin_right = margin_right + textframe.margin_top = margin_top + + # If textbox has no attribute width we will not be able to use textframe.fit_text + try: + textbox.width + except: + fit_text = False + + # ============================== Paragraph + # Access the only paragraph in the text frame + paragraph = textframe.paragraphs[0] + + # Vertical alignment of paragraph + paragraph.alignment = paragraph_alignment_pos_dct[horizontal_alignment] + + font = paragraph.font + + # If no text we will not be able to do fit_text + if text is None or text == '': + fit_text = False + + PptxPainter.set_font(font, + textframe=textframe, + fit_text=fit_text, + **font_kwargs) + + return textframe + + @staticmethod + def set_font(font_obj, + textframe=None, + fit_text=False, + font_name='Trebuchet MS', + font_size=12, + font_bold=False, + font_italic=False, + font_underline=False, + font_color=(0, 0, 0), + font_color_brightness=0, + font_color_theme=None): + + ''' + Does all font settings on the Font object + :param + font_obj: Object, The Font Instance + textframe: Need a textframe object, if fit_text==True + fit_text: Bool - True = Scale the font size to fit the text box. Requires a textframe + font_name: Str + font_file: Str - Relative path to a font file + font_size: Int + font_italic: Bool + font_underline: Bool + font_color: Tuple of Int, (R, G, B) + :return: font, The Font Instance + ''' + + font = font_obj + + # Resize text to fit textframe + if not textframe == None and fit_text == True: + # if font_name == "Raleway": + # font_file = os.path.join(thisdir, default_font_file) + # textframe.fit_text(font_family=font_name, max_size=font_size, bold=font_bold, + # italic=font_italic, font_file=font_file) + # else: + textframe.fit_text(font_family=font_name, max_size=font_size, bold=font_bold, + italic=font_italic) + + # ============================== Font + # Font color + font.color.rgb = RGBColor(*font_color) + font.underline = font_underline + + # Font name/size/bold/italic if not set with textframe.fit_text + if fit_text == False: + font.name = font_name + font.size = Pt(font_size) + font.bold = font_bold + font.italic = font_italic + + # Add color theme + if font_color_theme is not None: + font.color.theme_color = theme_color_index_dct[font_color_theme] + + # Font color brightness + font.color.brightness = font_color_brightness + + return font + + @staticmethod + def fix_yaxis(chart, fix_point, legend=None): + """ + Method to fix the vertical axis in a charts plotArea + :param + chart: An instance of a Chart object + fix_point: Where to fix the vertical axis (Not implemented - TODO) + :return: None, will edit the plotArea in place + """ + + if legend=='right': + xml_string = """<c:layout xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"> + <c:manualLayout> + <c:layoutTarget val="inner"/> + <c:xMode val="edge"/> + <c:yMode val="edge"/> + <c:x val="0.41682566853056413"/> + <c:y val="3.3743961352657004E-2"/> + <c:w val="0.45661636045494312"/> + <c:h val="0.89697898550724642"/> + </c:manualLayout> + </c:layout>""" + else: + xml_string = """<c:layout xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"> + <c:manualLayout> + <c:layoutTarget val="inner"/> + <c:xMode val="edge"/> + <c:yMode val="edge"/> + <c:x val="0.41682566853056413"/> + <c:y val="3.3743961352657004E-2"/> + <c:w val="0.55661636045494312"/> + <c:h val="0.89697898550724642"/> + </c:manualLayout> + </c:layout>""" + + xml_insert = etree.fromstring(xml_string) + chart._element.plotArea.append(xml_insert) + + @staticmethod + def add_net(slide, + df, + left=Cm(27.55), top=Cm(3.69), width=Cm(1.8), # width for 1 column + height=Cm(10.68), + margin_left=0.0, + margin_right=0.0, + margin_top=0.0, + margin_bottom=0.0, + + # side_member_font_size=8, + # side_member_font_name='Trebuchet MS', + # side_member_font_bold=False, + # side_member_font_italic=False, + # side_member_font_color=(109,111,113), + # side_member_font_para_alignment=PP_ALIGN.LEFT, + # side_member_vert_alignment=MSO_ANCHOR.MIDDLE, + # sidemember_shading=True, + # sidemember_shading_color=(255,255,255), + + top_member_font_size=8, + top_member_font_name='Trebuchet MS', + top_member_font_bold=False, + top_member_font_italic=False, + top_member_font_color=(0,0,0), + top_member_font_para_alignment=paragraph_alignment_pos_dct['center'], + top_member_vert_alignment=vertical_alignment_pos_dct['middle'], + top_member_shading=True, + top_member_shading_color=(255,255,255), + + values_font_size=8, + values_font_name='Trebuchet MS', + values_font_bold=False, + values_font_italic=False, + values_font_color=(0,0,0), + values_font_para_alignment=paragraph_alignment_pos_dct['center'], + values_vert_alignment=vertical_alignment_pos_dct['top'], + values_shading=True, + values_shading_shading_color=(255,255,255), + ): + #------------------------------------------------------------------------- + + rows = len(df.index) + cols = len(df.columns) + + # Height of table and rows + header_row_height = Cm(1.7) + if rows == 1: + top = top + int(round(height * (0.3 / rows)) - header_row_height) + else: + top = top + int(round(height* (0.45/rows)) - header_row_height) + plot_area = int(round(height * 0.9)) - Cm(0.4) + value_row_height = int(round(plot_area / rows)) + height = header_row_height + rows * value_row_height + + # Width of table + width = width * cols + + shapes = slide.shapes + table = shapes.add_table(rows+1, cols, left, top, width, height).table + table.horz_banding = True + #isolate seperate sections of a table + row_labels = list(df.index) + col_labels = list(df.columns) + table_values = df.values + #question_label = df.index.get_level_values(level=0)[0] + + #table specific properties + for i in range(0, rows + 1): + if i == 0: + table.rows[i].height = header_row_height + else: + table.rows[i].height = value_row_height + + for x in range(0, cols): + + cell = table.cell(i, x) + + cell.margin_left= Cm(margin_left) + cell.margin_right = Cm(margin_right) + cell.margin_top = Cm(margin_top) + cell.margin_bottom = Cm(margin_bottom) + + #add col labels + for idx, col_label in enumerate(col_labels): + + #table.columns[0].width = Emu(first_column_width) + + cell = table.cell(0, idx) + cell.vertical_anchor = top_member_vert_alignment + + if top_member_shading: + if top_member_shading_color == "No fill": + fill = cell.fill + fill.background() + else: + cfill = cell.fill + cfill.solid() + cfill.fore_color.rgb = RGBColor(*top_member_shading_color) + #cfill.fore_color.brightness = textbox_color_brightness + + textframe = cell.text_frame + paragraph = textframe.paragraphs[0] + paragraph.font.size = Pt(top_member_font_size) + paragraph.font.name = top_member_font_name + paragraph.font.bold = top_member_font_bold + paragraph.font.italic = top_member_font_italic + paragraph.font.color.rgb = RGBColor(*top_member_font_color) + paragraph.alignment = top_member_font_para_alignment + + cell.text = col_label + + #add values + for i, val in enumerate(table_values): + for x, subval in enumerate(val): + + cell = table.cell(i+1, x) + cell.vertical_anchor = values_vert_alignment + cell.margin_top = Cm(0.1) + + if values_shading: + if values_shading_shading_color == "No fill": + fill = cell.fill + fill.background() + else: + cfill = cell.fill + cfill.solid() + cfill.fore_color.rgb = RGBColor(*values_shading_shading_color) + + textframe = cell.text_frame + paragraph = textframe.paragraphs[0] + paragraph.font.size = Pt(values_font_size) + paragraph.font.name = values_font_name + paragraph.font.bold = values_font_bold + paragraph.font.italic = values_font_italic + paragraph.font.color.rgb = RGBColor(*values_font_color) + paragraph.alignment = values_font_para_alignment + #paragraph.line_spacing = Pt(6) + cell.text = str(subval) + diff --git a/quantipy/sandbox/pptx/__init__.py b/quantipy/sandbox/pptx/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/quantipy/sandbox/pptx/enumerations.py b/quantipy/sandbox/pptx/enumerations.py new file mode 100644 index 000000000..10dcb46d9 --- /dev/null +++ b/quantipy/sandbox/pptx/enumerations.py @@ -0,0 +1,157 @@ +# encoding: utf-8 + +''' +@author: Majeed.sahebzadha +''' + +from pptx.enum.chart import( + XL_CHART_TYPE, + XL_LABEL_POSITION, + XL_LEGEND_POSITION, + XL_TICK_MARK, + XL_TICK_LABEL_POSITION + ) +from pptx.enum.dml import( + MSO_THEME_COLOR, + MSO_COLOR_TYPE, + MSO_FILL + ) +from pptx.enum.text import( + PP_ALIGN, + MSO_AUTO_SIZE, + MSO_ANCHOR + ) + +#------------------------------------------------------------------------------ +#------------------------------------------------------------------------------- + +''' +See: http://python-pptx.readthedocs.io/en/latest/api/enum/index.html +TO DO: add individual description for each enum +''' + +# Specifies the type of bitmap used for the fill of a shape +fill_type_dct = { + 'background': MSO_FILL.BACKGROUND, + 'gradient': MSO_FILL.GRADIENT, + 'group': MSO_FILL.GROUP, + 'patterned': MSO_FILL.PATTERNED, + 'picture': MSO_FILL.PICTURE, + 'solid': MSO_FILL.SOLID, + 'textured': MSO_FILL.TEXTURED + } + +# Specifies where the data label is positioned +data_label_pos_dct = { + 'above': XL_LABEL_POSITION.ABOVE, + 'below': XL_LABEL_POSITION.BELOW, + 'best_fit': XL_LABEL_POSITION.BEST_FIT, + 'center': XL_LABEL_POSITION.CENTER, + 'inside_base': XL_LABEL_POSITION.INSIDE_BASE, + 'inside_end': XL_LABEL_POSITION.INSIDE_END, + 'left': XL_LABEL_POSITION.LEFT, + 'mixed': XL_LABEL_POSITION.MIXED, + 'outside_end': XL_LABEL_POSITION.OUTSIDE_END, + 'right': XL_LABEL_POSITION.RIGHT + } + +# Specifies the position of the legend on a chart +legend_pos_dct = { + 'bottom': XL_LEGEND_POSITION.BOTTOM, + 'corner': XL_LEGEND_POSITION.CORNER, + 'custom': XL_LEGEND_POSITION.CUSTOM, + 'left': XL_LEGEND_POSITION.LEFT, + 'right': XL_LEGEND_POSITION.RIGHT, + 'top': XL_LEGEND_POSITION.TOP + } + +# Specifies the position of tick-mark labels on a chart axis +tick_label_pos_dct = { + 'high': XL_TICK_LABEL_POSITION.HIGH, + 'low': XL_TICK_LABEL_POSITION.LOW, + 'next_to_axis': XL_TICK_LABEL_POSITION.NEXT_TO_AXIS, + 'none': XL_TICK_LABEL_POSITION.NONE + } + +# Specifies a type of axis tick for a chart. +tick_mark_pos_dct = { + 'cross': XL_TICK_MARK.CROSS, #Tick mark crosses the axis + 'inside': XL_TICK_MARK.INSIDE, #Tick mark appears inside the axis + 'none': XL_TICK_MARK.NONE, #No tick mark + 'outside': XL_TICK_MARK.OUTSIDE #Tick mark appears outside the axis + } + +# Specifies the vertical alignment of text in a text frame +vertical_alignment_pos_dct = { + 'top': MSO_ANCHOR.TOP, + 'middle': MSO_ANCHOR.MIDDLE, + 'bottom': MSO_ANCHOR.BOTTOM, + 'mixed': MSO_ANCHOR.MIXED + } + +# Specifies the horizontal alignment for one or more paragraphs +paragraph_alignment_pos_dct = { + 'center': PP_ALIGN.CENTER, + 'distribute': PP_ALIGN.DISTRIBUTE, + 'justify': PP_ALIGN.JUSTIFY, + 'justify_low': PP_ALIGN.JUSTIFY_LOW, + 'left': PP_ALIGN.LEFT, + 'right': PP_ALIGN.RIGHT, + 'thai_distribute': PP_ALIGN.THAI_DISTRIBUTE, + 'mixed': PP_ALIGN.MIXED + } + +# Indicates the Office theme color, one of those shown in the color gallery on the formatting ribbon +theme_color_index_dct = { + 'not_theme_color': MSO_THEME_COLOR.NOT_THEME_COLOR, + 'accent_1': MSO_THEME_COLOR.ACCENT_1, + 'accent_2': MSO_THEME_COLOR.ACCENT_2, + 'accent_3': MSO_THEME_COLOR.ACCENT_3, + 'accent_4': MSO_THEME_COLOR.ACCENT_4, + 'accent_5': MSO_THEME_COLOR.ACCENT_5, + 'accent_6': MSO_THEME_COLOR.ACCENT_6, + 'background_1': MSO_THEME_COLOR.BACKGROUND_1, + 'background_2': MSO_THEME_COLOR.BACKGROUND_2, + 'dark_1': MSO_THEME_COLOR.DARK_1, + 'dark_2': MSO_THEME_COLOR.DARK_2, + 'followed_hyperlink': MSO_THEME_COLOR.FOLLOWED_HYPERLINK, + 'hyperlink': MSO_THEME_COLOR.HYPERLINK, + 'light_1': MSO_THEME_COLOR.LIGHT_1, + 'light_2': MSO_THEME_COLOR.LIGHT_2, + 'text_1': MSO_THEME_COLOR.TEXT_1, + 'text_2': MSO_THEME_COLOR.TEXT_2, + 'mixed': MSO_THEME_COLOR.MIXED + } + +# Specifies the type of a chart +chart_type_dct = { + 'area': XL_CHART_TYPE.AREA, + 'area_stacked': XL_CHART_TYPE.AREA_STACKED, + 'area_stacked_100': XL_CHART_TYPE.AREA_STACKED_100, + 'bar_clustered': XL_CHART_TYPE.BAR_CLUSTERED, + 'bar_stacked': XL_CHART_TYPE.BAR_STACKED, + 'bar_stacked_100': XL_CHART_TYPE.BAR_STACKED_100, + 'column_clustered': XL_CHART_TYPE.COLUMN_CLUSTERED, + 'column_stacked': XL_CHART_TYPE.COLUMN_STACKED, + 'column_stacked_100': XL_CHART_TYPE.COLUMN_STACKED_100, + 'doughnut': XL_CHART_TYPE.DOUGHNUT, + 'doughnut_exploded': XL_CHART_TYPE.DOUGHNUT_EXPLODED, + 'line': XL_CHART_TYPE.LINE, + 'line_markers': XL_CHART_TYPE.LINE_MARKERS, + 'line_markers_stacked': XL_CHART_TYPE.LINE_MARKERS_STACKED, + 'line_markers_stacked_100': XL_CHART_TYPE.LINE_MARKERS_STACKED_100, + 'line_stacked': XL_CHART_TYPE.LINE_STACKED, + 'line_stacked_100': XL_CHART_TYPE.LINE_STACKED_100, + 'pie': XL_CHART_TYPE.PIE, + 'pie_exploded': XL_CHART_TYPE.PIE_EXPLODED, + 'radar': XL_CHART_TYPE.RADAR, + 'radar_filled': XL_CHART_TYPE.RADAR_FILLED, + 'radar_markers': XL_CHART_TYPE.RADAR_MARKERS, + 'xy_scatter': XL_CHART_TYPE.XY_SCATTER, + 'xy_scatter_lines': XL_CHART_TYPE.XY_SCATTER_LINES, + 'xy_scatter_lines_no_markers': XL_CHART_TYPE.XY_SCATTER_LINES_NO_MARKERS, + 'xy_scatter_smooth': XL_CHART_TYPE.XY_SCATTER_SMOOTH, + 'xy_scatter_smooth_no_markers': XL_CHART_TYPE.XY_SCATTER_SMOOTH_NO_MARKERS, + 'bubble': XL_CHART_TYPE.BUBBLE, + 'bubble_three_d_effect': XL_CHART_TYPE.BUBBLE_THREE_D_EFFECT + } diff --git a/quantipy/sandbox/pptx/pptx_defaults.py b/quantipy/sandbox/pptx/pptx_defaults.py new file mode 100644 index 000000000..fa47586b3 --- /dev/null +++ b/quantipy/sandbox/pptx/pptx_defaults.py @@ -0,0 +1,290 @@ +# encoding: utf-8 + +from collections import OrderedDict + +import pandas as pd + +# ---------------------------------------------------------------------------- +# Font defaults + +default_font_name='Trebuchet MS' +# default_font_file='fonts\Raleway-Regular.ttf' + +default_font = OrderedDict([ + ('font_name', default_font_name), + ('font_size', 9), + ('font_bold', False), + ('font_italic', False), + ('font_underline', False), + ('font_color', (89, 89, 89)), + ('font_color_brightness', 0), + ('font_color_theme', None), +]) + +# Chart Legend +default_font_legend = default_font.copy() + +# Chart Category axis +default_font_caxis = default_font.copy() + +# Chart Value axis +default_font_vaxis = default_font.copy() +default_font_vaxis['font_bold'] = True + +# Chart data labels +default_font_data_label = default_font.copy() +default_font_data_label['font_size'] = 8.5 +default_font_data_label['font_color'] = (0, 0, 0) + +# ---------------------------------------------------------------------------- +# Textframe defaults + +default_textframe = OrderedDict([ + ('fit_text', True), + ('margin_left', 90000), # Cm(0.25) + ('margin_right', 90000), # Cm(0.25) + ('margin_top', 46800), # Cm(0.13) + ('margin_bottom', 46800), # Cm(0.13) + ('vertical_alignment', 'top'), + ('horizontal_alignment', 'left'), + ('font_kwargs', default_font.copy()), +]) + +# --------------------------------------------------------------------------- +# Textbox defaults +default_textbox = OrderedDict([ + ('text', ''), + ('left', 831600), # Cm(2.31) + ('top', 1170000), # Cm(3.25) + ('width', 10522800), # Cm(29.23) + ('height', 630000), # Cm(1.75) + ('rotation', 0), + ('textbox_fill_solid', False), + ('textbox_color', (100, 0, 0)), + ('textbox_color_brightness', 0), + ('textframe_kwargs', default_textframe.copy()), +]) + +# --------------------------------------------------------------------------- +# Table cell defaults +default_cell_kwargs = OrderedDict([ + ('margin_left', 36000), # Cm(0.1) + ('margin_right', 36000), # Cm(0.1) + ('margin_top', 36000), # Cm(0.1) + ('margin_bottom', 36000), # Cm(0.1) + ('vertical_alignment', 'top'), + ('shading', True), + ('shading_color', (255,255,255)), +]) + +# ----------------------------------------------------------------------------- +# Table defaults +default_table = OrderedDict([ + ('dataframe', pd.DataFrame()), + ('text', None), + ('left', 838800), ('top', 1476000), ('width', 10515600), ('height', 4140000), + + ('show_side_member', True), + ('side_member_column_width', 2160000), # Cm(6) + ('side_member_textframe_kwargs', default_textframe.copy()), + ('side_member_cell_kwargs', default_cell_kwargs.copy()), + + ('show_top_member', True), + ('top_member_row_height', 360000), # Cm(1) + ('top_member_textframe_kwargs', default_textframe.copy()), + ('top_member_cell_kwargs', default_cell_kwargs.copy()), + + ('values_row_height', 360000), # Cm(1) + ('values_column_width', 720000), # Cm(2) + ('values_textframe_kwargs', default_textframe.copy()), + ('values_cell_kwargs', default_cell_kwargs.copy()), + ('values_prefix', None), + ('values_prefix_columns', 'all'), + + ('values_suffix', None), + ('values_suffix_columns', 'all'), + + ('top_left_corner_textframe_kwargs', default_textframe.copy()), + ('top_left_corner_cell_kwargs', default_cell_kwargs.copy()), +]) + +default_side_table = default_table.copy() +default_side_table['show_side_member'] = False +default_side_table['values_column_width'] = 648000 # Cm(1.8) +default_side_table['top_member_row_height'] = 612000 # Cm(1.7) +default_side_table['values_textframe_kwargs'] = default_textframe.copy() +default_side_table['values_textframe_kwargs']['horizontal_alignment'] = 'center' +default_side_table['values_textframe_kwargs']['font_kwargs'] = default_font.copy() +default_side_table['values_textframe_kwargs']['font_kwargs']['font_size'] = 8 + +default_side_table['top_member_textframe_kwargs'] = default_textframe.copy() +default_side_table['top_member_textframe_kwargs']['horizontal_alignment'] = 'center' +default_side_table['top_member_textframe_kwargs']['font_kwargs'] = default_font.copy() +default_side_table['top_member_textframe_kwargs']['font_kwargs']['font_size'] = 8 + +default_side_table['top_member_cell_kwargs'] = default_cell_kwargs.copy() +default_side_table['top_member_cell_kwargs']['vertical_alignment'] = 'middle' + +default_side_table['side_member_textframe_kwargs']['font_kwargs'] = default_font.copy() +default_side_table['side_member_textframe_kwargs']['font_kwargs']['font_size'] = 8 + +# ------------------------------------------------------------------------------------------- +# Chart defaults (Bar_clustered 1 series) + +default_chart = OrderedDict([ + ('dataframe', pd.DataFrame()), + ('chart_type', 'bar_clustered'), + ('left', 838800), ('top', 1476000), ('width', 10515600), ('height', 4140000), + ('chart_style', 2), + + # Title + ('has_chart_title', False), + ('titletext', None), + ('textframe_kwargs', default_textframe.copy()), + + # Legend properties + ('has_legend', False), + ('legend_position', 'right'), + ('legend_in_layout', False), # will we ever set this True? + ('legend_horz_offset', 0.1583), + ('legend_font_kwargs', default_font_legend.copy()), + + # Category axis properties + ('caxis_visible', True), + ('caxis_tick_label_position', 'low'), + ('caxis_tick_labels_offset', 730), + ('caxis_has_major_gridlines', False), + ('caxis_has_minor_gridlines', False), + ('caxis_major_tick_mark', 'outside'), + ('caxis_minor_tick_mark', 'none'), + ('caxis_font_kwargs', default_font_caxis.copy()), + + # Value axis properties + ('vaxis_visible', True), + ('vaxis_tick_label_position', 'low'), + ('vaxis_has_major_gridlines', True), + ('vaxis_has_minor_gridlines', False), + ('vaxis_major_tick_mark', 'outside'), + ('vaxis_minor_tick_mark', 'none'), + ('vaxis_max_scale', 1.0), + ('vaxis_min_scale', 0.0), + ('vaxis_major_unit', 0.1), + ('vaxis_minor_unit', None), + ('vaxis_tick_labels_num_format', '0%'), + ('vaxis_tick_labels_num_format_is_linked', False), + ('vaxis_font_kwargs', default_font_vaxis.copy()), + + # Datalabel properties + ('plot_has_data_labels', True), + ('data_labels_position', 'outside_end'), + ('data_labels_num_format', '0%'), + ('data_labels_num_format_is_linked', False), + ('data_labels_font_kwargs', default_font_data_label.copy()), + + # Plot properties + ('plot_vary_by_cat', False), + ('plot_gap_width', 150), + ('plot_overlap', -10), + + # Number format + ('number_format', '0.00%'), + ('xl_number_format', '0.00%'), + # Sig_testing + ('sig_test_visible', False), + ('sig_test_results', None), +]) + +# -------------------------- +# Bar_Clustered +default_chart_bar = default_chart.copy() +# fix y axis (False, 'center'), Currently only an option for bar chart, legend is not available if used. +default_chart_bar['fix_yaxis'] = False + +# -------------------------- +# Bar_Stacked_100% +default_chart_bar_stacked100 = default_chart.copy() +default_chart_bar_stacked100['chart_type'] = 'bar_stacked_100' +# Legend properties +default_chart_bar_stacked100['has_legend'] = True +default_chart_bar_stacked100['legend_horz_offset'] = 0 +# Datalabel properties +default_chart_bar_stacked100['data_labels_position'] = 'center' +# Plot properties +# default_chart_bar_stacked100['plot_vary_by_cat'] = True +default_chart_bar_stacked100['plot_overlap'] = 100 + +# --------------------------- +# Line +default_chart_line = default_chart.copy() +default_chart_line['chart_type'] = 'line' +# Legend properties +default_chart_line['legend_position'] = 'bottom' +default_chart_line['legend_horz_offset'] = 0 +# Category axis properties +default_chart_line['caxis_tick_label_position'] = 'low' +default_chart_line['caxis_tick_labels_offset'] = 100 +# Datalabel properties +default_chart_line['data_labels_position'] = 'above' +# Plot properties +default_chart_line['plot_overlap'] = 10 +default_chart_line['smooth_line'] = False + +# ---------------------------- +# Column +default_chart_column = default_chart.copy() +default_chart_column['chart_type'] = 'column_clustered' +# Legend properties +default_chart_column['legend_position'] = 'bottom' +default_chart_column['legend_horz_offset'] = 0 +# Category axis properties +default_chart_column['caxis_tick_label_position'] = 'next_to_axis' +default_chart_column['caxis_tick_labels_offset'] = 100 +# Plot properties +default_chart_column['plot_overlap'] = -10 + +# --------------------------- +# Pie +default_chart_pie = default_chart.copy() +default_chart_pie['chart_type'] = 'pie' +# Legend properties +default_chart_pie['has_legend'] = True +default_chart_pie['legend_position'] = 'bottom' +default_chart_pie['legend_horz_offset'] = 0 +# Plot properties +default_chart_pie['plot_vary_by_cat'] = True + +# ---------------------------- +# Question_text-dict for default_slide_kwargs +header_shape = default_textbox.copy() +header_shape['left'] = 838800 +header_shape['top'] = 1026000 +header_shape['width'] = 10515600 +header_shape['height'] = 468000 +header_shape['textframe_kwargs'] = default_textframe.copy() +header_shape['textframe_kwargs']['font_kwargs'] = default_font.copy() +header_shape['textframe_kwargs']['font_kwargs']['font_size']=11 +header_shape['textframe_kwargs']['font_kwargs']['font_bold']=True +header_shape['textframe_kwargs']['font_kwargs']['font_italic']=True + +# ---------------------------- +# Base_description-dict for default_slide_kwargs +footer_shape = default_textbox.copy() +footer_shape['left'] = 838800 +footer_shape['top'] = 5652000 +footer_shape['width'] = 10515600 +footer_shape['height'] = 396000 +footer_shape['textframe_kwargs'] = default_textframe.copy() +footer_shape['textframe_kwargs']['font_kwargs'] = default_font.copy() +footer_shape['textframe_kwargs']['font_kwargs']['font_bold'] = True + +shapes = {'charts' : {'bar': default_chart_bar, + 'bar_stacked100': default_chart_bar_stacked100, + 'line': default_chart_line, + 'column': default_chart_column, + 'pie': default_chart_pie}, + 'textboxes' : {'header': header_shape, + 'footer': footer_shape}, + 'tables' : {'table' : default_table, + 'side_table': default_side_table}, + } + diff --git a/quantipy/sandbox/sandbox.py b/quantipy/sandbox/sandbox.py index fa8bc23cf..72114274a 100644 --- a/quantipy/sandbox/sandbox.py +++ b/quantipy/sandbox/sandbox.py @@ -69,6 +69,7 @@ def __init__(self, stack): self.__chains = [] self.source = 'native' self.build_info = {} + self._hidden = [] def __str__(self): return '\n'.join([chain.__str__() for chain in self]) @@ -104,6 +105,9 @@ def __next__(self): raise StopIteration next = __next__ + def add_chain(self, chain): + self.__chains.append(chain) + @property def folders(self): """ @@ -160,6 +164,20 @@ def single_names(self): """ return [s.name for s in self if isinstance(s, Chain)] + @property + def hidden(self): + """ + All ``qp.Chain`` elements that are hidden. + """ + return [c.name for c in self.chains if c.hidden] + + @property + def hidden_folders(self): + """ + All hidden folders. + """ + return [n for n in self._hidden if n in self.folder_names] + def _content_structure(self): return ['folder' if isinstance(k, dict) else 'single' for k in self] @@ -379,6 +397,110 @@ def load(path): f.close() return obj + def _toggle_vis(self, chains, mode='hide'): + if not isinstance(chains, list): chains = [chains] + for chain in chains: + if isinstance(chain, dict): + fname = chain.keys()[0] + elements = chain.values()[0] + fidx = self._idx_from_name(fname) + folder = self[fidx][fname] + for c in folder: + if c.name in elements: + c.hidden = True if mode == 'hide' else False + if mode == 'hide' and not c.name in self._hidden: + self._hidden.append(c.name) + if mode == 'unhide' and c.name in self._hidden: + self._hidden.remove(c.name) + else: + if chain in self.folder_names: + for c in self[chain]: + c.hidden = True if mode == 'hide' else False + else: + self[chain].hidden = True if mode == 'hide' else False + if mode == 'hide': + if not chain in self._hidden: + self._hidden.append(chain) + else: + if chain in self._hidden: + self._hidden.remove(chain) + return None + + def hide(self, chains): + """ + Flag elements as being hidden. + + Parameters + ---------- + chains : (list) of int and/or str or dict + The ``qp.Chain`` item and/or folder names to hide. To hide *within* + a folder use a dict to map the desired Chain names to the belonging + folder name. + + Returns + ------- + None + """ + self._toggle_vis(chains, 'hide') + return None + + def unhide(self, chains=None): + """ + Unhide elements that have been set as ``hidden``. + + Parameters + ---------- + chains : (list) of int and/or str or dict, default None + The ``qp.Chain`` item and/or folder names to unhide. To unhide *within* + a folder use a dict to map the desired Chain names to the belonging + folder name. If not provided, all hidden elements will be unhidden. + + Returns + ------- + None + """ + if not chains: chains = self.folder_names + self.single_names + self._toggle_vis(chains, 'unhide') + return None + + def clone(self): + """ + Return a full (deep) copy of self. + """ + return copy.deepcopy(self) + + def insert(self, other_cm, index=-1, safe_names=False): + """ + Add elements from another ``ChainManager`` instance to self. + + Parameters + ---------- + other_cm : ``quantipy.ChainManager`` + A ChainManager instance to draw the elements from. + index : int, default -1 + The positional index after which new elements will be added. + Defaults to -1, i.e. elements are appended at the end. + safe_names : bool, default False + If True and any duplicated element names are found after the + operation, names will be made unique (by appending '_1', '_2', '_3', + etc.). + + Returns + ------ + None + """ + if not isinstance(other_cm, ChainManager): + raise ValueError("other_cm must be a quantipy.ChainManager instance.") + if not index == -1: + before_c = self.__chains[:index+1] + after_c = self.__chains[index+1:] + new_chains = before_c + other_cm.__chains + after_c + self.__chains = new_chains + else: + self.__chains.extend(other_cm.__chains) + if safe_names: self._uniquify_names() + return None + def merge(self, folders, new_name=None, drop=True): """ Unite the items of two or more folders, optionally providing a new name. @@ -485,7 +607,7 @@ def fold(self, folder_name=None, chains=None): self.__chains[self._singles_to_idx()[s.name]] = {s.name: [s]} return None - def unfold(self, folder): + def unfold(self, folder=None): """ Remove folder but keep the collected items. @@ -494,24 +616,31 @@ def unfold(self, folder): Parameters ---------- - folder : str - The name of the folder to drop and extract items from. + folder : (list of) str, default None + The name of the folder to drop and extract items from. If not + provided all folders will be unfolded. Returns ------- None """ - if not folder in self.folder_names: - err = "A folder named '{}' does not exist!".format(folder) - raise KeyError(err) - old_pos = self._idx_from_name(folder) - items = self[folder] - start = self.__chains[: old_pos] - end = self.__chains[old_pos + 1: ] - self.__chains = start + items + end + if not folder: + folder = self.folder_names + else: + if not isinstance(folder, list): folder = [folder] + invalid = [f for f in folder if f not in self.folder_names] + if invalid: + err = "Folder(s) named '{}' not found.".format(invalid) + raise KeyError(err) + for f in folder: + old_pos = self._idx_from_name(f) + items = self[f] + start = self.__chains[: old_pos] + end = self.__chains[old_pos + 1: ] + self.__chains = start + items + end return None - def remove(self, chains, folder=None): + def remove(self, chains, folder=None, inplace=True): """ Remove (folders of) ``qp.Chain`` items by providing a list of indices or names. @@ -524,27 +653,151 @@ def remove(self, chains, folder=None): folder : str, default None If a folder name is provided, items will be dropped within that folder only instead of removing all found instances. + inplace : bool, default True + By default the new order is applied inplace, set to ``False`` to + return a new object instead. Returns ------- None """ + if inplace: + cm = self + else: + cm = self.clone() if folder: - org_chains, org_index = self._set_to_folderitems(folder) + org_chains, org_index = cm._set_to_folderitems(folder) if not isinstance(chains, list): chains = [chains] - remove_idxs= [c if isinstance(c, int) else self._idx_from_name(c) + remove_idxs= [c if isinstance(c, int) else cm._idx_from_name(c) for c in chains] - if self._dupes_in_chainref(remove_idxs): + if cm._dupes_in_chainref(remove_idxs): err = "Cannot remove with duplicate chain references: {}" raise ValueError(err.format(remove_idxs)) new_items = [] - for pos, c in enumerate(self): + for pos, c in enumerate(cm): if not pos in remove_idxs: new_items.append(c) - self.__chains = new_items - if folder: self._rebuild_org_folder(folder, org_chains, org_index) + cm.__chains = new_items + if folder: cm._rebuild_org_folder(folder, org_chains, org_index) + if inplace: + return None + else: + return cm + + def cut(self, values, ci=None, base=False, tests=False): + """ + Isolate selected axis values in the ``Chain.dataframe``. + + Parameters + ---------- + values : (list of) str + The string must indicate the raw (i.e. the unpainted) second level + axis value, e.g. ``'mean'``, ``'net_1'``, etc. + ci : {'counts', 'c%', None}, default None + The cell item version to target if multiple frequency representations + are present. + base : bool, default False + Controls keeping any existing base view aggregations. + tests : bool, default False + Controls keeping any existing significance test view aggregations. + + Returns + ------- + None + """ + if not isinstance(values, list): values = [values] + if 'cbase' in values: + values[values.index('cbase')] = 'All' + if base and not 'All' in values: + values = ['All'] + values + for c in self.chains: + # force ci parameter for proper targeting on array summaries... + if c.array_style == 0 and ci is None: + _ci = c.cell_items.split('_')[0] + if not _ci.startswith('counts'): + ci = '%' + else: + ci = 'counts' + if c.sig_test_letters: c._remove_letter_header() + idxs, names, order = c._view_idxs( + values, keep_tests=tests, keep_bases=base, names=True, ci=ci) + idxs = [i for _, i in sorted(zip(order, idxs))] + names = [n for _, n in sorted(zip(order, names))] + if c.ci_count > 1: c._non_grouped_axis() + if c.array_style == 0: + c._fill_cells() + start, repeat = c._row_pattern(ci) + c._frame = c._frame.iloc[start::repeat, idxs] + else: + c._frame = c._frame.iloc[idxs, :] + c.index = c._slice_edited_index(c.index, idxs) + new_views = OrderedDict() + for v in c.views.copy(): + if not v in names: + del c._views[v] + else: + c._views[v] = names.count(v) + if not c._array_style == 0: + if not tests: + c.sig_test_letters = None + else: + c._frame = c._apply_letter_header(c._frame) + c.edited = True + + return None + + def join(self, title='Summary'): + """ + Join **all** ``qp.Chain```elements, concatenating along the matching axis. + + Parameters + ---------- + title : {str, 'auto'}, default 'Summary' + The new title for the joined axis' index representation. + + Returns + ------- + None + """ + custom_views = [] + self.unfold() + chains = self.chains + totalmul = len(chains[0]._frame.columns.get_level_values(0).tolist()) + concat_dfs = [] + new_labels = [] + for c in chains: + new_label = [] + if c.sig_test_letters: + c._remove_letter_header() + c._frame = c._apply_letter_header(c._frame) + df = c.dataframe + + if not c.array_style == 0: + new_label.append(df.index.get_level_values(0).values.tolist()[0]) + new_label.extend((len(c.describe()) - 1) * ['']) + else: + new_label.extend(df.index.get_level_values(1).values.tolist()) + names = ['Question', 'Values'] + join_idx = pd.MultiIndex.from_product([[title], new_label], names=names) + df.index = join_idx + + df.rename(columns={c._x_keys[0]: 'Total'}, inplace=True) + + if not c.array_style == 0: + custom_views.extend(c._views_per_rows()) + else: + df.columns.set_levels(levels=[title]*totalmul, level=0, inplace=True) + + concat_dfs.append(df) + + new_df = pd.concat(concat_dfs, axis=0, join='inner') + self.chains[0]._frame = new_df + self.reorder([0]) + self.rename({self.single_names[0]: title}) + self.fold() + self.chains[0]._custom_views = custom_views return None - def reorder(self, order, folder=None): + def reorder(self, order, folder=None, inplace=True): """ Reorder (folders of) ``qp.Chain`` items by providing a list of new indices or names. @@ -559,11 +812,18 @@ def reorder(self, order, folder=None): If a folder name is provided, items will be sorted within that folder instead of applying the sorting to the general items collection. + inplace : bool, default True + By default the new order is applied inplace, set to ``False`` to + return a new object instead. Returns ------- None """ + if inplace: + cm = self + else: + cm = self.clone() if folder: org_chains, org_index = self._set_to_folderitems(folder) if not isinstance(order, list): @@ -575,13 +835,16 @@ def reorder(self, order, folder=None): new_idx_order.append(o) else: new_idx_order.append(self._idx_from_name(o)) - if self._dupes_in_chainref(new_idx_order): + if cm._dupes_in_chainref(new_idx_order): err = "Cannot reorder from duplicate qp.Chain references: {}" raise ValueError(err.format(new_idx_order)) items = [self.__chains[idx] for idx in new_idx_order] - self.__chains = items - if folder: self._rebuild_org_folder(folder, org_chains, org_index) - return None + cm.__chains = items + if folder: cm._rebuild_org_folder(folder, org_chains, org_index) + if inplace: + return None + else: + return cm def rename(self, names, folder=None): """ @@ -651,7 +914,15 @@ def _native_stat_names(self, idxvals_list, text_key=None): native_stat_names.append(val) return native_stat_names - def describe(self, by_folder=False): + def _get_ykey_mapping(self): + ys = [] + letters = string.ascii_uppercase + string.ascii_lowercase + for c in self.chains: + if c._y_keys not in ys: + ys.append(c._y_keys) + return zip(ys, letters) + + def describe(self, by_folder=False, show_hidden=False): """ Get a structual summary of all ``qp.Chain`` instances found in self. @@ -661,6 +932,9 @@ def describe(self, by_folder=False): If True, only information on ``dict``-structured (folder-like) ``qp.Chain`` items is shown, multiindexed by folder names and item enumerations. + show_hidden : bool, default False + If True, the summary will also include elements that have been set + hidden using ``self.hide()``. Returns ------- @@ -672,7 +946,10 @@ def describe(self, by_folder=False): names = [] array_sum = [] sources = [] + banner_ids = [] item_pos = [] + hidden = [] + bannermap = self._get_ykey_mapping() for pos, chains in enumerate(self): is_folder = isinstance(chains, dict) if is_folder: @@ -685,42 +962,55 @@ def describe(self, by_folder=False): folder_name = [None] folder_items.append(None) item_pos.append(pos) + if chains[0].structure is None: variables.extend([c._x_keys[0] for c in chains]) names.extend([c.name for c in chains]) folders.extend(folder_name * len(chains)) array_sum.extend([True if c.array_style > -1 else False for c in chains]) - sources.extend(c.source for c in chains) - + sources.extend(c.source if not c.edited else 'edited' + for c in chains) + for c in chains: + for m in bannermap: + if m[0] == c._y_keys: banner_ids.append(m[1]) else: - variables.extend([chains[0].name])#(chains[0].structure.columns.tolist()) - names.extend([chains[0].name])# for _ in xrange(chains[0].structure.shape[1])]) - # names.extend(chains[0].structure.columns.tolist()) + variables.extend([chains[0].name]) + names.extend([chains[0].name]) folders.extend(folder_name) array_sum.extend([False]) sources.extend(c.source for c in chains) - + banner_ids.append(None) + for c in chains: + if c.hidden: + hidden.append(True) + else: + hidden.append(False) df_data = [item_pos, names, folders, folder_items, variables, sources, - array_sum] + banner_ids, + array_sum, + hidden] df_cols = ['Position', 'Name', 'Folder', 'Item', 'Variable', 'Source', - 'Array'] + 'Banner id', + 'Array', + 'Hidden'] df = pd.DataFrame(df_data).T df.columns = df_cols if by_folder: - return df.set_index(['Position', 'Folder', 'Item']) - else: - return df + df = df.set_index(['Position', 'Folder', 'Item']) + if not show_hidden: + df = df[df['Hidden'] == False][df.columns[:-1]] + return df def from_mtd(self, mtd_doc, ignore=None, paint=True, flatten=False): """ @@ -836,10 +1126,10 @@ def to_chain(basic_chain_defintion, add_chain_meta): # new_chain._meta['var_meta'] = basic_chain_defintion[-1] # new_chain._extract_base_descriptions() new_chain._views = OrderedDict() - new_chain._views_per_rows - for vk in new_chain._views_per_rows: + new_chain._views_per_rows() + for vk in new_chain._views_per_rows(): if not vk in new_chain._views: - new_chain._views[vk] = new_chain._views_per_rows.count(vk) + new_chain._views[vk] = new_chain._views_per_rows().count(vk) return new_chain def mine_mtd(tab_collection, paint, chain_coll, folder=None): @@ -1014,9 +1304,9 @@ def to_chain(basic_chain_defintion, add_chain_meta): new_chain._meta['var_meta'] = basic_chain_defintion[-1] new_chain._extract_base_descriptions() new_chain._views = OrderedDict() - for vk in new_chain._views_per_rows: + for vk in new_chain._views_per_rows(): if not vk in new_chain._views: - new_chain._views[vk] = new_chain._views_per_rows.count(vk) + new_chain._views[vk] = new_chain._views_per_rows().count(vk) return new_chain # self.name = name OK! @@ -1238,7 +1528,8 @@ def get(self, data_key, filter_key, x_keys, y_keys, views, orient='x', chain = chain.get(data_key, filter_key, self._force_list(x_key), self._force_list(y_key), views, rules=rules, - prioritize=prioritize, orient=orient) + rules_weight=rules_weight, prioritize=prioritize, + orient=orient) folders = self.folder_names if folder in folders: @@ -1249,6 +1540,7 @@ def get(self, data_key, filter_key, x_keys, y_keys, views, orient='x', self.__chains.append({folder: [chain]}) else: self.__chains.append(chain) + return None def paint_all(self, *args, **kwargs): @@ -1472,12 +1764,15 @@ def __init__(self, stack, name, structure=None): self.name = name self.structure = structure self.source = 'native' + self.edited = False + self._custom_views = None self.double_base = False self.grouping = None self.sig_test_letters = None self.totalize = False self.base_descriptions = None self.painted = False + self.hidden = False self.annotations = ChainAnnotations() self._array_style = None self._group_style = None @@ -1487,15 +1782,134 @@ def __init__(self, stack, name, structure=None): self._given_views = None self._grp_text_map = [] self._text_map = None + self._custom_texts = {} self._transl = qp.core.view.View._metric_name_map() self._pad_id = None self._frame = None self._has_rules = None - self.grouping = None - self.sig_test_letters = None - self._group_style = None self._flag_bases = None self._is_mask_item = False + self._shapes = None + + class _TransformedChainDF(object): + """ + """ + def __init__(self, chain): + c = chain.clone() + self.org_views = c.views + self.df = c._frame + self._org_idx = self.df.index + self._edit_idx = range(0, len(self._org_idx)) + self._painted_idx = c.index + self._idx_valmap = {n: o for n, o in + zip(self._edit_idx, + self._org_idx.get_level_values(1))} + self.df.index = self._edit_idx + + self._org_col = self.df.columns + self._edit_col = range(0, len(self._org_col)) + self._painted_col = c.columns + self._col_valmap = {n: o for n, o in + zip(self._edit_col, + self._org_col.get_level_values(1))} + self.df.columns = self._edit_col + self.array_mi = c._array_style == 0 + self.nested_y = c._nested_y + self._nest_mul = self._nesting_multiplier() + return None + + def _nesting_multiplier(self): + """ + """ + levels = self._org_col.nlevels + if levels == 2: + return 1 + else: + return (levels / 2) + 1 + + def _insert_viewlikes(self, new_index_flat, org_index_mapped): + inserts = [new_index_flat.index(val) for val in new_index_flat + if not val in org_index_mapped.values()] + flatviews = [] + for name, no in self.org_views.items(): + e = [name] * no + flatviews.extend(e) + for vno, i in enumerate(inserts): + flatviews.insert(i, '__viewlike__{}'.format(vno)) + new_views = OrderedDict() + no_of_views = Counter(flatviews) + for fv in flatviews: + if not fv in new_views: new_views[fv] = no_of_views[fv] + return new_views + + def _updated_index_tuples(self, axis): + """ + """ + if axis == 1: + current = self.df.columns.values.tolist() + mapped = self._col_valmap + org_tuples = self._org_col.tolist() + painted_tuples = self._painted_col.tolist() + else: + current = self.df.index.values.tolist() + mapped = self._idx_valmap + org_tuples = self._org_idx.tolist() + painted_tuples = self._painted_idx.tolist() + merged = [mapped[val] if val in mapped else val for val in current] + # ================================================================ + if (self.array_mi and axis == 1) or axis == 0: + self._transf_views = self._insert_viewlikes(merged, mapped) + else: + self._transf_views = self.org_views + # ================================================================ + i = d = 0 + new_tuples = [] + new_painted_tuples = [] + for merged_val in merged: + idx = i-d if i-d != len(org_tuples) else i-d-1 + if org_tuples[idx][1] == merged_val: + new_tuples.append(org_tuples[idx]) + new_painted_tuples.append(painted_tuples[idx]) + else: + empties = ['*'] * self._nest_mul + new_tuple = tuple(empties + [merged_val]) + new_tuples.append(new_tuple) + new_painted_tuples.append(new_tuple) + d += 1 + i += 1 + return new_tuples, new_painted_tuples + + def _reindex(self, chain): + """ + """ + y_names = ['Question', 'Values'] + if not self.array_mi: + x_names = y_names + else: + x_names = ['Array', 'Questions'] + if self.nested_y: y_names = y_names * (self._nest_mul - 1) + tuples, p_tuples = self._updated_index_tuples(axis=1) + self.df.columns = pd.MultiIndex.from_tuples(tuples, names=y_names) + chain.columns = pd.MultiIndex.from_tuples(p_tuples, names=y_names) + tuples, p_tuples = self._updated_index_tuples(axis=0) + self.df.index = pd.MultiIndex.from_tuples(tuples, names=x_names) + chain.index = pd.MultiIndex.from_tuples(p_tuples, names=x_names) + return None + + def export(self): + """ + """ + return self._TransformedChainDF(self) + + def assign(self, transformed_chain_df): + """ + """ + if not isinstance(transformed_chain_df, self._TransformedChainDF): + raise ValueError("Must pass an exported ``Chain`` instance!") + transformed_chain_df._reindex(self) + self._frame = transformed_chain_df.df + self.views = transformed_chain_df._transf_views + return None def __str__(self): if self.structure is not None: @@ -1524,9 +1938,17 @@ def __len__(self): """Returns the total number of cells in the Chain.dataframe""" return (len(getattr(self, 'index', [])) * len(getattr(self, 'columns', []))) + def clone(self): + """ + """ + return copy.deepcopy(self) + @lazy_property def _default_text(self): - return self._meta['lib']['default text'] + tk = self._meta['lib']['default text'] + if tk not in self._transl: + self._transl[tk] = self._transl['en-GB'] + return tk @lazy_property def orientation(self): @@ -1593,6 +2015,12 @@ def views(self, views): def array_style(self): return self._array_style + @property + def shapes(self): + if self._shapes is None: + self._shapes = [] + return self._shapes + @array_style.setter def array_style(self, link): array_style = -1 @@ -1621,7 +2049,7 @@ def sig_levels(self): for m in zip(tests, levels): l = '.{}'.format(m[1]) t = m[0] - if m in sig_levels: + if t in sig_levels: sig_levels[t].append(l) else: sig_levels[t] = [l] @@ -1631,18 +2059,30 @@ def sig_levels(self): def cell_items(self): if self.views: compl_views = [v for v in self.views if ']*:' in v] - if not compl_views: - c = any(v.split('|')[-1] == 'counts' for v in self.views) - col_pct = any(v.split('|')[-1] == 'c%' for v in self.views) - row_pct = any(v.split('|')[-1] == 'r%' for v in self.views) - else: - c = any(v.split('|')[3] == '' for v in compl_views) - col_pct = any(v.split('|')[3] == 'y' for v in compl_views) - row_pct = any(v.split('|')[3] == 'x' for v in self.views) + check_views = compl_views[:] or self.views.copy() + for v in check_views: + if v.startswith('__viewlike__'): + if compl_views: + check_views.remove(v) + else: + del check_views[v] + + non_freqs = ('d.', 't.') + c = any(v.split('|')[3] == '' and + not v.split('|')[1].startswith(non_freqs) and + not v.split('|')[-1].startswith('cbase') + for v in check_views) + col_pct = any(v.split('|')[3] == 'y' and + not v.split('|')[1].startswith(non_freqs) and + not v.split('|')[-1].startswith('cbase') + for v in check_views) + row_pct = any(v.split('|')[3] == 'x' and + not v.split('|')[1].startswith(non_freqs) and + not v.split('|')[-1].startswith('cbase') + for v in check_views) c_colpct = c and col_pct c_rowpct = c and row_pct c_colrow_pct = c_colpct and c_rowpct - single_ci = not (c_colrow_pct or c_colpct or c_rowpct) if single_ci: if c: @@ -1655,7 +2095,10 @@ def cell_items(self): if c_colrow_pct: return 'counts_colpct_rowpct' elif c_colpct: - return 'counts_colpct' + if self._counts_first(): + return 'counts_colpct' + else: + return 'colpct_counts' else: return 'counts_rowpct' @@ -1664,6 +2107,8 @@ def _ci_simple(self): ci = [] if self.views: for v in self.views: + if 'significance' in v: + continue if ']*:' in v: if v.split('|')[3] == '': if 'N' not in ci: @@ -1695,7 +2140,6 @@ def ci_count(self): def contents(self): if self.structure: return - nested = self._array_style == 0 if nested: dims = self._frame.shape @@ -1703,13 +2147,12 @@ def contents(self): for row in range(0, dims[0])} else: contents = dict() - for row, idx in enumerate(self._views_per_rows): + for row, idx in enumerate(self._views_per_rows()): if nested: for i, v in idx.items(): - if v: - contents[row][i] = self._add_contents(v.split('|')) + contents[row][i] = self._add_contents(v) else: - contents[row] = self._add_contents(idx.split('|')) + contents[row] = self._add_contents(idx) return contents @property @@ -1722,11 +2165,12 @@ def cell_details(self): if self.sig_test_letters: mapped = '' group = None - i = 0 if (self._frame.columns.nlevels == 3) else 4 + i = 0 if (self._frame.columns.nlevels in [2, 3]) else 4 + for letter, lab in zip(self.sig_test_letters, self._frame.columns.labels[-i]): if letter == '@': continue - if group: + if group is not None: if lab == group: mapped += '/' + letter else: @@ -1735,7 +2179,6 @@ def cell_details(self): else: group = lab mapped += letter - test_types = cd['cp'] if self.sig_levels.get('means'): test_types += ', ' + cd['cm'] @@ -1762,7 +2205,6 @@ def cell_details(self): if against_total: cd_str.extend([cd['up'], cd['down']]) - return cd_str def describe(self): @@ -1784,7 +2226,24 @@ def _describe(cell_defs, row_id): description = _describe(self.contents, None) return description - @lazy_property + def _fill_cells(self): + """ + """ + self._frame = self._frame.fillna(method='ffill') + return None + + + # @lazy_property + def _counts_first(self): + for v in self.views: + sname = v.split('|')[-1] + if sname in ['counts', 'c%']: + if sname == 'counts': + return True + else: + return False + + #@property def _views_per_rows(self): """ """ @@ -1829,60 +2288,72 @@ def _views_per_rows(self): else: # Native Chain views # ---------------------------------------------------------------- - if self._array_style != 0: - metrics = [] - if self.orientation == 'x': - for view in self._valid_views(): - view = self._force_list(view) - initial = view[0] - size = self.views[initial] - metrics.extend(view * size) - else: - for view_part in self.views: + if self.edited and (self._custom_views and not self.array_style == 0): + return self._custom_views + else: + if self._array_style != 0: + metrics = [] + if self.orientation == 'x': for view in self._valid_views(): view = self._force_list(view) initial = view[0] - size = view_part[initial] + size = self.views[initial] metrics.extend(view * size) - else: - counts = [] - colpcts = [] - rowpcts = [] - metrics = [] - ci = self.cell_items - for v in self.views.keys(): - parts = v.split('|') - is_completed = ']*:' in v - if not self._is_c_pct(parts): - counts.extend([v]*self.views[v]) - if self._is_r_pct(parts): - rowpcts.extend([v]*self.views[v]) - if (self._is_c_pct(parts) or self._is_base(parts) or - self._is_stat(parts)): - colpcts.extend([v]*self.views[v]) - # else: - # if ci == 'counts_colpct' and self.grouping: - # if not self._is_counts(parts): - # # ...or self._is_c_base(parts): - # colpcts.append(None) - # else: - # colpcts.extend([v] * self.views[v]) - dims = self._frame.shape - for row in range(0, dims[0]): - if ci == 'counts_colpct' and self.grouping: - if row % 2 == 0: - vc = counts - else: - vc = colpcts else: - vc = counts if ci == 'counts' else colpcts - metrics.append({col: vc[col] for col in range(0, dims[1])}) + for view_part in self.views: + for view in self._valid_views(): + view = self._force_list(view) + initial = view[0] + size = view_part[initial] + metrics.extend(view * size) + else: + counts = [] + colpcts = [] + rowpcts = [] + metrics = [] + ci = self.cell_items + for v in self.views.keys(): + if not v.startswith('__viewlike__'): + parts = v.split('|') + is_completed = ']*:' in v + if not self._is_c_pct(parts): + counts.extend([v]*self.views[v]) + if self._is_r_pct(parts): + rowpcts.extend([v]*self.views[v]) + if (self._is_c_pct(parts) or self._is_base(parts) or + self._is_stat(parts)): + colpcts.extend([v]*self.views[v]) + else: + counts = counts + ['__viewlike__'] + colpcts = colpcts + ['__viewlike__'] + rowpcts = rowpcts + ['__viewlike__'] + dims = self._frame.shape + for row in range(0, dims[0]): + if ci in ['counts_colpct', 'colpct_counts'] and self.grouping: + if row % 2 == 0: + if self._counts_first(): + vc = counts + else: + vc = colpcts + else: + if not self._counts_first(): + vc = counts + else: + vc = colpcts + else: + vc = counts if ci == 'counts' else colpcts + metrics.append({col: vc[col] for col in range(0, dims[1])}) return metrics def _valid_views(self, flat=False): clean_view_list = [] valid = self.views.keys() - for v in self._given_views: + org_vc = self._given_views + v_likes = [v for v in valid if v.startswith('__viewlike__')] + if isinstance(org_vc, tuple): + v_likes = tuple(v_likes) + view_coll = org_vc + v_likes + for v in view_coll: if isinstance(v, (str, unicode)): if v in valid: clean_view_list.append(v) @@ -1892,17 +2363,28 @@ def _valid_views(self, flat=False): if sub_v in valid: new_v.append(sub_v) if isinstance(v, tuple): - new_v = tuple(new_v) + new_v = list(new_v) if new_v: if len(new_v) == 1: new_v = new_v[0] if not flat: clean_view_list.append(new_v) else: - clean_view_list.extend(new_v) + if isinstance(new_v, list): + clean_view_list.extend(new_v) + else: + clean_view_list.append(new_v) return clean_view_list - def _add_contents(self, parts): + def _add_contents(self, viewelement): + """ + """ + if viewelement.startswith('__viewlike__'): + parts = '|||||' + viewlike = True + else: + parts = viewelement.split('|') + viewlike = False return dict(is_default=self._is_default(parts), is_c_base=self._is_c_base(parts), is_r_base=self._is_r_base(parts), @@ -1934,7 +2416,126 @@ def _add_contents(self, parts): weight=self._weight(parts), is_stat=self._is_stat(parts), stat=self._stat(parts), - siglevel=self._siglevel(parts)) + siglevel=self._siglevel(parts), + is_viewlike=viewlike) + + def _row_pattern(self, target_ci): + """ + """ + cisplit = self.cell_items.split('_') + if target_ci == 'c%': + start = cisplit.index('colpct') + elif target_ci == 'counts': + start = cisplit.index('counts') + repeat = self.ci_count + return (start, repeat) + + def _view_idxs(self, view_tags, keep_tests=True, keep_bases=True, names=False, ci=None): + """ + """ + if not isinstance(view_tags, list): view_tags = [view_tags] + rowmeta = self.named_rowmeta + nested = self.array_style == 0 + if nested: + if self.ci_count > 1: + rp_idx = self._row_pattern(ci)[0] + rowmeta = rowmeta[rp_idx] + else: + rp_idx = 0 + rowmeta = rowmeta[0] + rows = [] + for r in rowmeta: + is_code = str(r[0]).isdigit() + if 'is_counts' in r[1] and is_code: + rows.append(('counts', r[1])) + elif 'is_c_pct' in r[1] and is_code: + rows.append(('c%', r[1])) + elif 'is_propstest' in r[1]: + rows.append((r[0], r[1])) + elif 'is_meanstest' in r[1]: + rows.append((r[0], r[1])) + else: + rows.append(r) + invalids = [] + if not keep_tests: + invalids.extend(['is_propstest', 'is_meanstest']) + if ci == 'counts': + invalids.append('is_c_pct') + elif ci == 'c%': + invalids.append('is_counts') + idxs = [] + names = [] + order = [] + for i, row in enumerate(rows): + if any([invalid in row[1] for invalid in invalids]): + if not (row[0] == 'All' and keep_bases): continue + if row[0] in view_tags: + order.append(view_tags.index(row[0])) + idxs.append(i) + if nested: + names.append(self._views_per_rows()[rp_idx][i]) + else: + names.append(self._views_per_rows()[i]) + return (idxs, order) if not names else (idxs, names, order) + + + @staticmethod + def _remove_grouped_blanks(viewindex_labs): + """ + """ + full = [] + for v in viewindex_labs: + if v == '': + full.append(last) + else: + last = v + full.append(last) + return full + + def _slice_edited_index(self, axis, positions): + """ + """ + l_zero = axis.get_level_values(0).values.tolist()[0] + l_one = axis.get_level_values(1).values.tolist() + l_one = [l_one[p] for p in positions] + axis_tuples = [(l_zero, lab) for lab in l_one] + if self.array_style == 0: + names = ['Array', 'Questions'] + else: + names = ['Question', 'Values'] + return pd.MultiIndex.from_tuples(axis_tuples, names=names) + + + def _non_grouped_axis(self): + """ + """ + axis = self._frame.index + l_zero = axis.get_level_values(0).values.tolist()[0] + l_one = axis.get_level_values(1).values.tolist() + l_one = self._remove_grouped_blanks(l_one) + axis_tuples = [(l_zero, lab) for lab in l_one] + if self.array_style == 0: + names = ['Array', 'Questions'] + else: + names = ['Question', 'Values'] + self._frame.index = pd.MultiIndex.from_tuples(axis_tuples, names=names) + return None + + @property + def named_rowmeta(self): + if self.painted: + self.toggle_labels() + d = self.describe() + if self.array_style == 0: + n = self._frame.columns.get_level_values(1).values.tolist() + n = self._remove_grouped_blanks(n) + mapped = {rowid: zip(n, rowmeta) for rowid, rowmeta in d.items()} + else: + n = self._frame.index.get_level_values(1).values.tolist() + n = self._remove_grouped_blanks(n) + mapped = zip(n, d) + if not self.painted: self.toggle_labels() + return mapped @lazy_property def _nested_y(self): @@ -1991,8 +2592,12 @@ def _is_block(self, parts): multiple_conditions = len(conditions) > 2 expand = '+{' in parts[2] or '}+' in parts[2] complete = '*:' in parts[2] - if multiple_conditions or expand or complete: + if expand or complete: return True + if multiple_conditions: + if self.__has_operator_expr(parts): + return True + return False return False return False @@ -2005,8 +2610,8 @@ def _stat(self, parts): # non-meta relevant helpers def __has_operator_expr(self, parts): e = parts[2] - for syntax in ['[+{', '}+]', ']*:']: - if syntax in e: e.remove(syntax) + for syntax in [']*:', '[+{', '}+']: + if syntax in e: e = e.replace(syntax, '') ops = ['+', '-', '*', '/'] return any(len(e.split(op)) > 1 for op in ops) @@ -2092,17 +2697,23 @@ def _describe_block(self, description, row_id): self.toggle_labels() else: repaint = False - vpr = self._views_per_rows + vpr = self._views_per_rows() if row_id is not None: vpr = [v[1] for v in vpr[row_id].items()] idx = self.dataframe.columns.get_level_values(1).tolist() else: idx = self.dataframe.index.get_level_values(1).tolist() idx_view_map = zip(idx, vpr) - block_net_vk = [v for v in vpr if len(v.split('|')[2].split('['))>2 or - '[+{' in v.split('|')[2] or '}+]' in v.split('|')[2]] + + block_net_vk = [ + v for v in vpr + if not v == "__viewlike__" and ( + len(v.split('|')[2].split('['))>2 or + '[+{' in v.split('|')[2] or '}+]' in v.split('|')[2])] + has_calc = any([v.split('|')[1].startswith('f.c') for v in block_net_vk]) - is_tested = any(v.split('|')[1].startswith('t.props') for v in vpr) + is_tested = any(v.split('|')[1].startswith('t.props') for v in vpr + if not v == "__viewlike__" ) if block_net_vk: expr = block_net_vk[0].split('|')[2] expanded_codes = set(map(int, re.findall(r'\d+', expr))) @@ -2138,7 +2749,7 @@ def _describe_block(self, description, row_id): return block_net_def def get(self, data_key, filter_key, x_keys, y_keys, views, rules=False, - orient='x', prioritize=True): + rules_weight=None, orient='x', prioritize=True): """ Get the concatenated Chain.DataFrame """ self._meta = self.stack[data_key].meta @@ -2154,6 +2765,15 @@ def get(self, data_key, filter_key, x_keys, y_keys, views, rules=False, else: self._has_rules = rules + # use_views = views[:] + # for first in self.axes[0]: + # for second in self.axes[1]: + # link = self._get_link(data_key, filter_key, first, second) + + # for v in use_views: + # if v not in link: + # use_views.remove(v) + for first in self.axes[0]: found = [] x_frames = [] @@ -2166,9 +2786,9 @@ def get(self, data_key, filter_key, x_keys, y_keys, views, rules=False, if link is None: continue - if prioritize: link = self._drop_substituted_views(link) - found_views, y_frames = self._concat_views(link, views) + found_views, y_frames = self._concat_views( + link, views, rules_weight) found.append(found_views) try: @@ -2187,15 +2807,25 @@ def get(self, data_key, filter_key, x_keys, y_keys, views, rules=False, x_frames.append(pd.concat(y_frames, axis=concat_axis)) + self.shapes.append(x_frames[-1].shape) self._frame = pd.concat(self._pad(x_frames), axis=self.axis) + + if self._group_style == 'reduced' and self.array_style >- 1: - if not any(len(v) == 2 and any(view.split('|')[1].startswith('t.') - for view in v) for v in self._given_views): + scan_views = [v if isinstance(v, (tuple, list)) else [v] + for v in self._given_views] + scan_views = [v for v in scan_views if len(v) > 1] + no_tests = [] + for scan_view in scan_views: + new_views = [] + for view in scan_view: + if not view.split('|')[1].startswith('t.'): + new_views.append(view) + no_tests.append(new_views) + cond = any(len(v) >= 2 for v in no_tests) + if cond: self._frame = self._reduce_grouped_index(self._frame, 2, self._array_style) - elif any(len(v) == 3 for v in self._given_views): - self._frame = self._reduce_grouped_index(self._frame, 2, self._array_style) - if self.axis == 1: self.views = found[-1] else: @@ -2212,6 +2842,57 @@ def get(self, data_key, filter_key, x_keys, y_keys, views, rules=False, return self + def _toggle_bases(self, keep_weighted=True): + df = self._frame + is_array = self._array_style == 0 + contents = self.contents[0] if is_array else self.contents + has_wgt_b = [k for k, v in contents.items() + if v['is_c_base'] and v['is_weighted']] + has_unwgt_b = [k for k, v in contents.items() + if v['is_c_base'] and not v['is_weighted']] + if not (has_wgt_b and has_unwgt_b): + return None + + if keep_weighted: + drop_rows = has_unwgt_b + names = ['x|f|x:|||cbase'] + else: + drop_rows = has_wgt_b + names = ['x|f|x:||{}|cbase'.format(contents.values()[0]['weight'])] + + for v in self.views.copy(): + if v in names: + del self._views[v] + + df = self._frame + + if is_array: + cols = [col for x, col in enumerate(df.columns.tolist()) + if not x in drop_rows] + df = df.loc[:, cols] + else: + rows = [row for x, row in enumerate(df.index.tolist()) + if not x in drop_rows] + df = df.loc[rows, :] + + self._frame = df + self._index = df.index + self._columns = df.columns + return None + + def _slice_edited_index(self, axis, positions): + """ + """ + l_zero = axis.get_level_values(0).values.tolist()[0] + l_one = axis.get_level_values(1).values.tolist() + l_one = [l_one[p] for p in positions] + axis_tuples = [(l_zero, lab) for lab in l_one] + if self.array_style == 0: + names = ['Array', 'Questions'] + else: + names = ['Question', 'Values'] + return pd.MultiIndex.from_tuples(axis_tuples, names=names) + def _drop_substituted_views(self, link): if any(isinstance(sect, (list, tuple)) for sect in self._given_views): chain_views = list(chain.from_iterable(self._given_views)) @@ -2236,7 +2917,6 @@ def _drop_substituted_views(self, link): else: return link - def _pad_frames(self, frames): """ TODO: doc string """ @@ -2324,7 +3004,7 @@ def _reindx_source(df, varname, total): df.columns = df.columns.set_levels([varname], level=0, inplace=False) return df - def _concat_views(self, link, views, found=None): + def _concat_views(self, link, views, rules_weight, found=None): """ Concatenates the Views of a Chain. """ frames = [] @@ -2355,7 +3035,7 @@ def _concat_views(self, link, views, found=None): else: use_grp_type = self._group_style - found, grouped = self._concat_views(link, view, found=found) + found, grouped = self._concat_views(link, view, rules_weight, found=found) if grouped: frames.append(self._group_views(grouped, use_grp_type)) else: @@ -2367,6 +3047,12 @@ def _concat_views(self, link, views, found=None): oth_src = link[view].has_other_source() no_total_sign = is_descriptive or is_base or is_sum or is_net + if link[view]._custom_txt and is_descriptive: + statname = agg['fullname'].split('|')[1].split('.')[1] + if not statname in self._custom_texts: + self._custom_texts[statname] = [] + self._custom_texts[statname].append(link[view]._custom_txt) + if is_descriptive: text = agg['name'] try: @@ -2399,7 +3085,7 @@ def _concat_views(self, link, views, found=None): rules_weight = None if self._has_rules: - rules = Rules(link, view, axes=self._has_rules) + rules = Rules(link, view, self._has_rules, rules_weight) # print rules.show_rules() # rules.get_slicer() # print rules.show_slicers() @@ -2462,7 +3148,7 @@ def _temp_nest_index(df): return df, flat_cols @staticmethod - def _replace_test_results(df, replacement_map): + def _replace_test_results(df, replacement_map, char_repr): """ Swap all digit-based results with letters referencing the column header. @@ -2470,6 +3156,7 @@ def _replace_test_results(df, replacement_map): and columns. """ all_dfs = [] + ignore = False for col in replacement_map.keys(): target_col = df.columns[0] if col == '@' else col value_df = df[[target_col]].copy() @@ -2478,12 +3165,23 @@ def _replace_test_results(df, replacement_map): values = value_df.replace(np.NaN, '-').values.tolist() r = replacement_map[col] new_values = [] + case = None for v in values: if isinstance(v[0], (str, unicode)): - for number, letter in sorted(r.items(), reverse=True): - v = [char.replace(str(number), letter) + if char_repr == 'upper': + case = 'up' + elif char_repr == 'lower': + case = 'low' + elif char_repr == 'alternate': + if case == 'up': + case = 'low' + else: + case = 'up' + for no, l in sorted(r.items(), reverse=True): + v = [char.replace(str(no), l if case == 'up' else l.lower()) if isinstance(char, (str, unicode)) else char for char in v] + new_values.append(v) else: new_values.append(v) @@ -2503,11 +3201,12 @@ def _get_abc_letters(no_of_cols, incl_total): Get the list of letter replacements depending on the y-axis length. """ repeat_alphabet = int(no_of_cols / 26) + abc = list(string.ascii_uppercase) letters = list(string.ascii_uppercase) if repeat_alphabet: for r in range(0, repeat_alphabet): - letter = letters[r] - extend_abc = ['{}{}'.format(letter, l) for l in letters] + letter = abc[r] + extend_abc = ['{}{}'.format(letter, l) for l in abc] letters.extend(extend_abc) if incl_total: letters = ['@'] + letters[:no_of_cols-1] @@ -2519,7 +3218,24 @@ def _any_tests(self): vms = [v.split('|')[1] for v in self._views.keys()] return any('t.' in v for v in vms) - def transform_tests(self): + def _no_of_tests(self): + tests = [v for v in self._views.keys() + if v.split('|')[1].startswith('t.')] + levels = [v.split('|')[1].split('.')[-1] for v in tests] + return len(set(levels)) + + def _siglevel_on_row(self): + """ + """ + vpr = self._views_per_rows() + tests = [(no, v) for no, v in enumerate(vpr) + if v.split('|')[1].startswith('t.')] + s = [(t[0], + float(int(t[1].split('|')[1].split('.')[3].split('+')[0]))/100.0) + for t in tests] + return s + + def transform_tests(self, char_repr='upper', display_level=True): """ Transform column-wise digit-based test representation to letters. @@ -2533,7 +3249,8 @@ def transform_tests(self): df = self.dataframe.copy() number_codes = df.columns.get_level_values(-1).tolist() number_header_row = copy.copy(df.columns) - + if self._no_of_tests() != 2 and char_repr == 'alternate': + char_repr = 'upper' has_total = '@' in self._y_keys if self._nested_y: df, questions = self._temp_nest_index(df) @@ -2541,12 +3258,14 @@ def transform_tests(self): questions = self._y_keys all_num = number_codes if not has_total else [0] + number_codes[1:] # Set the new column header (ABC, ...) + column_letters = self._get_abc_letters(len(number_codes), has_total) - df.columns.set_levels(levels=column_letters, level=1, inplace=True) - df.columns.set_labels(labels=xrange(0, len(column_letters)), level=1, - inplace=True) + vals = df.columns.get_level_values(0).tolist() + mi = pd.MultiIndex.from_arrays( + (vals, + column_letters)) + df.columns = mi self.sig_test_letters = df.columns.get_level_values(1).tolist() - # Build the replacements dict and build list of unique column indices test_dict = OrderedDict() for num_idx, col in enumerate(df.columns): @@ -2558,10 +3277,20 @@ def transform_tests(self): number = all_num[num_idx] letter = col[1] test_dict[question][number] = letter - # Do the replacements... - letter_df = self._replace_test_results(df, test_dict) + letter_df = self._replace_test_results(df, test_dict, char_repr) # Re-apply indexing & finalize the new crossbreak column header - letter_df.index = df.index + if display_level: + levels = self._siglevel_on_row() + index = df.index.get_level_values(1).tolist() + for i, l in levels: + index[i] = '#Level: {}'.format(l) + l0 = df.index.get_level_values(0).tolist()[0] + tuples = [(l0, i) for i in index] + index = pd.MultiIndex.from_tuples( + tuples, names=['Question', 'Values']) + letter_df.index = index + else: + letter_df.index = df.index letter_df.columns = number_header_row letter_df = self._apply_letter_header(letter_df) self._frame = letter_df @@ -2648,9 +3377,10 @@ def _finish_text_key(self, text_key, text_loc_x, text_loc_y): return text_keys def paint(self, text_key=None, text_loc_x=None, text_loc_y=None, display=None, - axes=None, view_level=False, transform_tests='cells', - add_base_texts='simple', totalize=False, sep=None, na_rep=None, - transform_column_names=None, exclude_mask_text=False): + axes=None, view_level=False, transform_tests='upper', display_level=True, + add_test_ids=True, add_base_texts='simple', totalize=False, + sep=None, na_rep=None, transform_column_names=None, + exclude_mask_text=False): """ Apply labels, sig. testing conversion and other post-processing to the ``Chain.dataframe`` property. @@ -2672,9 +3402,11 @@ def paint(self, text_key=None, text_loc_x=None, text_loc_y=None, display=None, Text view_level : bool, default False Text - transform_tests : {False, 'full', 'cells'}, default 'cells' + transform_tests : {False, 'upper', 'lower', 'alternate'}, default 'upper' + Text + add_test_ids : bool, default True Text - add_base_texts : {False, 'all', 'simple'}, default 'simple' + add_base_texts : {False, 'all', 'simple', 'simple-no-items'}, default 'simple' Whether or not to include existing ``.base_descriptions`` str to the label of the appropriate base view. Selecting ``'simple'`` will inject the base texts to non-array type Chains only. @@ -2699,7 +3431,7 @@ def paint(self, text_key=None, text_loc_x=None, text_loc_y=None, display=None, self._paint_structure(text_key, sep=sep, na_rep=na_rep) else: self.totalize = totalize - if transform_tests: self.transform_tests() + if transform_tests: self.transform_tests(transform_tests, display_level) # Remove any letter header row from transformed tests... if self.sig_test_letters: self._remove_letter_header() @@ -2710,7 +3442,7 @@ def paint(self, text_key=None, text_loc_x=None, text_loc_y=None, display=None, self._paint(text_keys, display, axes, add_base_texts, transform_column_names, exclude_mask_text) # Re-build the full column index (labels + letter row) - if self.sig_test_letters and transform_tests == 'full': + if self.sig_test_letters and add_test_ids: self._frame = self._apply_letter_header(self._frame) if view_level: self._add_view_level() @@ -2731,9 +3463,10 @@ def _paint_structure(self, text_key=None, sep=None, na_rep=None): pattern = r'\, (?=\W|$)' for column in self.structure.columns: - if not column in self._meta['columns']: return None + if not column in self._meta['columns']: continue meta = self._meta['columns'][column] + if sep: column_mapper[column] = str_format % (column, meta['text'][text_key]) else: @@ -2741,35 +3474,34 @@ def _paint_structure(self, text_key=None, sep=None, na_rep=None): if meta.get('values'): values = meta['values'] - if isinstance(values, (str, unicode)): + if isinstance(values, basestring): pointers = values.split('@') values = self._meta[pointers.pop(0)] while pointers: - valules = values[pointers.pop(0)] + values = values[pointers.pop(0)] if meta['type'] == 'delimited set': value_mapper = { str(item['value']): item['text'][text_key] for item in values } series = self.structure[column] - series = (series.str.split(';') - .apply(pd.Series, 1) - .stack(dropna=False) - .map(value_mapper.get) #, na_action='ignore') - .unstack()) - first = series[series.columns[0]] - rest = [series[c] for c in series.columns[1:]] - self.structure[column] = (first - .str.cat(rest, - sep=', ', - na_rep='') - .str.slice(0, -2) - .replace(to_replace=pattern, - value='', - regex=True) - .replace(to_replace='', - value=na_rep) - ) + try: + series = (series.str.split(';') + .apply(pd.Series, 1) + .stack(dropna=False) + .map(value_mapper.get) #, na_action='ignore') + .unstack()) + first = series[series.columns[0]] + rest = [series[c] for c in series.columns[1:]] + self.structure[column] = ( + first + .str.cat(rest, sep=', ', na_rep='') + .str.slice(0, -2) + .replace(to_replace=pattern, value='', regex=True) + .replace(to_replace='', value=na_rep) + ) + except AttributeError: + continue else: value_mapper = { item['value']: item['text'][text_key] @@ -2866,6 +3598,7 @@ def _get_level_1(self, levels, text_keys, display, axis, bases): tk_transl = text_keys[axis] else: tk_transl = self._default_text + c_text = copy.deepcopy(self._custom_texts) if self._custom_texts else {} for i, value in enumerate(levels[1]): if str(value).startswith('#pad'): level_1_text.append(value) @@ -2873,6 +3606,8 @@ def _get_level_1(self, levels, text_keys, display, axis, bases): level_1_text.append(value) elif str(value) == '': level_1_text.append(value) + elif str(value).startswith('#Level: '): + level_1_text.append(value.replace('#Level: ', '')) else: translate = self._transl[self._transl.keys()[0]].keys() if value in self._text_map.keys() and value not in translate: @@ -2882,6 +3617,9 @@ def _get_level_1(self, levels, text_keys, display, axis, bases): text = self._specify_base(i, text_keys[axis], bases) else: text = self._transl[tk_transl][value] + if value in c_text: + add_text = c_text[value].pop(0) + text = '{} {}'.format(text, add_text) level_1_text.append(text) elif value == 'All (eff.)': text = self._specify_base(i, text_keys[axis], bases) @@ -2900,7 +3638,7 @@ def _get_level_1(self, levels, text_keys, display, axis, bases): if int(value) == item['value']: text = self._get_text(item, text_keys[axis]) level_1_text.append(text) - except ValueError: + except (ValueError, UnboundLocalError): if self._grp_text_map: for gtm in self._grp_text_map: if value in gtm.keys(): @@ -2909,8 +3647,20 @@ def _get_level_1(self, levels, text_keys, display, axis, bases): return map(unicode, level_1_text) @staticmethod - def _is_multibase(views, basetype): - return len([v for v in views if v.split('|')[-1] == basetype]) > 1 + def _unwgt_label(views, base_vk): + valid = ['cbase', 'cbase_gross', 'rbase', 'ebase'] + basetype = base_vk.split('|')[-1] + views_split = [v.split('|') for v in views] + multibase = len([v for v in views_split if v[-1] == basetype]) > 1 + weighted = base_vk.split('|')[-2] + w_diff = len([v for v in views_split + if not v[-1] in valid and not v[-2] == weighted]) > 0 + if weighted: + return False + elif multibase or w_diff: + return True + else: + return False def _add_base_text(self, base_val, tk, bases): if self._array_style == 0 and bases != 'all': @@ -2932,29 +3682,28 @@ def _specify_base(self, view_idx, tk, bases): tk_transl = tk if tk in self._transl else self._default_text base_vk = self._valid_views()[view_idx] basetype = base_vk.split('|')[-1] - weighted = base_vk.split('|')[-2] - is_multibase = self._is_multibase(self._views.keys(), basetype) - if basetype == 'cbase_gross': - if weighted or (not weighted and not is_multibase): - base_value = self._transl[tk_transl]['gross All'] - else: + unwgt_label = self._unwgt_label(self._views.keys(), base_vk) + + if unwgt_label: + if basetype == 'cbase_gross': base_value = self._transl[tk_transl]['no_w_gross_All'] - elif basetype == 'ebase': - if weighted or (not weighted and not is_multibase): - base_value = 'Effective base' - else: + elif basetype == 'ebase': base_value = 'Unweighted effective base' + else: + base_value = self._transl[tk_transl]['no_w_All'] else: - if weighted or (not weighted and not is_multibase): - if not bases: - return self._transl[tk_transl]['All'] + if basetype == 'cbase_gross': + base_value = self._transl[tk_transl]['gross All'] + elif basetype == 'ebase': + base_value = 'Effective base' + elif not bases or (bases == 'simple-no-items' and self._is_mask_item): + base_value = self._transl[tk_transl]['All'] + else: key = tk if isinstance(tk, tuple): _, key = tk base_value = self._add_base_text(self._transl[tk_transl]['All'], key, bases) - else: - base_value = self._transl[tk_transl]['no_w_All'] return base_value def _get_text(self, value, text_key, item_text=False): @@ -2965,7 +3714,10 @@ def _get_text(self, value, text_key, item_text=False): if item_text and col.get('parent'): parent = col['parent'].keys()[0].split('@')[-1] items = self._meta['masks'][parent]['items'] - obj = [i['text'] for i in items if value in i['source']][0] + for i in items: + if i['source'].split('@')[-1] == value: + obj = i['text'] + break else: obj = col['text'] elif value in self._meta['masks'].keys(): @@ -3002,19 +3754,17 @@ def _get_values(self, column): values = self._meta['columns'][column].get('values', []) elif column in self._meta['masks']: values = self._meta['lib']['values'].get(column, []) - if isinstance(values, (str, unicode)): keys = values.split('@') values = self._meta[keys.pop(0)] while keys: values = values[keys.pop(0)] - return values def _add_view_level(self, shorten=False): """ Insert a third Index level containing View keys into the DataFrame. """ - vnames = self._views_per_rows + vnames = self._views_per_rows() if shorten: vnames = [v.split('|')[-1] for v in vnames] self._frame['View'] = pd.Series(vnames, index=self._frame.index) @@ -3031,7 +3781,6 @@ def toggle_labels(self): attrs = ['index', 'columns'] if self.structure is not None: attrs.append('_frame_values') - for attr in attrs: vals = attr[6:] if attr.startswith('_frame') else attr frame_val = getattr(self._frame, vals) @@ -3041,8 +3790,7 @@ def toggle_labels(self): if self.structure is not None: values = self._frame.values self._frame.loc[:, :] = self.frame_values - self.fram_values = values - + self.frame_values = values return self @staticmethod diff --git a/setup.cfg b/setup.cfg index 0bbc916eb..5aea674ab 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,3 +4,4 @@ test=pytest [tool:pytest] norecursedirs=*egg .eggs .idea data debug #addopts=--cov quantipy +filterwarnings = ignore::DeprecationWarning \ No newline at end of file diff --git a/setup.py b/setup.py index df3d3fd41..438091985 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ 'xmltodict', 'lxml', 'xlsxwriter', - 'pillow', + # 'pillow', 'prettytable', 'decorator', 'watchdog', diff --git a/tests/Example Data (A).json b/tests/Example Data (A).json index e61ddb930..7714b0347 100644 --- a/tests/Example Data (A).json +++ b/tests/Example Data (A).json @@ -1 +1 @@ -{"columns": {"@1": {"type": "int"}, "RecordNo": {"name": "RecordNo", "parent": {}, "properties": {"created": true}, "text": {"en-GB": "RecordNo"}, "type": "int"}, "Wave": {"name": "Wave", "parent": {}, "text": {"en-GB": "Wave"}, "type": "single", "values": [{"text": {"en-GB": "Wave 1"}, "value": 1}, {"text": {"en-GB": "Wave 2"}, "value": 2}, {"text": {"en-GB": "Wave 3"}, "value": 3}, {"text": {"en-GB": "Wave 4"}, "value": 4}, {"text": {"en-GB": "Wave 5"}, "value": 5}]}, "age": {"name": "age", "parent": {}, "text": {"en-GB": "Age"}, "type": "int"}, "birth_day": {"name": "birth_day", "parent": {}, "text": {"en-GB": "Birth day"}, "type": "int"}, "birth_month": {"name": "birth_month", "parent": {}, "text": {"en-GB": "Birth month"}, "type": "int"}, "birth_year": {"name": "birth_year", "parent": {}, "text": {"en-GB": "Birth year"}, "type": "int"}, "duration": {"name": "duration", "parent": {}, "text": {"en-GB": "Duration"}, "type": "time"}, "end_time": {"name": "end_time", "parent": {}, "text": {"en-GB": "End time of survey"}, "type": "date"}, "ethnicity": {"name": "ethnicity", "parent": {}, "text": {"en-GB": "What is your ethnicity?"}, "type": "single", "values": [{"text": {"en-GB": "White European"}, "value": 1}, {"text": {"en-GB": "Any other white background"}, "value": 2}, {"text": {"en-GB": "White and Black Caribbean"}, "value": 3}, {"text": {"en-GB": "White and Black African"}, "value": 4}, {"text": {"en-GB": "White and Asian"}, "value": 5}, {"text": {"en-GB": "Any other mixed background"}, "value": 6}, {"text": {"en-GB": "Indian"}, "value": 7}, {"text": {"en-GB": "Pakistani"}, "value": 8}, {"text": {"en-GB": "Bangladeshi"}, "value": 9}, {"text": {"en-GB": "Any other Asian background"}, "value": 10}, {"text": {"en-GB": "Black Caribbean"}, "value": 11}, {"text": {"en-GB": "Black African"}, "value": 12}, {"text": {"en-GB": "Any other black background"}, "value": 13}, {"text": {"en-GB": "Chinese"}, "value": 14}, {"text": {"en-GB": "Other ethnic group"}, "value": 15}, {"text": {"en-GB": "Prefer not to say"}, "value": 16}]}, "gender": {"name": "gender", "parent": {}, "text": {"en-GB": "What is your gender?"}, "type": "single", "values": [{"text": {"en-GB": "Male"}, "value": 1}, {"text": {"en-GB": "Female"}, "value": 2}]}, "locality": {"name": "locality", "parent": {}, "text": {"en-GB": "How would you describe the areas in which you live?"}, "type": "single", "values": [{"text": {"en-GB": "CBD (central business district)"}, "value": 1}, {"text": {"en-GB": "Urban"}, "value": 2}, {"text": {"en-GB": "Suburban"}, "value": 3}, {"text": {"en-GB": "Rural"}, "value": 4}, {"text": {"en-GB": "Remote"}, "value": 5}]}, "q1": {"name": "q1", "parent": {}, "text": {"en-GB": "What is your main fitness activity?"}, "type": "single", "values": [{"text": {"en-GB": "Swimming"}, "value": 1}, {"text": {"en-GB": "Running/jogging"}, "value": 2}, {"text": {"en-GB": "Lifting weights"}, "value": 3}, {"text": {"en-GB": "Aerobics"}, "value": 4}, {"text": {"en-GB": "Yoga"}, "value": 5}, {"text": {"en-GB": "Pilates"}, "value": 6}, {"text": {"en-GB": "Football (soccer)"}, "value": 7}, {"text": {"en-GB": "Basketball"}, "value": 8}, {"text": {"en-GB": "Hockey"}, "value": 9}, {"text": {"en-GB": "Other"}, "value": 96}, {"text": {"en-GB": "I regularly change my fitness activity"}, "value": 98}, {"text": {"en-GB": "Not applicable - I don't exercise"}, "value": 99}]}, "q14r01c01": {"name": "q14r01c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - I had a good experience in the store."}, "type": "single", "values": "lib@values@q14_1"}, "q14r01c02": {"name": "q14r01c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - I had a good experience in the store."}, "type": "single", "values": "lib@values@q14_2"}, "q14r01c03": {"name": "q14r01c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - I had a good experience in the store."}, "type": "single", "values": "lib@values@q14_3"}, "q14r02c01": {"name": "q14r02c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - The store was clean."}, "type": "single", "values": "lib@values@q14_1"}, "q14r02c02": {"name": "q14r02c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - The store was clean."}, "type": "single", "values": "lib@values@q14_2"}, "q14r02c03": {"name": "q14r02c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - The store was clean."}, "type": "single", "values": "lib@values@q14_3"}, "q14r03c01": {"name": "q14r03c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - It was easy to find what I was looking for."}, "type": "single", "values": "lib@values@q14_1"}, "q14r03c02": {"name": "q14r03c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - It was easy to find what I was looking for."}, "type": "single", "values": "lib@values@q14_2"}, "q14r03c03": {"name": "q14r03c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - It was easy to find what I was looking for."}, "type": "single", "values": "lib@values@q14_3"}, "q14r04c01": {"name": "q14r04c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - The store had everything I needed."}, "type": "single", "values": "lib@values@q14_1"}, "q14r04c02": {"name": "q14r04c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - The store had everything I needed."}, "type": "single", "values": "lib@values@q14_2"}, "q14r04c03": {"name": "q14r04c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - The store had everything I needed."}, "type": "single", "values": "lib@values@q14_3"}, "q14r05c01": {"name": "q14r05c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - The store's staff were friendly and helpful."}, "type": "single", "values": "lib@values@q14_1"}, "q14r05c02": {"name": "q14r05c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - The store's staff were friendly and helpful."}, "type": "single", "values": "lib@values@q14_2"}, "q14r05c03": {"name": "q14r05c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - The store's staff were friendly and helpful."}, "type": "single", "values": "lib@values@q14_3"}, "q14r06c01": {"name": "q14r06c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - The wait time when checking out was acceptable."}, "type": "single", "values": "lib@values@q14_1"}, "q14r06c02": {"name": "q14r06c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - The wait time when checking out was acceptable."}, "type": "single", "values": "lib@values@q14_2"}, "q14r06c03": {"name": "q14r06c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - The wait time when checking out was acceptable."}, "type": "single", "values": "lib@values@q14_3"}, "q14r07c01": {"name": "q14r07c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - The music playing in the store was appropriate."}, "type": "single", "values": "lib@values@q14_1"}, "q14r07c02": {"name": "q14r07c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - The music playing in the store was appropriate."}, "type": "single", "values": "lib@values@q14_2"}, "q14r07c03": {"name": "q14r07c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - The music playing in the store was appropriate."}, "type": "single", "values": "lib@values@q14_3"}, "q14r08c01": {"name": "q14r08c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - The staff made me feel welcome."}, "type": "single", "values": "lib@values@q14_1"}, "q14r08c02": {"name": "q14r08c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - The staff made me feel welcome."}, "type": "single", "values": "lib@values@q14_2"}, "q14r08c03": {"name": "q14r08c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - The staff made me feel welcome."}, "type": "single", "values": "lib@values@q14_3"}, "q14r09c01": {"name": "q14r09c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - The climate control in the store was set appropriately."}, "type": "single", "values": "lib@values@q14_1"}, "q14r09c02": {"name": "q14r09c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - The climate control in the store was set appropriately."}, "type": "single", "values": "lib@values@q14_2"}, "q14r09c03": {"name": "q14r09c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - The climate control in the store was set appropriately."}, "type": "single", "values": "lib@values@q14_3"}, "q14r10c01": {"name": "q14r10c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - The store had ample available parking when I arrived."}, "type": "single", "values": "lib@values@q14_1"}, "q14r10c02": {"name": "q14r10c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - The store had ample available parking when I arrived."}, "type": "single", "values": "lib@values@q14_2"}, "q14r10c03": {"name": "q14r10c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - The store had ample available parking when I arrived."}, "type": "single", "values": "lib@values@q14_3"}, "q2": {"name": "q2", "parent": {}, "text": {"en-GB": "Which, if any, of these other sports have you ever participated in?"}, "type": "delimited set", "values": [{"text": {"en-GB": "Sky diving"}, "value": 1}, {"text": {"en-GB": "Base jumping"}, "value": 2}, {"text": {"en-GB": "Mountain biking"}, "value": 3}, {"text": {"en-GB": "Kite boarding"}, "value": 4}, {"text": {"en-GB": "Snowboarding"}, "value": 5}, {"text": {"en-GB": "Parachuting"}, "value": 6}, {"text": {"en-GB": "Other"}, "value": 97}, {"text": {"en-GB": "None of these"}, "value": 98}]}, "q2b": {"name": "q2b", "parent": {}, "text": {"en-GB": "How regularly do you participate in any fitness or sports activity?"}, "type": "single", "values": [{"text": {"en-GB": "Regularly"}, "value": 1}, {"text": {"en-GB": "Irregularly"}, "value": 2}, {"text": {"en-GB": "Never"}, "value": 3}]}, "q3": {"name": "q3", "parent": {}, "text": {"en-GB": "Which of these pieces of sports equipment are owned by anyone in your household?"}, "type": "delimited set", "values": [{"text": {"en-GB": "Basketball"}, "value": 1}, {"text": {"en-GB": "Football"}, "value": 2}, {"text": {"en-GB": "Hockey stick"}, "value": 3}, {"text": {"en-GB": "Surfboard"}, "value": 4}, {"text": {"en-GB": "Climbing gear"}, "value": 5}, {"text": {"en-GB": "Bicycle"}, "value": 6}, {"text": {"en-GB": "Parachute"}, "value": 7}, {"text": {"en-GB": "Swimming goggles"}, "value": 8}, {"text": {"en-GB": "None of these"}, "value": 97}]}, "q4": {"name": "q4", "parent": {}, "text": {"en-GB": "Do you ever participate in sports activities with people in your household?"}, "type": "single", "values": [{"text": {"en-GB": "Yes"}, "value": 1}, {"text": {"en-GB": "No"}, "value": 2}]}, "q5_1": {"name": "q5_1", "parent": {"masks@q5": {"type": "array"}}, "text": {"en-GB": "How likely are you to do each of the following in the next year? - Surfing"}, "type": "single", "values": "lib@values@q5"}, "q5_2": {"name": "q5_2", "parent": {"masks@q5": {"type": "array"}}, "text": {"en-GB": "How likely are you to do each of the following in the next year? - Snowboarding"}, "type": "single", "values": "lib@values@q5"}, "q5_3": {"name": "q5_3", "parent": {"masks@q5": {"type": "array"}}, "text": {"en-GB": "How likely are you to do each of the following in the next year? - Kite boarding"}, "type": "single", "values": "lib@values@q5"}, "q5_4": {"name": "q5_4", "parent": {"masks@q5": {"type": "array"}}, "text": {"en-GB": "How likely are you to do each of the following in the next year? - Parachuting"}, "type": "single", "values": "lib@values@q5"}, "q5_5": {"name": "q5_5", "parent": {"masks@q5": {"type": "array"}}, "text": {"en-GB": "How likely are you to do each of the following in the next year? - Cave diving"}, "type": "single", "values": "lib@values@q5"}, "q5_6": {"name": "q5_6", "parent": {"masks@q5": {"type": "array"}}, "text": {"en-GB": "How likely are you to do each of the following in the next year? - Windsurfing"}, "type": "single", "values": [{"text": {"en-GB": "I would refuse if asked"}, "value": 1}, {"text": {"en-GB": "Very unlikely"}, "value": 2}, {"text": {"en-GB": "Probably wouldn't"}, "value": 3}, {"text": {"en-GB": "Probably would if asked"}, "value": 4}, {"text": {"en-GB": "Very likely"}, "value": 5}, {"text": {"en-GB": "I'm already planning to"}, "value": 97}, {"text": {"en-GB": "Don't know"}, "value": 98}]}, "q6_1": {"name": "q6_1", "parent": {"masks@q6": {"type": "array"}}, "text": {"en-GB": "How often do you take part in any of the following? - Exercise alone"}, "type": "single", "values": "lib@values@q6"}, "q6_2": {"name": "q6_2", "parent": {"masks@q6": {"type": "array"}}, "text": {"en-GB": "How often do you take part in any of the following? - Join an exercise class"}, "type": "single", "values": "lib@values@q6"}, "q6_3": {"name": "q6_3", "parent": {"masks@q6": {"type": "array"}}, "text": {"en-GB": "How often do you take part in any of the following? - Play any kind of team sport"}, "type": "single", "values": "lib@values@q6"}, "q7_1": {"name": "q7_1", "parent": {"masks@q7": {"type": "array"}}, "text": {"en-GB": "How often do you use any of the following for any reason? - A smartphone"}, "type": "single", "values": "lib@values@q7"}, "q7_2": {"name": "q7_2", "parent": {"masks@q7": {"type": "array"}}, "text": {"en-GB": "How often do you use any of the following for any reason? - A tablet"}, "type": "single", "values": "lib@values@q7"}, "q7_3": {"name": "q7_3", "parent": {"masks@q7": {"type": "array"}}, "text": {"en-GB": "How often do you use any of the following for any reason? - A laptop/ PC"}, "type": "single", "values": "lib@values@q7"}, "q7_4": {"name": "q7_4", "parent": {"masks@q7": {"type": "array"}}, "text": {"en-GB": "How often do you use any of the following for any reason? - A gaming console (e.g. Xbox, PlayStation)"}, "type": "single", "values": "lib@values@q7"}, "q7_5": {"name": "q7_5", "parent": {"masks@q7": {"type": "array"}}, "text": {"en-GB": "How often do you use any of the following for any reason? - A digital camera"}, "type": "single", "values": "lib@values@q7"}, "q7_6": {"name": "q7_6", "parent": {"masks@q7": {"type": "array"}}, "text": {"en-GB": "How often do you use any of the following for any reason? - A landline telephone"}, "type": "single", "values": "lib@values@q7"}, "q8": {"name": "q8", "parent": {}, "text": {"en-GB": "Which of the following do you regularly skip?"}, "type": "delimited set", "values": [{"text": {"en-GB": "Breakfast"}, "value": 1}, {"text": {"en-GB": "Mid-morning snacking"}, "value": 2}, {"text": {"en-GB": "Lunch"}, "value": 3}, {"text": {"en-GB": "Mid-afternoon snacking"}, "value": 4}, {"text": {"en-GB": "Dinner"}, "value": 5}, {"text": {"en-GB": "None of them"}, "value": 96}, {"text": {"en-GB": "Don't know (it varies a lot)"}, "value": 98}]}, "q8a": {"name": "q8a", "parent": {}, "text": {"en-GB": "Other specify (q8)"}, "type": "string"}, "q9": {"name": "q9", "parent": {}, "text": {"en-GB": "For what reasons might you visit a sporting goods store in the future?"}, "type": "delimited set", "values": [{"text": {"en-GB": "To buy something for myself"}, "value": 1}, {"text": {"en-GB": "To buy something for somebody else"}, "value": 2}, {"text": {"en-GB": "To ask the staff for sporting advice"}, "value": 3}, {"text": {"en-GB": "To check prices"}, "value": 4}, {"text": {"en-GB": "Other"}, "value": 96}, {"text": {"en-GB": "Don't know"}, "value": 98}, {"text": {"en-GB": "Not applicable - I won't ever go to a sporting goods store"}, "value": 99}]}, "q9a": {"name": "q9a", "parent": {}, "text": {"en-GB": "Other specify (q9)"}, "type": "string"}, "record_number": {"name": "record_number", "parent": {}, "text": {"en-GB": "Record number"}, "type": "int"}, "religion": {"name": "religion", "parent": {}, "text": {"en-GB": "How do you identify religiously?"}, "type": "single", "values": [{"text": {"en-GB": "None"}, "value": 1}, {"text": {"en-GB": "Church of England/Anglican/Episcopal"}, "value": 2}, {"text": {"en-GB": "Roman Catholic"}, "value": 3}, {"text": {"en-GB": "Presbyterian/Church of Scotland"}, "value": 4}, {"text": {"en-GB": "Methodist"}, "value": 5}, {"text": {"en-GB": "Baptist"}, "value": 6}, {"text": {"en-GB": "United Reformed Church"}, "value": 7}, {"text": {"en-GB": "Free Presbyterian"}, "value": 8}, {"text": {"en-GB": "Brethren"}, "value": 9}, {"text": {"en-GB": "Jewish"}, "value": 10}, {"text": {"en-GB": "Hindu"}, "value": 11}, {"text": {"en-GB": "Islam/Muslim"}, "value": 12}, {"text": {"en-GB": "Sikh"}, "value": 13}, {"text": {"en-GB": "Buddhist"}, "value": 14}, {"text": {"en-GB": "Other"}, "value": 15}, {"text": {"en-GB": "Prefer not to say"}, "value": 16}]}, "start_time": {"name": "start_time", "parent": {}, "text": {"en-GB": "Start time of survey"}, "type": "date"}, "unique_id": {"name": "unique_id", "parent": {}, "text": {"en-GB": "Unique identifier"}, "type": "int"}, "visit_1": {"name": "visit_1", "parent": {}, "text": {"en-GB": "Fist store visited."}, "type": "single", "values": [{"text": {"en-GB": "Dunham's Sports"}, "value": 1}, {"text": {"en-GB": "Sports Authority"}, "value": 2}, {"text": {"en-GB": "Champs Sports"}, "value": 3}, {"text": {"en-GB": "Academy Sports + Outdoors"}, "value": 4}, {"text": {"en-GB": "Scheels"}, "value": 5}, {"text": {"en-GB": "Eastern Mountain Sports"}, "value": 6}, {"text": {"en-GB": "City Sports"}, "value": 7}, {"text": {"en-GB": "Didn't have another visit"}, "value": 8}]}, "visit_2": {"name": "visit_2", "parent": {}, "text": {"en-GB": "Second store visited."}, "type": "single", "values": [{"text": {"en-GB": "Dunham's Sports"}, "value": 1}, {"text": {"en-GB": "Sports Authority"}, "value": 2}, {"text": {"en-GB": "Champs Sports"}, "value": 3}, {"text": {"en-GB": "Academy Sports + Outdoors"}, "value": 4}, {"text": {"en-GB": "Scheels"}, "value": 5}, {"text": {"en-GB": "Eastern Mountain Sports"}, "value": 6}, {"text": {"en-GB": "City Sports"}, "value": 7}, {"text": {"en-GB": "Didn't have another visit"}, "value": 8}]}, "visit_3": {"name": "visit_3", "parent": {}, "text": {"en-GB": "Third store visited."}, "type": "single", "values": [{"text": {"en-GB": "Dunham's Sports"}, "value": 1}, {"text": {"en-GB": "Sports Authority"}, "value": 2}, {"text": {"en-GB": "Champs Sports"}, "value": 3}, {"text": {"en-GB": "Academy Sports + Outdoors"}, "value": 4}, {"text": {"en-GB": "Scheels"}, "value": 5}, {"text": {"en-GB": "Eastern Mountain Sports"}, "value": 6}, {"text": {"en-GB": "City Sports"}, "value": 7}, {"text": {"en-GB": "Didn't have another visit"}, "value": 8}]}, "weight": {"name": "weight", "parent": {}, "text": {"en-GB": "Weight (main)"}, "type": "float"}, "weight_a": {"name": "weight_a", "parent": {}, "text": {"en-GB": "Weight (variant A)"}, "type": "float"}, "weight_b": {"name": "weight_b", "parent": {}, "text": {"en-GB": "Weight (variant B)"}, "type": "float"}}, "info": {"from_source": ["./data/Quantipy Example Data.mdd"], "name": "Quantipy Example Data"}, "lib": {"default text": "en-GB", "values": {"q14_1": [{"text": {"en-GB": "Strongly disagree"}, "value": 1}, {"text": {"en-GB": "Disagree"}, "value": 2}, {"text": {"en-GB": "Neither agree nor disagree"}, "value": 3}, {"text": {"en-GB": "Agree"}, "value": 4}, {"text": {"en-GB": "Strongly agree"}, "value": 5}], "q14_2": [{"text": {"en-GB": "Strongly disagree"}, "value": 1}, {"text": {"en-GB": "Disagree"}, "value": 2}, {"text": {"en-GB": "Neither agree nor disagree"}, "value": 3}, {"text": {"en-GB": "Agree"}, "value": 4}, {"text": {"en-GB": "Strongly agree"}, "value": 5}], "q14_3": [{"text": {"en-GB": "Strongly disagree"}, "value": 1}, {"text": {"en-GB": "Disagree"}, "value": 2}, {"text": {"en-GB": "Neither agree nor disagree"}, "value": 3}, {"text": {"en-GB": "Agree"}, "value": 4}, {"text": {"en-GB": "Strongly agree"}, "value": 5}], "q5": [{"text": {"en-GB": "I would refuse if asked"}, "value": 1}, {"text": {"en-GB": "Very unlikely"}, "value": 2}, {"text": {"en-GB": "Probably wouldn't"}, "value": 3}, {"text": {"en-GB": "Probably would if asked"}, "value": 4}, {"text": {"en-GB": "Very likely"}, "value": 5}, {"text": {"en-GB": "I'm already planning to"}, "value": 97}, {"text": {"en-GB": "Don't know"}, "value": 98}], "q6": [{"text": {"en-GB": "Once a day or more often"}, "value": 1}, {"text": {"en-GB": "Every few days"}, "value": 2}, {"text": {"en-GB": "Once a week"}, "value": 3}, {"text": {"en-GB": "Once a fortnight"}, "value": 4}, {"text": {"en-GB": "Once a month"}, "value": 5}, {"text": {"en-GB": "Once every few months"}, "value": 6}, {"text": {"en-GB": "Once every six months"}, "value": 7}, {"text": {"en-GB": "Once a year"}, "value": 8}, {"text": {"en-GB": "Less often than once a year"}, "value": 9}, {"text": {"en-GB": "Never"}, "value": 10}], "q7": [{"text": {"en-GB": "Once a day or more often"}, "value": 1}, {"text": {"en-GB": "Every few days"}, "value": 2}, {"text": {"en-GB": "Once a week"}, "value": 3}, {"text": {"en-GB": "Once a fortnight"}, "value": 4}, {"text": {"en-GB": "Once a month"}, "value": 5}, {"text": {"en-GB": "Once every few months"}, "value": 6}, {"text": {"en-GB": "Once every six months"}, "value": 7}, {"text": {"en-GB": "Once a year"}, "value": 8}, {"text": {"en-GB": "Less often than once a year"}, "value": 9}]}}, "masks": {"q14_1": {"items": [{"properties": {}, "source": "columns@q14r01c01", "text": {"en-GB": "I had a good experience in the store."}}, {"properties": {}, "source": "columns@q14r02c01", "text": {"en-GB": "The store was clean."}}, {"properties": {}, "source": "columns@q14r03c01", "text": {"en-GB": "It was easy to find what I was looking for."}}, {"properties": {}, "source": "columns@q14r04c01", "text": {"en-GB": "The store had everything I needed."}}, {"properties": {}, "source": "columns@q14r05c01", "text": {"en-GB": "The store's staff were friendly and helpful."}}, {"properties": {}, "source": "columns@q14r06c01", "text": {"en-GB": "The wait time when checking out was acceptable."}}, {"properties": {}, "source": "columns@q14r07c01", "text": {"en-GB": "The music playing in the store was appropriate."}}, {"properties": {}, "source": "columns@q14r08c01", "text": {"en-GB": "The staff made me feel welcome."}}, {"properties": {}, "source": "columns@q14r09c01", "text": {"en-GB": "The climate control in the store was set appropriately."}}, {"properties": {}, "source": "columns@q14r10c01", "text": {"en-GB": "The store had ample available parking when I arrived."}}], "name": "q14_1", "properties": {}, "subtype": "single", "text": {"en-GB": "Store 1"}, "type": "array", "values": "lib@values@q14_1"}, "q14_2": {"items": [{"properties": {}, "source": "columns@q14r01c02", "text": {"en-GB": "I had a good experience in the store."}}, {"properties": {}, "source": "columns@q14r02c02", "text": {"en-GB": "The store was clean."}}, {"properties": {}, "source": "columns@q14r03c02", "text": {"en-GB": "It was easy to find what I was looking for."}}, {"properties": {}, "source": "columns@q14r04c02", "text": {"en-GB": "The store had everything I needed."}}, {"properties": {}, "source": "columns@q14r05c02", "text": {"en-GB": "The store's staff were friendly and helpful."}}, {"properties": {}, "source": "columns@q14r06c02", "text": {"en-GB": "The wait time when checking out was acceptable."}}, {"properties": {}, "source": "columns@q14r07c02", "text": {"en-GB": "The music playing in the store was appropriate."}}, {"properties": {}, "source": "columns@q14r08c02", "text": {"en-GB": "The staff made me feel welcome."}}, {"properties": {}, "source": "columns@q14r09c02", "text": {"en-GB": "The climate control in the store was set appropriately."}}, {"properties": {}, "source": "columns@q14r10c02", "text": {"en-GB": "The store had ample available parking when I arrived."}}], "name": "q14_2", "properties": {}, "subtype": "single", "text": {"en-GB": "Store 2"}, "type": "array", "values": "lib@values@q14_2"}, "q14_3": {"items": [{"properties": {}, "source": "columns@q14r01c03", "text": {"en-GB": "I had a good experience in the store."}}, {"properties": {}, "source": "columns@q14r02c03", "text": {"en-GB": "The store was clean."}}, {"properties": {}, "source": "columns@q14r03c03", "text": {"en-GB": "It was easy to find what I was looking for."}}, {"properties": {}, "source": "columns@q14r04c03", "text": {"en-GB": "The store had everything I needed."}}, {"properties": {}, "source": "columns@q14r05c03", "text": {"en-GB": "The store's staff were friendly and helpful."}}, {"properties": {}, "source": "columns@q14r06c03", "text": {"en-GB": "The wait time when checking out was acceptable."}}, {"properties": {}, "source": "columns@q14r07c03", "text": {"en-GB": "The music playing in the store was appropriate."}}, {"properties": {}, "source": "columns@q14r08c03", "text": {"en-GB": "The staff made me feel welcome."}}, {"properties": {}, "source": "columns@q14r09c03", "text": {"en-GB": "The climate control in the store was set appropriately."}}, {"properties": {}, "source": "columns@q14r10c03", "text": {"en-GB": "The store had ample available parking when I arrived."}}], "name": "q14_3", "properties": {}, "subtype": "single", "text": {"en-GB": "Store 3"}, "type": "array", "values": "lib@values@q14_3"}, "q5": {"items": [{"source": "columns@q5_1", "text": {"en-GB": "Surfing"}}, {"source": "columns@q5_2", "text": {"en-GB": "Snowboarding"}}, {"source": "columns@q5_3", "text": {"en-GB": "Kite boarding"}}, {"source": "columns@q5_4", "text": {"en-GB": "Parachuting"}}, {"source": "columns@q5_5", "text": {"en-GB": "Cave diving"}}, {"source": "columns@q5_6", "text": {"en-GB": "Windsurfing"}}], "name": "q5", "subtype": "single", "text": {"en-GB": "How likely are you to do each of the following in the next year?"}, "type": "array", "values": "lib@values@q5"}, "q6": {"items": [{"source": "columns@q6_1", "text": {"en-GB": "Exercise alone"}}, {"source": "columns@q6_2", "text": {"en-GB": "Join an exercise class"}}, {"source": "columns@q6_3", "text": {"en-GB": "Play any kind of team sport"}}], "name": "q6", "subtype": "single", "text": {"en-GB": "How often do you take part in any of the following?"}, "type": "array", "values": "lib@values@q6"}, "q7": {"items": [{"source": "columns@q7_1", "text": {"en-GB": "A smartphone"}}, {"source": "columns@q7_2", "text": {"en-GB": "A tablet"}}, {"source": "columns@q7_3", "text": {"en-GB": "A laptop/ PC"}}, {"source": "columns@q7_4", "text": {"en-GB": "A gaming console (e.g. Xbox, PlayStation)"}}, {"source": "columns@q7_5", "text": {"en-GB": "A digital camera"}}, {"source": "columns@q7_6", "text": {"en-GB": "A landline telephone"}}], "name": "q7", "subtype": "single", "text": {"en-GB": "How often do you use any of the following for any reason?"}, "type": "array", "values": "lib@values@q7"}}, "sets": {"data file": {"items": ["columns@record_number", "columns@unique_id", "columns@age", "columns@birth_day", "columns@birth_month", "columns@birth_year", "columns@gender", "columns@locality", "columns@ethnicity", "columns@religion", "columns@q1", "columns@q2", "columns@q2b", "columns@q3", "columns@q4", "masks@q5", "masks@q6", "masks@q7", "columns@q8", "columns@q8a", "columns@q9", "columns@q9a", "columns@Wave", "columns@weight_a", "columns@weight_b", "columns@start_time", "columns@end_time", "columns@duration", "masks@q14_1", "masks@q14_2", "masks@q14_3", "columns@RecordNo"], "text": "As per the data file"}, "q14_1": {"items": ["columns@q14r01c01", "columns@q14r02c01", "columns@q14r03c01", "columns@q14r04c01", "columns@q14r05c01", "columns@q14r06c01", "columns@q14r07c01", "columns@q14r08c01", "columns@q14r09c01", "columns@q14r10c01"]}, "q14_2": {"items": ["columns@q14r01c02", "columns@q14r02c02", "columns@q14r03c02", "columns@q14r04c02", "columns@q14r05c02", "columns@q14r06c02", "columns@q14r07c02", "columns@q14r08c02", "columns@q14r09c02", "columns@q14r10c02"]}, "q14_3": {"items": ["columns@q14r01c03", "columns@q14r02c03", "columns@q14r03c03", "columns@q14r04c03", "columns@q14r05c03", "columns@q14r06c03", "columns@q14r07c03", "columns@q14r08c03", "columns@q14r09c03", "columns@q14r10c03"]}, "q5": {"items": ["columns@q5_1", "columns@q5_2", "columns@q5_3", "columns@q5_4", "columns@q5_5", "columns@q5_6"]}, "q6": {"items": ["columns@q6_1", "columns@q6_2", "columns@q6_3"]}, "q7": {"items": ["columns@q7_1", "columns@q7_2", "columns@q7_3", "columns@q7_4", "columns@q7_5", "columns@q7_6"]}}, "type": "pandas.DataFrame"} \ No newline at end of file +{"columns": {"@1": {"type": "int"}, "RecordNo": {"name": "RecordNo", "parent": {}, "properties": {"created": true}, "text": {"en-GB": "RecordNo"}, "type": "int"}, "Wave": {"name": "Wave", "parent": {}, "text": {"en-GB": "Wave"}, "type": "single", "values": [{"text": {"en-GB": "Wave 1"}, "value": 1}, {"text": {"en-GB": "Wave 2"}, "value": 2}, {"text": {"en-GB": "Wave 3"}, "value": 3}, {"text": {"en-GB": "Wave 4"}, "value": 4}, {"text": {"en-GB": "Wave 5"}, "value": 5}]}, "age": {"name": "age", "parent": {}, "text": {"en-GB": "Age"}, "type": "int"}, "birth_day": {"name": "birth_day", "parent": {}, "text": {"en-GB": "Birth day"}, "type": "int"}, "birth_month": {"name": "birth_month", "parent": {}, "text": {"en-GB": "Birth month"}, "type": "int"}, "birth_year": {"name": "birth_year", "parent": {}, "text": {"en-GB": "Birth year"}, "type": "int"}, "duration": {"name": "duration", "parent": {}, "text": {"en-GB": "Duration"}, "type": "time"}, "end_time": {"name": "end_time", "parent": {}, "text": {"en-GB": "End time of survey"}, "type": "date"}, "ethnicity": {"name": "ethnicity", "parent": {}, "text": {"en-GB": "What is your ethnicity?"}, "type": "single", "values": [{"text": {"en-GB": "White European"}, "value": 1}, {"text": {"en-GB": "Any other white background"}, "value": 2}, {"text": {"en-GB": "White and Black Caribbean"}, "value": 3}, {"text": {"en-GB": "White and Black African"}, "value": 4}, {"text": {"en-GB": "White and Asian"}, "value": 5}, {"text": {"en-GB": "Any other mixed background"}, "value": 6}, {"text": {"en-GB": "Indian"}, "value": 7}, {"text": {"en-GB": "Pakistani"}, "value": 8}, {"text": {"en-GB": "Bangladeshi"}, "value": 9}, {"text": {"en-GB": "Any other Asian background"}, "value": 10}, {"text": {"en-GB": "Black Caribbean"}, "value": 11}, {"text": {"en-GB": "Black African"}, "value": 12}, {"text": {"en-GB": "Any other black background"}, "value": 13}, {"text": {"en-GB": "Chinese"}, "value": 14}, {"text": {"en-GB": "Other ethnic group"}, "value": 15}, {"text": {"en-GB": "Prefer not to say"}, "value": 16}]}, "gender": {"name": "gender", "parent": {}, "text": {"en-GB": "What is your gender?"}, "type": "single", "values": [{"text": {"en-GB": "Male"}, "value": 1}, {"text": {"en-GB": "Female"}, "value": 2}]}, "locality": {"name": "locality", "parent": {}, "text": {"en-GB": "How would you describe the areas in which you live?"}, "type": "single", "values": [{"text": {"en-GB": "CBD (central business district)"}, "value": 1}, {"text": {"en-GB": "Urban"}, "value": 2}, {"text": {"en-GB": "Suburban"}, "value": 3}, {"text": {"en-GB": "Rural"}, "value": 4}, {"text": {"en-GB": "Remote"}, "value": 5}]}, "q1": {"name": "q1", "parent": {}, "text": {"en-GB": "What is your main fitness activity?"}, "type": "single", "values": [{"text": {"en-GB": "Swimming"}, "value": 1}, {"text": {"en-GB": "Running/jogging"}, "value": 2}, {"text": {"en-GB": "Lifting weights"}, "value": 3}, {"text": {"en-GB": "Aerobics"}, "value": 4}, {"text": {"en-GB": "Yoga"}, "value": 5}, {"text": {"en-GB": "Pilates"}, "value": 6}, {"text": {"en-GB": "Football (soccer)"}, "value": 7}, {"text": {"en-GB": "Basketball"}, "value": 8}, {"text": {"en-GB": "Hockey"}, "value": 9}, {"text": {"en-GB": "Other"}, "value": 96}, {"text": {"en-GB": "I regularly change my fitness activity"}, "value": 98}, {"text": {"en-GB": "Not applicable - I don't exercise"}, "value": 99}]}, "q14r01c01": {"name": "q14r01c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - I had a good experience in the store."}, "type": "single", "values": "lib@values@q14_1"}, "q14r01c02": {"name": "q14r01c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - I had a good experience in the store."}, "type": "single", "values": "lib@values@q14_2"}, "q14r01c03": {"name": "q14r01c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - I had a good experience in the store."}, "type": "single", "values": "lib@values@q14_3"}, "q14r02c01": {"name": "q14r02c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - The store was clean."}, "type": "single", "values": "lib@values@q14_1"}, "q14r02c02": {"name": "q14r02c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - The store was clean."}, "type": "single", "values": "lib@values@q14_2"}, "q14r02c03": {"name": "q14r02c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - The store was clean."}, "type": "single", "values": "lib@values@q14_3"}, "q14r03c01": {"name": "q14r03c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - It was easy to find what I was looking for."}, "type": "single", "values": "lib@values@q14_1"}, "q14r03c02": {"name": "q14r03c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - It was easy to find what I was looking for."}, "type": "single", "values": "lib@values@q14_2"}, "q14r03c03": {"name": "q14r03c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - It was easy to find what I was looking for."}, "type": "single", "values": "lib@values@q14_3"}, "q14r04c01": {"name": "q14r04c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - The store had everything I needed."}, "type": "single", "values": "lib@values@q14_1"}, "q14r04c02": {"name": "q14r04c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - The store had everything I needed."}, "type": "single", "values": "lib@values@q14_2"}, "q14r04c03": {"name": "q14r04c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - The store had everything I needed."}, "type": "single", "values": "lib@values@q14_3"}, "q14r05c01": {"name": "q14r05c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - The store's staff were friendly and helpful."}, "type": "single", "values": "lib@values@q14_1"}, "q14r05c02": {"name": "q14r05c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - The store's staff were friendly and helpful."}, "type": "single", "values": "lib@values@q14_2"}, "q14r05c03": {"name": "q14r05c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - The store's staff were friendly and helpful."}, "type": "single", "values": "lib@values@q14_3"}, "q14r06c01": {"name": "q14r06c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - The wait time when checking out was acceptable."}, "type": "single", "values": "lib@values@q14_1"}, "q14r06c02": {"name": "q14r06c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - The wait time when checking out was acceptable."}, "type": "single", "values": "lib@values@q14_2"}, "q14r06c03": {"name": "q14r06c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - The wait time when checking out was acceptable."}, "type": "single", "values": "lib@values@q14_3"}, "q14r07c01": {"name": "q14r07c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - The music playing in the store was appropriate."}, "type": "single", "values": "lib@values@q14_1"}, "q14r07c02": {"name": "q14r07c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - The music playing in the store was appropriate."}, "type": "single", "values": "lib@values@q14_2"}, "q14r07c03": {"name": "q14r07c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - The music playing in the store was appropriate."}, "type": "single", "values": "lib@values@q14_3"}, "q14r08c01": {"name": "q14r08c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - The staff made me feel welcome."}, "type": "single", "values": "lib@values@q14_1"}, "q14r08c02": {"name": "q14r08c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - The staff made me feel welcome."}, "type": "single", "values": "lib@values@q14_2"}, "q14r08c03": {"name": "q14r08c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - The staff made me feel welcome."}, "type": "single", "values": "lib@values@q14_3"}, "q14r09c01": {"name": "q14r09c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - The climate control in the store was set appropriately."}, "type": "single", "values": "lib@values@q14_1"}, "q14r09c02": {"name": "q14r09c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - The climate control in the store was set appropriately."}, "type": "single", "values": "lib@values@q14_2"}, "q14r09c03": {"name": "q14r09c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - The climate control in the store was set appropriately."}, "type": "single", "values": "lib@values@q14_3"}, "q14r10c01": {"name": "q14r10c01", "parent": {"masks@q14_1": {"type": "array"}}, "text": {"en-GB": "Store 1 - The store had ample available parking when I arrived."}, "type": "single", "values": "lib@values@q14_1"}, "q14r10c02": {"name": "q14r10c02", "parent": {"masks@q14_2": {"type": "array"}}, "text": {"en-GB": "Store 2 - The store had ample available parking when I arrived."}, "type": "single", "values": "lib@values@q14_2"}, "q14r10c03": {"name": "q14r10c03", "parent": {"masks@q14_3": {"type": "array"}}, "text": {"en-GB": "Store 3 - The store had ample available parking when I arrived."}, "type": "single", "values": "lib@values@q14_3"}, "q2": {"name": "q2", "parent": {}, "text": {"en-GB": "Which, if any, of these other sports have you ever participated in?"}, "type": "delimited set", "values": [{"text": {"en-GB": "Sky diving"}, "value": 1}, {"text": {"en-GB": "Base jumping"}, "value": 2}, {"text": {"en-GB": "Mountain biking"}, "value": 3}, {"text": {"en-GB": "Kite boarding"}, "value": 4}, {"text": {"en-GB": "Snowboarding"}, "value": 5}, {"text": {"en-GB": "Parachuting"}, "value": 6}, {"text": {"en-GB": "Other"}, "value": 97}, {"text": {"en-GB": "None of these"}, "value": 98}]}, "q2b": {"name": "q2b", "parent": {}, "text": {"en-GB": "How regularly do you participate in any fitness or sports activity?"}, "type": "single", "values": [{"text": {"en-GB": "Regularly"}, "value": 1}, {"text": {"en-GB": "Irregularly"}, "value": 2}, {"text": {"en-GB": "Never"}, "value": 3}]}, "q3": {"name": "q3", "parent": {}, "text": {"en-GB": "Which of these pieces of sports equipment are owned by anyone in your household?"}, "type": "delimited set", "values": [{"text": {"en-GB": "Basketball"}, "value": 1}, {"text": {"en-GB": "Football"}, "value": 2}, {"text": {"en-GB": "Hockey stick"}, "value": 3}, {"text": {"en-GB": "Surfboard"}, "value": 4}, {"text": {"en-GB": "Climbing gear"}, "value": 5}, {"text": {"en-GB": "Bicycle"}, "value": 6}, {"text": {"en-GB": "Parachute"}, "value": 7}, {"text": {"en-GB": "Swimming goggles"}, "value": 8}, {"text": {"en-GB": "None of these"}, "value": 97}]}, "q4": {"name": "q4", "parent": {}, "text": {"en-GB": "Do you ever participate in sports activities with people in your household?"}, "type": "single", "values": [{"text": {"en-GB": "Yes"}, "value": 1}, {"text": {"en-GB": "No"}, "value": 2}]}, "q5_1": {"name": "q5_1", "parent": {"masks@q5": {"type": "array"}}, "text": {"en-GB": "How likely are you to do each of the following in the next year? - Surfing"}, "type": "single", "values": "lib@values@q5"}, "q5_2": {"name": "q5_2", "parent": {"masks@q5": {"type": "array"}}, "text": {"en-GB": "How likely are you to do each of the following in the next year? - Snowboarding"}, "type": "single", "values": "lib@values@q5"}, "q5_3": {"name": "q5_3", "parent": {"masks@q5": {"type": "array"}}, "text": {"en-GB": "How likely are you to do each of the following in the next year? - Kite boarding"}, "type": "single", "values": "lib@values@q5"}, "q5_4": {"name": "q5_4", "parent": {"masks@q5": {"type": "array"}}, "text": {"en-GB": "How likely are you to do each of the following in the next year? - Parachuting"}, "type": "single", "values": "lib@values@q5"}, "q5_5": {"name": "q5_5", "parent": {"masks@q5": {"type": "array"}}, "text": {"en-GB": "How likely are you to do each of the following in the next year? - Cave diving"}, "type": "single", "values": "lib@values@q5"}, "q5_6": {"name": "q5_6", "parent": {"masks@q5": {"type": "array"}}, "text": {"en-GB": "How likely are you to do each of the following in the next year? - Windsurfing"}, "type": "single", "values": [{"text": {"en-GB": "I would refuse if asked"}, "value": 1}, {"text": {"en-GB": "Very unlikely"}, "value": 2}, {"text": {"en-GB": "Probably wouldn't"}, "value": 3}, {"text": {"en-GB": "Probably would if asked"}, "value": 4}, {"text": {"en-GB": "Very likely"}, "value": 5}, {"text": {"en-GB": "I'm already planning to"}, "value": 97}, {"text": {"en-GB": "Don't know"}, "value": 98}]}, "q6_1": {"name": "q6_1", "parent": {"masks@q6": {"type": "array"}}, "text": {"en-GB": "How often do you take part in any of the following? - Exercise alone"}, "type": "single", "values": "lib@values@q6"}, "q6_2": {"name": "q6_2", "parent": {"masks@q6": {"type": "array"}}, "text": {"en-GB": "How often do you take part in any of the following? - Join an exercise class"}, "type": "single", "values": "lib@values@q6"}, "q6_3": {"name": "q6_3", "parent": {"masks@q6": {"type": "array"}}, "text": {"en-GB": "How often do you take part in any of the following? - Play any kind of team sport"}, "type": "single", "values": "lib@values@q6"}, "q7_1": {"name": "q7_1", "parent": {"masks@q7": {"type": "array"}}, "text": {"en-GB": "How often do you use any of the following for any reason? - A smartphone"}, "type": "single", "values": "lib@values@q7"}, "q7_2": {"name": "q7_2", "parent": {"masks@q7": {"type": "array"}}, "text": {"en-GB": "How often do you use any of the following for any reason? - A tablet"}, "type": "single", "values": "lib@values@q7"}, "q7_3": {"name": "q7_3", "parent": {"masks@q7": {"type": "array"}}, "text": {"en-GB": "How often do you use any of the following for any reason? - A laptop/ PC"}, "type": "single", "values": "lib@values@q7"}, "q7_4": {"name": "q7_4", "parent": {"masks@q7": {"type": "array"}}, "text": {"en-GB": "How often do you use any of the following for any reason? - A gaming console (e.g. Xbox, PlayStation)"}, "type": "single", "values": "lib@values@q7"}, "q7_5": {"name": "q7_5", "parent": {"masks@q7": {"type": "array"}}, "text": {"en-GB": "How often do you use any of the following for any reason? - A digital camera"}, "type": "single", "values": "lib@values@q7"}, "q7_6": {"name": "q7_6", "parent": {"masks@q7": {"type": "array"}}, "text": {"en-GB": "How often do you use any of the following for any reason? - A landline telephone"}, "type": "single", "values": "lib@values@q7"}, "q8": {"name": "q8", "parent": {}, "text": {"en-GB": "Which of the following do you regularly skip?"}, "type": "delimited set", "values": [{"text": {"en-GB": "Breakfast"}, "value": 1}, {"text": {"en-GB": "Mid-morning snacking"}, "value": 2}, {"text": {"en-GB": "Lunch"}, "value": 3}, {"text": {"en-GB": "Mid-afternoon snacking"}, "value": 4}, {"text": {"en-GB": "Dinner"}, "value": 5}, {"text": {"en-GB": "None of them"}, "value": 96}, {"text": {"en-GB": "Don't know (it varies a lot)"}, "value": 98}]}, "q8a": {"name": "q8a", "parent": {}, "text": {"en-GB": "Other specify (q8)"}, "type": "string"}, "q9": {"name": "q9", "parent": {}, "text": {"en-GB": "For what reasons might you visit a sporting goods store in the future?"}, "type": "delimited set", "values": [{"text": {"en-GB": "To buy something for myself"}, "value": 1}, {"text": {"en-GB": "To buy something for somebody else"}, "value": 2}, {"text": {"en-GB": "To ask the staff for sporting advice"}, "value": 3}, {"text": {"en-GB": "To check prices"}, "value": 4}, {"text": {"en-GB": "Other"}, "value": 96}, {"text": {"en-GB": "Don't know"}, "value": 98}, {"text": {"en-GB": "Not applicable - I won't ever go to a sporting goods store"}, "value": 99}]}, "q9a": {"name": "q9a", "parent": {}, "text": {"en-GB": "Other specify (q9)"}, "type": "string"}, "record_number": {"name": "record_number", "parent": {}, "text": {"en-GB": "Record number"}, "type": "int"}, "religion": {"name": "religion", "parent": {}, "text": {"en-GB": "How do you identify religiously?"}, "type": "single", "values": [{"text": {"en-GB": "None"}, "value": 1}, {"text": {"en-GB": "Church of England/Anglican/Episcopal"}, "value": 2}, {"text": {"en-GB": "Roman Catholic"}, "value": 3}, {"text": {"en-GB": "Presbyterian/Church of Scotland"}, "value": 4}, {"text": {"en-GB": "Methodist"}, "value": 5}, {"text": {"en-GB": "Baptist"}, "value": 6}, {"text": {"en-GB": "United Reformed Church"}, "value": 7}, {"text": {"en-GB": "Free Presbyterian"}, "value": 8}, {"text": {"en-GB": "Brethren"}, "value": 9}, {"text": {"en-GB": "Jewish"}, "value": 10}, {"text": {"en-GB": "Hindu"}, "value": 11}, {"text": {"en-GB": "Islam/Muslim"}, "value": 12}, {"text": {"en-GB": "Sikh"}, "value": 13}, {"text": {"en-GB": "Buddhist"}, "value": 14}, {"text": {"en-GB": "Other"}, "value": 15}, {"text": {"en-GB": "Prefer not to say"}, "value": 16}]}, "start_time": {"name": "start_time", "parent": {}, "text": {"en-GB": "Start time of survey"}, "type": "date"}, "unique_id": {"name": "unique_id", "parent": {}, "text": {"en-GB": "Unique identifier"}, "type": "int"}, "visit_1": {"name": "visit_1", "parent": {}, "text": {"en-GB": "Fist store visited."}, "type": "single", "values": [{"text": {"en-GB": "Dunham's Sports"}, "value": 1}, {"text": {"en-GB": "Sports Authority"}, "value": 2}, {"text": {"en-GB": "Champs Sports"}, "value": 3}, {"text": {"en-GB": "Academy Sports + Outdoors"}, "value": 4}, {"text": {"en-GB": "Scheels"}, "value": 5}, {"text": {"en-GB": "Eastern Mountain Sports"}, "value": 6}, {"text": {"en-GB": "City Sports"}, "value": 7}, {"text": {"en-GB": "Didn't have another visit"}, "value": 8}]}, "visit_2": {"name": "visit_2", "parent": {}, "text": {"en-GB": "Second store visited."}, "type": "single", "values": [{"text": {"en-GB": "Dunham's Sports"}, "value": 1}, {"text": {"en-GB": "Sports Authority"}, "value": 2}, {"text": {"en-GB": "Champs Sports"}, "value": 3}, {"text": {"en-GB": "Academy Sports + Outdoors"}, "value": 4}, {"text": {"en-GB": "Scheels"}, "value": 5}, {"text": {"en-GB": "Eastern Mountain Sports"}, "value": 6}, {"text": {"en-GB": "City Sports"}, "value": 7}, {"text": {"en-GB": "Didn't have another visit"}, "value": 8}]}, "visit_3": {"name": "visit_3", "parent": {}, "text": {"en-GB": "Third store visited."}, "type": "single", "values": [{"text": {"en-GB": "Dunham's Sports"}, "value": 1}, {"text": {"en-GB": "Sports Authority"}, "value": 2}, {"text": {"en-GB": "Champs Sports"}, "value": 3}, {"text": {"en-GB": "Academy Sports + Outdoors"}, "value": 4}, {"text": {"en-GB": "Scheels"}, "value": 5}, {"text": {"en-GB": "Eastern Mountain Sports"}, "value": 6}, {"text": {"en-GB": "City Sports"}, "value": 7}, {"text": {"en-GB": "Didn't have another visit"}, "value": 8}]}, "weight": {"name": "weight", "parent": {}, "text": {"en-GB": "Weight (main)"}, "type": "float"}, "weight_a": {"name": "weight_a", "parent": {}, "text": {"en-GB": "Weight (variant A)"}, "type": "float"}, "weight_b": {"name": "weight_b", "parent": {}, "text": {"en-GB": "Weight (variant B)"}, "type": "float"}}, "info": {"dataset": {"name": "Quantipy Example Data"}, "from_source": ["./data/Quantipy Example Data.mdd"], "name": "Quantipy Example Data"}, "lib": {"default text": "en-GB", "values": {"q14_1": [{"text": {"en-GB": "Strongly disagree"}, "value": 1}, {"text": {"en-GB": "Disagree"}, "value": 2}, {"text": {"en-GB": "Neither agree nor disagree"}, "value": 3}, {"text": {"en-GB": "Agree"}, "value": 4}, {"text": {"en-GB": "Strongly agree"}, "value": 5}], "q14_2": [{"text": {"en-GB": "Strongly disagree"}, "value": 1}, {"text": {"en-GB": "Disagree"}, "value": 2}, {"text": {"en-GB": "Neither agree nor disagree"}, "value": 3}, {"text": {"en-GB": "Agree"}, "value": 4}, {"text": {"en-GB": "Strongly agree"}, "value": 5}], "q14_3": [{"text": {"en-GB": "Strongly disagree"}, "value": 1}, {"text": {"en-GB": "Disagree"}, "value": 2}, {"text": {"en-GB": "Neither agree nor disagree"}, "value": 3}, {"text": {"en-GB": "Agree"}, "value": 4}, {"text": {"en-GB": "Strongly agree"}, "value": 5}], "q5": [{"text": {"en-GB": "I would refuse if asked"}, "value": 1}, {"text": {"en-GB": "Very unlikely"}, "value": 2}, {"text": {"en-GB": "Probably wouldn't"}, "value": 3}, {"text": {"en-GB": "Probably would if asked"}, "value": 4}, {"text": {"en-GB": "Very likely"}, "value": 5}, {"text": {"en-GB": "I'm already planning to"}, "value": 97}, {"text": {"en-GB": "Don't know"}, "value": 98}], "q6": [{"text": {"en-GB": "Once a day or more often"}, "value": 1}, {"text": {"en-GB": "Every few days"}, "value": 2}, {"text": {"en-GB": "Once a week"}, "value": 3}, {"text": {"en-GB": "Once a fortnight"}, "value": 4}, {"text": {"en-GB": "Once a month"}, "value": 5}, {"text": {"en-GB": "Once every few months"}, "value": 6}, {"text": {"en-GB": "Once every six months"}, "value": 7}, {"text": {"en-GB": "Once a year"}, "value": 8}, {"text": {"en-GB": "Less often than once a year"}, "value": 9}, {"text": {"en-GB": "Never"}, "value": 10}], "q7": [{"text": {"en-GB": "Once a day or more often"}, "value": 1}, {"text": {"en-GB": "Every few days"}, "value": 2}, {"text": {"en-GB": "Once a week"}, "value": 3}, {"text": {"en-GB": "Once a fortnight"}, "value": 4}, {"text": {"en-GB": "Once a month"}, "value": 5}, {"text": {"en-GB": "Once every few months"}, "value": 6}, {"text": {"en-GB": "Once every six months"}, "value": 7}, {"text": {"en-GB": "Once a year"}, "value": 8}, {"text": {"en-GB": "Less often than once a year"}, "value": 9}]}}, "masks": {"q14_1": {"items": [{"properties": {}, "source": "columns@q14r01c01", "text": {"en-GB": "I had a good experience in the store."}}, {"properties": {}, "source": "columns@q14r02c01", "text": {"en-GB": "The store was clean."}}, {"properties": {}, "source": "columns@q14r03c01", "text": {"en-GB": "It was easy to find what I was looking for."}}, {"properties": {}, "source": "columns@q14r04c01", "text": {"en-GB": "The store had everything I needed."}}, {"properties": {}, "source": "columns@q14r05c01", "text": {"en-GB": "The store's staff were friendly and helpful."}}, {"properties": {}, "source": "columns@q14r06c01", "text": {"en-GB": "The wait time when checking out was acceptable."}}, {"properties": {}, "source": "columns@q14r07c01", "text": {"en-GB": "The music playing in the store was appropriate."}}, {"properties": {}, "source": "columns@q14r08c01", "text": {"en-GB": "The staff made me feel welcome."}}, {"properties": {}, "source": "columns@q14r09c01", "text": {"en-GB": "The climate control in the store was set appropriately."}}, {"properties": {}, "source": "columns@q14r10c01", "text": {"en-GB": "The store had ample available parking when I arrived."}}], "name": "q14_1", "properties": {}, "subtype": "single", "text": {"en-GB": "Store 1"}, "type": "array", "values": "lib@values@q14_1"}, "q14_2": {"items": [{"properties": {}, "source": "columns@q14r01c02", "text": {"en-GB": "I had a good experience in the store."}}, {"properties": {}, "source": "columns@q14r02c02", "text": {"en-GB": "The store was clean."}}, {"properties": {}, "source": "columns@q14r03c02", "text": {"en-GB": "It was easy to find what I was looking for."}}, {"properties": {}, "source": "columns@q14r04c02", "text": {"en-GB": "The store had everything I needed."}}, {"properties": {}, "source": "columns@q14r05c02", "text": {"en-GB": "The store's staff were friendly and helpful."}}, {"properties": {}, "source": "columns@q14r06c02", "text": {"en-GB": "The wait time when checking out was acceptable."}}, {"properties": {}, "source": "columns@q14r07c02", "text": {"en-GB": "The music playing in the store was appropriate."}}, {"properties": {}, "source": "columns@q14r08c02", "text": {"en-GB": "The staff made me feel welcome."}}, {"properties": {}, "source": "columns@q14r09c02", "text": {"en-GB": "The climate control in the store was set appropriately."}}, {"properties": {}, "source": "columns@q14r10c02", "text": {"en-GB": "The store had ample available parking when I arrived."}}], "name": "q14_2", "properties": {}, "subtype": "single", "text": {"en-GB": "Store 2"}, "type": "array", "values": "lib@values@q14_2"}, "q14_3": {"items": [{"properties": {}, "source": "columns@q14r01c03", "text": {"en-GB": "I had a good experience in the store."}}, {"properties": {}, "source": "columns@q14r02c03", "text": {"en-GB": "The store was clean."}}, {"properties": {}, "source": "columns@q14r03c03", "text": {"en-GB": "It was easy to find what I was looking for."}}, {"properties": {}, "source": "columns@q14r04c03", "text": {"en-GB": "The store had everything I needed."}}, {"properties": {}, "source": "columns@q14r05c03", "text": {"en-GB": "The store's staff were friendly and helpful."}}, {"properties": {}, "source": "columns@q14r06c03", "text": {"en-GB": "The wait time when checking out was acceptable."}}, {"properties": {}, "source": "columns@q14r07c03", "text": {"en-GB": "The music playing in the store was appropriate."}}, {"properties": {}, "source": "columns@q14r08c03", "text": {"en-GB": "The staff made me feel welcome."}}, {"properties": {}, "source": "columns@q14r09c03", "text": {"en-GB": "The climate control in the store was set appropriately."}}, {"properties": {}, "source": "columns@q14r10c03", "text": {"en-GB": "The store had ample available parking when I arrived."}}], "name": "q14_3", "properties": {}, "subtype": "single", "text": {"en-GB": "Store 3"}, "type": "array", "values": "lib@values@q14_3"}, "q5": {"items": [{"source": "columns@q5_1", "text": {"en-GB": "Surfing"}}, {"source": "columns@q5_2", "text": {"en-GB": "Snowboarding"}}, {"source": "columns@q5_3", "text": {"en-GB": "Kite boarding"}}, {"source": "columns@q5_4", "text": {"en-GB": "Parachuting"}}, {"source": "columns@q5_5", "text": {"en-GB": "Cave diving"}}, {"source": "columns@q5_6", "text": {"en-GB": "Windsurfing"}}], "name": "q5", "subtype": "single", "text": {"en-GB": "How likely are you to do each of the following in the next year?"}, "type": "array", "values": "lib@values@q5"}, "q6": {"items": [{"source": "columns@q6_1", "text": {"en-GB": "Exercise alone"}}, {"source": "columns@q6_2", "text": {"en-GB": "Join an exercise class"}}, {"source": "columns@q6_3", "text": {"en-GB": "Play any kind of team sport"}}], "name": "q6", "subtype": "single", "text": {"en-GB": "How often do you take part in any of the following?"}, "type": "array", "values": "lib@values@q6"}, "q7": {"items": [{"source": "columns@q7_1", "text": {"en-GB": "A smartphone"}}, {"source": "columns@q7_2", "text": {"en-GB": "A tablet"}}, {"source": "columns@q7_3", "text": {"en-GB": "A laptop/ PC"}}, {"source": "columns@q7_4", "text": {"en-GB": "A gaming console (e.g. Xbox, PlayStation)"}}, {"source": "columns@q7_5", "text": {"en-GB": "A digital camera"}}, {"source": "columns@q7_6", "text": {"en-GB": "A landline telephone"}}], "name": "q7", "subtype": "single", "text": {"en-GB": "How often do you use any of the following for any reason?"}, "type": "array", "values": "lib@values@q7"}}, "sets": {"data file": {"items": ["columns@record_number", "columns@unique_id", "columns@age", "columns@birth_day", "columns@birth_month", "columns@birth_year", "columns@gender", "columns@locality", "columns@ethnicity", "columns@religion", "columns@q1", "columns@q2", "columns@q2b", "columns@q3", "columns@q4", "masks@q5", "masks@q6", "masks@q7", "columns@q8", "columns@q8a", "columns@q9", "columns@q9a", "columns@Wave", "columns@weight_a", "columns@weight_b", "columns@start_time", "columns@end_time", "columns@duration", "masks@q14_1", "masks@q14_2", "masks@q14_3", "columns@RecordNo"], "text": "As per the data file"}, "q14_1": {"items": ["columns@q14r01c01", "columns@q14r02c01", "columns@q14r03c01", "columns@q14r04c01", "columns@q14r05c01", "columns@q14r06c01", "columns@q14r07c01", "columns@q14r08c01", "columns@q14r09c01", "columns@q14r10c01"]}, "q14_2": {"items": ["columns@q14r01c02", "columns@q14r02c02", "columns@q14r03c02", "columns@q14r04c02", "columns@q14r05c02", "columns@q14r06c02", "columns@q14r07c02", "columns@q14r08c02", "columns@q14r09c02", "columns@q14r10c02"]}, "q14_3": {"items": ["columns@q14r01c03", "columns@q14r02c03", "columns@q14r03c03", "columns@q14r04c03", "columns@q14r05c03", "columns@q14r06c03", "columns@q14r07c03", "columns@q14r08c03", "columns@q14r09c03", "columns@q14r10c03"]}, "q5": {"items": ["columns@q5_1", "columns@q5_2", "columns@q5_3", "columns@q5_4", "columns@q5_5", "columns@q5_6"]}, "q6": {"items": ["columns@q6_1", "columns@q6_2", "columns@q6_3"]}, "q7": {"items": ["columns@q7_1", "columns@q7_2", "columns@q7_3", "columns@q7_4", "columns@q7_5", "columns@q7_6"]}}, "type": "pandas.DataFrame"} \ No newline at end of file diff --git a/tests/basic.xlsx b/tests/basic.xlsx index f6708c6c6..afd1d9578 100644 Binary files a/tests/basic.xlsx and b/tests/basic.xlsx differ diff --git a/tests/complex_0.xlsx b/tests/complex_0.xlsx index 929107185..9cfab97bc 100644 Binary files a/tests/complex_0.xlsx and b/tests/complex_0.xlsx differ diff --git a/tests/complex_1.xlsx b/tests/complex_1.xlsx index c6b8bdb54..c329901b0 100644 Binary files a/tests/complex_1.xlsx and b/tests/complex_1.xlsx differ diff --git a/tests/complex_2.xlsx b/tests/complex_2.xlsx index d19e672fc..cc717fbef 100644 Binary files a/tests/complex_2.xlsx and b/tests/complex_2.xlsx differ diff --git a/tests/complex_3.xlsx b/tests/complex_3.xlsx index 5bc4b6a5d..3274a903f 100644 Binary files a/tests/complex_3.xlsx and b/tests/complex_3.xlsx differ diff --git a/tests/engine_B_data.csv b/tests/engine_B_data.csv index 9113de1b3..f1874a472 100644 --- a/tests/engine_B_data.csv +++ b/tests/engine_B_data.csv @@ -1,21 +1,21 @@ -identity,cost_breakfast,cost_lunch,cost_dinner,name,endtime,duration,profile_gender,age,age_group,q1_1,q1_2,q1_3,q1_4,q1_5,q2_1,q2_2,q2_3,q3_1,q3_2,q3_3,q4,weight -6542497,3.25,4.23,6.99,Alfred Pope,02/07/2014 16:58,,1,51,6,1,2,1,2,1,1,1,2,1,2,,1;2;,0.5 -6542644,3.69,4.3,5.67,Devin Watts,02/07/2014 16:58,,2,52,6,1,1,1,3,2,2,1,2,2,,,2;,0.5 -6542856,3.67,4.67,6.2,Guadalupe Mathis,02/07/2014 16:59,,1,17,2,2,2,2,3,1,1,1,1,1,2,3,1;2;3;,0.5 -6543060,4.32,4.45,6.21,Candice Stokes,02/07/2014 16:59,,1,47,5,1,3,1,1,2,2,1,2,2,,,2;,0.5 -6543208,3.52,6.44,6.5,Jerry Freeman,02/07/2014 17:00,,1,46,5,1,3,2,2,1,1,2,2,1,,,1;,0.5 -6543287,3.65,4.08,4.81,Kay Hamilton,02/07/2014 17:01,,2,43,5,2,1,3,1,1,1,2,1,1,3,,1;3;,0.5 -6543371,4.74,5.36,7.07,Conrad Graves,02/07/2014 17:01,,2,57,6,1,2,2,2,1,2,1,2,2,,,2;,0.5 -6543622,4.7,7.66,9.91,Ebony Kelly,02/07/2014 17:01,,1,50,6,2,1,1,2,2,1,2,2,1,,,1;,0.5 -6543719,4.67,5.47,7.03,Andre Robinson,02/07/2014 17:02,,2,48,5,3,2,1,1,1,1,2,1,1,3,,1;3;,0.5 -6543729,3.45,4.17,7.01,Matt Wallace,02/07/2014 17:02,,2,7,1,3,1,2,1,2,1,1,1,1,2,3,1;2;3;,0.5 -6543841,3.97,5.71,8.32,Peter Richardson,02/07/2014 17:02,,1,22,3,1,2,1,2,3,2,1,2,2,,,2;,0.5 -6543983,4.11,6.87,7.26,Rudy Erickson,02/07/2014 17:02,,2,1,1,2,3,2,1,3,1,2,2,1,,,1;,0.5 -6544213,3.93,4.52,4.94,Pablo Romero,02/07/2014 17:03,,2,11,2,1,3,3,1,1,1,2,1,1,3,,1;3;,0.5 -6544442,3.46,4.88,6.48,Brandon Cummings,02/07/2014 17:03,,2,14,2,2,1,3,2,2,1,2,1,1,3,,1;3;,0.5 -6544515,4.34,4.62,7.46,Ivan Wilson,02/07/2014 17:03,,1,3,1,1,2,1,1,1,1,1,2,1,2,,1;2;,0.5 -6544549,4.14,4.77,4.81,Lisa Castro,02/07/2014 17:04,,1,34,4,2,1,2,2,2,2,1,2,2,,,2;,0.5 -6544798,4.71,4.8,4.93,Bertha Collier,02/07/2014 17:05,,2,1,1,1,2,1,3,1,1,2,2,1,,,1;,0.5 -6544827,3.8,4.36,5.69,Angie Hoffman,02/07/2014 17:05,,2,34,4,2,1,2,3,2,1,2,1,1,3,,1;3;,0.5 -6544946,3.68,4.81,6.48,Bethany Jones,02/07/2014 17:07,,1,38,4,3,2,1,1,1,1,2,2,1,,,1;,0.5 -6545105,3.71,4.31,4.77,Wilbur Rios,02/07/2014 17:07,,2,27,3,3,1,2,2,2,1,2,1,1,3,,1;3;,0.5 +,cost_breakfast,cost_lunch,cost_dinner,full_name,endtime,duration,profile_gender,age,age_group,q1_1,q1_2,q1_3,q1_4,q1_5,q2_1,q2_2,q2_3,q3_1,q3_2,q3_3,q4,weight,@1,identity +0,3.25,4.23,6.99,Alfred Pope,2014-02-07 16:58:00,,1,51,6,1,2,1,2,1,1,1,2,1,2.0,,1;2;,0.5,1.0,0 +1,3.69,4.3,5.67,Devin Watts,2014-02-07 16:58:00,,2,52,6,1,1,1,3,2,2,1,2,2,,,2;,0.5,1.0,1 +2,3.67,4.67,6.2,Guadalupe Mathis,2014-02-07 16:59:00,,1,17,2,2,2,2,3,1,1,1,1,1,2.0,3.0,1;2;3;,0.5,1.0,2 +3,4.32,4.45,6.21,Candice Stokes,2014-02-07 16:59:00,,1,47,5,1,3,1,1,2,2,1,2,2,,,2;,0.5,1.0,3 +4,3.52,6.44,6.5,Jerry Freeman,2014-02-07 17:00:00,,1,46,5,1,3,2,2,1,1,2,2,1,,,1;,0.5,1.0,4 +5,3.65,4.08,4.81,Kay Hamilton,2014-02-07 17:01:00,,2,43,5,2,1,3,1,1,1,2,1,1,3.0,,1;3;,0.5,1.0,5 +6,4.74,5.36,7.07,Conrad Graves,2014-02-07 17:01:00,,2,57,6,1,2,2,2,1,2,1,2,2,,,2;,0.5,1.0,6 +7,4.7,7.66,9.91,Ebony Kelly,2014-02-07 17:01:00,,1,50,6,2,1,1,2,2,1,2,2,1,,,1;,0.5,1.0,7 +8,4.67,5.47,7.03,Andre Robinson,2014-02-07 17:02:00,,2,48,5,3,2,1,1,1,1,2,1,1,3.0,,1;3;,0.5,1.0,8 +9,3.45,4.17,7.01,Matt Wallace,2014-02-07 17:02:00,,2,7,1,3,1,2,1,2,1,1,1,1,2.0,3.0,1;2;3;,0.5,1.0,9 +10,3.97,5.71,8.32,Peter Richardson,2014-02-07 17:02:00,,1,22,3,1,2,1,2,3,2,1,2,2,,,2;,0.5,1.0,10 +11,4.11,6.87,7.26,Rudy Erickson,2014-02-07 17:02:00,,2,1,1,2,3,2,1,3,1,2,2,1,,,1;,0.5,1.0,11 +12,3.93,4.52,4.94,Pablo Romero,2014-02-07 17:03:00,,2,11,2,1,3,3,1,1,1,2,1,1,3.0,,1;3;,0.5,1.0,12 +13,3.46,4.88,6.48,Brandon Cummings,2014-02-07 17:03:00,,2,14,2,2,1,3,2,2,1,2,1,1,3.0,,1;3;,0.5,1.0,13 +14,4.34,4.62,7.46,Ivan Wilson,2014-02-07 17:03:00,,1,3,1,1,2,1,1,1,1,1,2,1,2.0,,1;2;,0.5,1.0,14 +15,4.14,4.77,4.81,Lisa Castro,2014-02-07 17:04:00,,1,34,4,2,1,2,2,2,2,1,2,2,,,2;,0.5,1.0,15 +16,4.71,4.8,4.93,Bertha Collier,2014-02-07 17:05:00,,2,1,1,1,2,1,3,1,1,2,2,1,,,1;,0.5,1.0,16 +17,3.8,4.36,5.69,Angie Hoffman,2014-02-07 17:05:00,,2,34,4,2,1,2,3,2,1,2,1,1,3.0,,1;3;,0.5,1.0,17 +18,3.68,4.81,6.48,Bethany Jones,2014-02-07 17:07:00,,1,38,4,3,2,1,1,1,1,2,2,1,,,1;,0.5,1.0,18 +19,3.71,4.31,4.77,Wilbur Rios,2014-02-07 17:07:00,,2,27,3,3,1,2,2,2,1,2,1,1,3.0,,1;3;,0.5,1.0,19 diff --git a/tests/engine_B_meta.json b/tests/engine_B_meta.json index 8b6fa9492..fe13d6d8d 100644 --- a/tests/engine_B_meta.json +++ b/tests/engine_B_meta.json @@ -1,562 +1 @@ -{ - "info": { - "notes": "Client version at 2014/09/25", - "from_source": { - "pandas_reader": "from_csv", - "kwargs": { - "infer_datetime_format": false, - "index_col": 0, - "tupleize_cols": false, - "sep": ",", - "parse_dates": true, - "header": 0, - "path": "./data/example_data_with_meta.csv" - } - }, - "name": "ASDA tracker W4" - }, - "lib": { - "text": { - "dk": [ - "Don't know", - "weiss nicht" - ] - }, - "text map": { - "auto": "enu", - "map": [ - "enu", - "deu" - ] - }, - "values": { - "core": { - "98 Not asked 99 Skipped": [ - { - "text": [ - "Not asked", - "Nicht gefragt" - ], - "value": 98, - "missing": true - }, - { - "text": [ - "Skipped", - "Übersprungen" - ], - "value": 99, - "missing": true - } - ], - "97 dk": [ - { - "text": [ - "lib@text@dk" - ], - "value": 97 - } - ], - "96 none": [ - { - "text": [ - "None", - "Keine" - ], - "value": 96 - } - ], - "Not shown": [ - { - "text": [ - "Not shown", - "Nicht gesehen" - ], - "value": 0, - "missing": true - } - ], - "96 none missing": [ - { - "text": [ - "None", - "Keine" - ], - "value": 96, - "missing": true - } - ], - "95 other": [ - { - "text": [ - "Other", - "Sonstige" - ], - "value": 95 - } - ], - "97 dk missing": [ - { - "text": [ - "lib@text@dk" - ], - "value": 97, - "missing": true - } - ] - }, - "custom": { - "12345 disagree-agree": [ - { - "text": [ - "Disagree", - "Stimme nicht zu" - ], - "value": 1 - }, - { - "text": [ - "Somewhat disagree", - "Stimme eher nicht zu" - ], - "value": 2 - }, - { - "text": [ - "Neither", - "Teils/teils" - ], - "value": 3 - }, - { - "text": [ - "Somewhat agree", - "Stimme eher zu" - ], - "value": 4 - }, - { - "text": [ - "Agree", - "Stimme zu" - ], - "value": 5 - } - ], - "meals": [ - { - "text": [ - "Breakfast", - "Frühstück" - ], - "value": 1 - }, - { - "text": [ - "Lunch", - "Mittagessen" - ], - "value": 2 - }, - { - "text": [ - "Dinner", - "Abendessen" - ], - "value": 3 - } - ], - "dichotomous": [ - { - "text": [ - "Selected", - "Ja" - ], - "value": 1 - }, - { - "text": [ - "Not selected", - "Nein" - ], - "value": 2 - } - ] - } - } - }, - "masks": { - "q1": { - "text": [ - "How much to you agree or disagree with the following statements?", - "Inwieweit stimmen Sie den folgenden Aussagen zu?" - ], - "type": "array", - "items": [ - { - "source": "columns@q1_1" - }, - { - "source": "columns@q1_2" - }, - { - "source": "columns@q1_3" - }, - { - "source": "columns@q1_4" - }, - { - "source": "columns@q1_5" - } - ] - }, - "q2": { - "text": [ - "Which meals do you normally eat?", - "Welche Mahlzeiten nehmen Sie normalerweise zu sich?" - ], - "type": "dichotomous set", - "items": [ - { - "source": "columns@q2_1" - }, - { - "source": "columns@q2_2" - }, - { - "source": "columns@q2_3" - } - ] - }, - "q3": { - "text": [ - "Which meals do you normally eat?", - "Welche Mahlzeiten nehmen Sie normalerweise zu sich?" - ], - "type": "categorical set", - "items": [ - { - "source": "columns@q3_1" - }, - { - "source": "columns@q3_2" - }, - { - "source": "columns@q3_3" - } - ] - }, - "cost": { - "text": [ - "How much did you pay for these meals?", - "Wie viel haben Sie für diese Mahlzeiten bezahlt?" - ], - "type": "array", - "items": [ - { - "source": "columns@cost_breakfast", - "text": [ - "Breakfast", - "Frühstück" - ] - }, - { - "source": "columns@cost_lunch", - "text": [ - "Lunch", - "Mittagessen" - ] - }, - { - "source": "columns@cost_dinner", - "text": [ - "Dinner", - "Abendessen" - ] - } - ] - } - }, - "sets": { - "demographics": { - "text": "PDLs", - "items": [ - "columns@name", - "columns@profile_gender" - ] - }, - "internal": { - "text": "Variables for internal use", - "items": [ - "sets@system", - "columns@profile_gender", - "sets@survey variables" - ] - }, - "client export": { - "text": "Variables for external use", - "items": [ - "columns@profile_gender", - "sets@survey variables" - ] - }, - "system": { - "text": "System variables", - "items": [ - "columns@identity", - "columns@endtime" - ] - }, - "survey variables": { - "text": "Variables from questionnaire", - "items": [ - "masks@cost", - "masks@q1", - "masks@q2", - "masks@q3", - "columns@q4" - ] - } - }, - "type": "pandas.DataFrame", - "columns": { - "cost_dinner": { - "text": [ - "How much did you pay for your dinner?", - "Wie viel haben Sie für ihr Abendessen bezahlt?" - ], - "type": "float" - }, - "cost_lunch": { - "text": [ - "How much did you pay for your lunch?", - "Wie viel haben Sie für ihr Mittagessen bezahlt?" - ], - "type": "float" - }, - "duration": { - "text": [ - "Survey duration", - "Umfragedauer" - ], - "type": "time" - }, - "cost_breakfast": { - "text": [ - "How much did you pay for your breakfast?", - "Wie viel haben Sie für ihr Frühstück bezahlt?" - ], - "type": "float" - }, - "age_group": { - "values": [ - { - "text": "1-9", - "value": 1 - }, - { - "text": "11-19", - "value": 2 - }, - { - "text": "21-29", - "value": 3 - }, - { - "text": "31-39", - "value": 4 - }, - { - "text": "41-49", - "value": 5 - }, - { - "text": "51-59", - "value": 6 - } - ], - "text": [ - "Age group", - "Altersgruppe" - ], - "type": "single" - }, - "endtime": { - "text": [ - "Date of survey.", - "Umfragedatum" - ], - "type": "date" - }, - "q4": { - "values": [ - "lib@values@custom@meals" - ], - "text": [ - "Which meals do you normally eat?", - "Welche Mahlzeiten nehmen Sie normalerweise zu sich?" - ], - "type": "delimited set", - "sep": ";" - }, - "identity": { - "text": [ - "id", - "Identifikationsnummer" - ], - "type": "int" - }, - "q2_1": { - "values": [ - "lib@values@custom@dichotomous" - ], - "text": [ - "Breakfast", - "Frühstück" - ], - "type": "single" - }, - "q2_2": { - "values": [ - "lib@values@custom@dichotomous" - ], - "text": [ - "Lunch", - "Mittagessen" - ], - "type": "single" - }, - "q2_3": { - "values": [ - "lib@values@custom@dichotomous" - ], - "text": [ - "Dinner", - "Abendessen" - ], - "type": "single" - }, - "q3_1": { - "values": [ - "lib@values@custom@meals" - ], - "text": [ - "Meals eaten (1/3)", - "Verzehrte Mahlzeiten (1/3)" - ], - "type": "single" - }, - "q3_3": { - "values": [ - "lib@values@custom@meals" - ], - "text": [ - "Meals eaten (3/3)", - "Verzehrte Mahlzeiten (3/3)" - ], - "type": "single" - }, - "q3_2": { - "values": [ - "lib@values@custom@meals" - ], - "text": [ - "Meals eaten (2/3)", - "Verzehrte Mahlzeiten (2/3)" - ], - "type": "single" - }, - "q1_5": { - "values": [ - "lib@values@custom@12345 disagree-agree", - "lib@values@core@97 dk" - ], - "text": [ - "I like Dr Pepper.", - "Ich mag Dr Pepper" - ], - "type": "single" - }, - "q1_4": { - "values": [ - "lib@values@custom@12345 disagree-agree", - "lib@values@core@97 dk" - ], - "text": [ - "I like 7-Up.", - "Ich mag 7-Up." - ], - "type": "single" - }, - "q1_3": { - "values": [ - "lib@values@custom@12345 disagree-agree", - "lib@values@core@97 dk" - ], - "text": [ - "I like Sprite.", - "Ich mag Sprite." - ], - "type": "single" - }, - "q1_2": { - "values": [ - "lib@values@custom@12345 disagree-agree", - "lib@values@core@97 dk" - ], - "text": [ - "I like Fanta.", - "Ich mag Fanta." - ], - "type": "single" - }, - "q1_1": { - "values": [ - "lib@values@custom@12345 disagree-agree", - "lib@values@core@97 dk" - ], - "text": [ - "I like Coca-Cola.", - "Ich mag Coca-Cola." - ], - "type": "single" - }, - "name": { - "text": [ - "What is your name?", - "Wie heißen Sie?" - ], - "type": "string" - }, - "age": { - "text": [ - "Age", - "Alter" - ], - "type": "int" - }, - "profile_gender": { - "values": [ - { - "text": [ - "Male", - "Männlich" - ], - "value": 1 - }, - { - "text": [ - "Female", - "Weiblich" - ], - "value": 2 - } - ], - "text": [ - "Gender", - "Geschlecht" - ], - "type": "single" - } - } -} \ No newline at end of file +{"columns": {"@1": {"type": "int"}, "age": {"text": ["Age", "Alter"], "type": "int"}, "age_group": {"text": ["Age group", "Altersgruppe"], "type": "single", "values": [{"text": "1-9", "value": 1}, {"text": "11-19", "value": 2}, {"text": "21-29", "value": 3}, {"text": "31-39", "value": 4}, {"text": "41-49", "value": 5}, {"text": "51-59", "value": 6}]}, "cost_breakfast": {"text": ["How much did you pay for your breakfast?", "Wie viel haben Sie f\u00fcr ihr Fr\u00fchst\u00fcck bezahlt?"], "type": "float"}, "cost_dinner": {"text": ["How much did you pay for your dinner?", "Wie viel haben Sie f\u00fcr ihr Abendessen bezahlt?"], "type": "float"}, "cost_lunch": {"text": ["How much did you pay for your lunch?", "Wie viel haben Sie f\u00fcr ihr Mittagessen bezahlt?"], "type": "float"}, "duration": {"text": ["Survey duration", "Umfragedauer"], "type": "time"}, "endtime": {"text": ["Date of survey.", "Umfragedatum"], "type": "date"}, "full_name": {"name": "full_name", "text": ["What is your name?", "Wie hei\u00dfen Sie?"], "type": "string"}, "identity": {"name": "identity", "parent": {}, "properties": {"created": true}, "text": {"en-GB": "ID"}, "type": "int"}, "profile_gender": {"text": ["Gender", "Geschlecht"], "type": "single", "values": [{"text": ["Male", "M\u00e4nnlich"], "value": 1}, {"text": ["Female", "Weiblich"], "value": 2}]}, "q1_1": {"text": ["I like Coca-Cola.", "Ich mag Coca-Cola."], "type": "single", "values": ["lib@values@custom@12345 disagree-agree", "lib@values@core@97 dk"]}, "q1_2": {"text": ["I like Fanta.", "Ich mag Fanta."], "type": "single", "values": ["lib@values@custom@12345 disagree-agree", "lib@values@core@97 dk"]}, "q1_3": {"text": ["I like Sprite.", "Ich mag Sprite."], "type": "single", "values": ["lib@values@custom@12345 disagree-agree", "lib@values@core@97 dk"]}, "q1_4": {"text": ["I like 7-Up.", "Ich mag 7-Up."], "type": "single", "values": ["lib@values@custom@12345 disagree-agree", "lib@values@core@97 dk"]}, "q1_5": {"text": ["I like Dr Pepper.", "Ich mag Dr Pepper"], "type": "single", "values": ["lib@values@custom@12345 disagree-agree", "lib@values@core@97 dk"]}, "q2_1": {"text": ["Breakfast", "Fr\u00fchst\u00fcck"], "type": "single", "values": ["lib@values@custom@dichotomous"]}, "q2_2": {"text": ["Lunch", "Mittagessen"], "type": "single", "values": ["lib@values@custom@dichotomous"]}, "q2_3": {"text": ["Dinner", "Abendessen"], "type": "single", "values": ["lib@values@custom@dichotomous"]}, "q3_1": {"text": ["Meals eaten (1/3)", "Verzehrte Mahlzeiten (1/3)"], "type": "single", "values": ["lib@values@custom@meals"]}, "q3_2": {"text": ["Meals eaten (2/3)", "Verzehrte Mahlzeiten (2/3)"], "type": "single", "values": ["lib@values@custom@meals"]}, "q3_3": {"text": ["Meals eaten (3/3)", "Verzehrte Mahlzeiten (3/3)"], "type": "single", "values": ["lib@values@custom@meals"]}, "q4": {"sep": ";", "text": ["Which meals do you normally eat?", "Welche Mahlzeiten nehmen Sie normalerweise zu sich?"], "type": "delimited set", "values": ["lib@values@custom@meals"]}, "weight": {"name": "weight", "text": {"en-GB": "Weight"}, "type": "float"}}, "info": {"dimensions_comp": false, "dimensions_suffix": "_grid", "from_source": {"kwargs": {"header": 0, "index_col": 0, "infer_datetime_format": false, "parse_dates": true, "path": "./data/example_data_with_meta.csv", "sep": ",", "tupleize_cols": false}, "pandas_reader": "from_csv"}, "name": "ASDA tracker W4", "notes": "Client version at 2014/09/25"}, "lib": {"default text": "en-GB", "text": {"dk": ["Don't know", "weiss nicht"]}, "text map": {"auto": "enu", "map": ["enu", "deu"]}, "values": {"core": {"95 other": [{"text": ["Other", "Sonstige"], "value": 95}], "96 none": [{"text": ["None", "Keine"], "value": 96}], "96 none missing": [{"missing": true, "text": ["None", "Keine"], "value": 96}], "97 dk": [{"text": ["lib@text@dk"], "value": 97}], "97 dk missing": [{"missing": true, "text": ["lib@text@dk"], "value": 97}], "98 Not asked 99 Skipped": [{"missing": true, "text": ["Not asked", "Nicht gefragt"], "value": 98}, {"missing": true, "text": ["Skipped", "\u00dcbersprungen"], "value": 99}], "Not shown": [{"missing": true, "text": ["Not shown", "Nicht gesehen"], "value": 0}]}, "custom": {"12345 disagree-agree": [{"text": ["Disagree", "Stimme nicht zu"], "value": 1}, {"text": ["Somewhat disagree", "Stimme eher nicht zu"], "value": 2}, {"text": ["Neither", "Teils/teils"], "value": 3}, {"text": ["Somewhat agree", "Stimme eher zu"], "value": 4}, {"text": ["Agree", "Stimme zu"], "value": 5}], "dichotomous": [{"text": ["Selected", "Ja"], "value": 1}, {"text": ["Not selected", "Nein"], "value": 2}], "meals": [{"text": ["Breakfast", "Fr\u00fchst\u00fcck"], "value": 1}, {"text": ["Lunch", "Mittagessen"], "value": 2}, {"text": ["Dinner", "Abendessen"], "value": 3}]}}}, "masks": {"cost": {"items": [{"source": "columns@cost_breakfast", "text": ["Breakfast", "Fr\u00fchst\u00fcck"]}, {"source": "columns@cost_lunch", "text": ["Lunch", "Mittagessen"]}, {"source": "columns@cost_dinner", "text": ["Dinner", "Abendessen"]}], "text": ["How much did you pay for these meals?", "Wie viel haben Sie f\u00fcr diese Mahlzeiten bezahlt?"], "type": "array"}, "q1": {"items": [{"source": "columns@q1_1"}, {"source": "columns@q1_2"}, {"source": "columns@q1_3"}, {"source": "columns@q1_4"}, {"source": "columns@q1_5"}], "text": ["How much to you agree or disagree with the following statements?", "Inwieweit stimmen Sie den folgenden Aussagen zu?"], "type": "array"}, "q2": {"items": [{"source": "columns@q2_1"}, {"source": "columns@q2_2"}, {"source": "columns@q2_3"}], "text": ["Which meals do you normally eat?", "Welche Mahlzeiten nehmen Sie normalerweise zu sich?"], "type": "dichotomous set"}, "q3": {"items": [{"source": "columns@q3_1"}, {"source": "columns@q3_2"}, {"source": "columns@q3_3"}], "text": ["Which meals do you normally eat?", "Welche Mahlzeiten nehmen Sie normalerweise zu sich?"], "type": "categorical set"}}, "sets": {"client export": {"items": ["columns@profile_gender", "sets@survey variables"], "text": "Variables for external use"}, "data file": {"items": ["columns@identity", "columns@cost_breakfast", "columns@cost_lunch", "columns@cost_dinner", "columns@full_name", "columns@endtime", "columns@duration", "columns@profile_gender", "columns@age", "columns@age_group", "columns@q1_1", "columns@q1_2", "columns@q1_3", "columns@q1_4", "columns@q1_5", "columns@q2_1", "columns@q2_2", "columns@q2_3", "columns@q3_1", "columns@q3_2", "columns@q3_3", "columns@q4", "columns@weight"]}, "demographics": {"items": ["columns@full_name", "columns@profile_gender"], "text": "PDLs"}, "internal": {"items": ["sets@system", "columns@profile_gender", "sets@survey variables"], "text": "Variables for internal use"}, "survey variables": {"items": ["masks@cost", "masks@q1", "masks@q2", "masks@q3", "columns@q4"], "text": "Variables from questionnaire"}, "system": {"items": ["columns@identity", "columns@endtime"], "text": "System variables"}}, "type": "pandas.DataFrame"} \ No newline at end of file diff --git a/tests/parameters_chain.py b/tests/parameters_chain.py index 215eaaae9..dc900540f 100644 --- a/tests/parameters_chain.py +++ b/tests/parameters_chain.py @@ -301,7 +301,8 @@ def pad(level, size, pad_id): 'siglevel': None, 'stat': None, 'weight': None, - 'is_calc_only': False}, + 'is_calc_only': False, + 'is_viewlike': False}, 1: { 'is_block': False, 'is_c_base': False, @@ -334,7 +335,8 @@ def pad(level, size, pad_id): 'siglevel': None, 'stat': None, 'weight': None, - 'is_calc_only': False}, + 'is_calc_only': False, + 'is_viewlike': False}, 2: { 'is_block': False, 'is_c_base': False, @@ -367,7 +369,8 @@ def pad(level, size, pad_id): 'siglevel': None, 'stat': None, 'weight': None, - 'is_calc_only': False}, + 'is_calc_only': False, + 'is_viewlike': False}, 3: { 'is_block': False, 'is_c_base': False, @@ -400,7 +403,8 @@ def pad(level, size, pad_id): 'siglevel': None, 'stat': None, 'weight': None, - 'is_calc_only': False}, + 'is_calc_only': False, + 'is_viewlike': False}, 4: { 'is_block': False, 'is_c_base': False, @@ -433,7 +437,8 @@ def pad(level, size, pad_id): 'siglevel': None, 'stat': None, 'weight': None, - 'is_calc_only': False}, + 'is_calc_only': False, + 'is_viewlike': False}, 5: { 'is_block': False, 'is_c_base': False, @@ -466,7 +471,8 @@ def pad(level, size, pad_id): 'siglevel': None, 'stat': None, 'weight': None, - 'is_calc_only': False}, + 'is_calc_only': False, + 'is_viewlike': False}, 6: { 'is_block': False, 'is_c_base': False, @@ -499,7 +505,8 @@ def pad(level, size, pad_id): 'siglevel': None, 'stat': None, 'weight': None, - 'is_calc_only': False}, + 'is_calc_only': False, + 'is_viewlike': False}, 7: { 'is_block': False, 'is_c_base': False, @@ -532,7 +539,8 @@ def pad(level, size, pad_id): 'siglevel': None, 'stat': None, 'weight': None, - 'is_calc_only': False}, + 'is_calc_only': False, + 'is_viewlike': False}, 8: { 'is_block': False, 'is_c_base': False, @@ -565,7 +573,8 @@ def pad(level, size, pad_id): 'siglevel': None, 'stat': 'mean', 'weight': None, - 'is_calc_only': False}, + 'is_calc_only': False, + 'is_viewlike': False}, 9: { 'is_block': False, 'is_c_base': False, @@ -598,7 +607,8 @@ def pad(level, size, pad_id): 'siglevel': None, 'stat': 'median', 'weight': None, - 'is_calc_only': False} + 'is_calc_only': False, + 'is_viewlike': False} } CHAIN_STRUCT_COLUMNS = ['record_number', 'age', 'gender', 'q9', 'q9a'] diff --git a/tests/parameters_excel.py b/tests/parameters_excel.py index 0b915fbd8..80b6daec5 100644 --- a/tests/parameters_excel.py +++ b/tests/parameters_excel.py @@ -5,7 +5,7 @@ XKEYS_BASIC = ('q2', 'q2b', 'q3', 'q4', ('q5_1', 'q5_2', 'q5_3', 'q5_4', 'q5_5', 'q5_6'), 'q8', 'q9') -YKEYS_BASIC = ('@', 'gender', 'locality') +YKEYS_BASIC = ('@', 'gender', 'gender', 'locality') VIEWS_BASIC = ('cbase', 'counts') OPENS_BASIC = ('q8a', 'q9a') CELLS_BASIC = 'counts' @@ -186,7 +186,8 @@ FORMATS_0 = dict(view_border_freq = None, view_border_net = None, view_border_block_net = None, - view_border_block_expanded = None) + view_border_block_expanded = None, + text_h_align_data = 1) SHEET_PROPERTIES_1 = dict(alternate_bg=True, freq_0_rep=':', @@ -286,7 +287,9 @@ SHEET_PROPERTIES_3 = dict(dummy_tests=True, alternate_bg=False, start_row=7, - start_column=2) + start_column=2, + start_row_annotations=4, + start_column_annotations=5) VIEW_GROUPS_3 = dict(block_normal_counts='block_normal', block_normal_c_pct='block_normal', diff --git a/tests/test_batch.py b/tests/test_batch.py index 97594ff87..3aafec021 100644 --- a/tests/test_batch.py +++ b/tests/test_batch.py @@ -1,329 +1,356 @@ -import unittest -import os.path -import numpy as np -import pandas as pd -import quantipy as qp - -from quantipy.core.tools.view.logic import ( - has_any, has_all, has_count, - not_any, not_all, not_count, - is_lt, is_ne, is_gt, - is_le, is_eq, is_ge, - union, intersection) - -from quantipy.core.tools.dp.prep import frange -from collections import OrderedDict - -def _get_dataset(): - path = os.path.dirname(os.path.abspath(__file__)) + '/' - name = 'Example Data (A)' - casedata = '{}.csv'.format(name) - metadata = '{}.json'.format(name) - dataset = qp.DataSet(name, False) - dataset.set_verbose_infomsg(False) - dataset.set_verbose_errmsg(False) - dataset.read_quantipy(path+metadata, path+casedata) - return dataset - -def _get_batch(name, dataset=None, full=False): - if not dataset: dataset = _get_dataset() - batch = qp.Batch(dataset, name) - if full: - batch.add_x(['q1', 'q2', 'q6', 'age']) - batch.add_y(['gender', 'q2']) - batch.add_open_ends(['q8a', 'q9a'], 'RecordNo') - batch.add_filter('men only', {'gender': 1}) - batch.set_weights('weight_a') - return batch, dataset - -def _get_meta(batch): - name = batch.name - return batch._meta['sets']['batches'][name] - -class TestBatch(unittest.TestCase): - - def test_dataset_add_batch(self): - dataset = _get_dataset() - batch1 = dataset.add_batch('batch1') - batch2 = dataset.add_batch('batch2', 'c', 'weight', .05) - self.assertTrue(isinstance(batch1, qp.Batch)) - self.assertEqual(len(_get_meta(batch1).keys()), 30) - b_meta = _get_meta(batch2) - self.assertEqual(b_meta['name'], 'batch2') - self.assertEqual(b_meta['cell_items'], ['c']) - self.assertEqual(b_meta['weights'], ['weight']) - self.assertEqual(b_meta['sigproperties']['siglevels'], [0.05]) - - def test_dataset_get_batch(self): - batch, ds = _get_batch('test', full=True) - self.assertRaises(KeyError, ds.get_batch, 'name') - b = ds.get_batch('test') - attr = ['xks', 'yks', 'filter', 'filter_names', - 'x_y_map', 'x_filter_map', 'y_on_y', - 'forced_names', 'summaries', 'transposed_arrays', 'verbatims', - 'verbatim_names', 'extended_yks_global', 'extended_yks_per_x', - 'exclusive_yks_per_x', 'extended_filters_per_x', 'meta_edits', - 'cell_items', 'weights', 'sigproperties', 'additional', - 'sample_size', 'language', 'name', 'total'] - for a in attr: - self.assertEqual(batch.__dict__[a], b.__dict__[a]) - - def test_from_batch(self): - ds = _get_dataset() - ds.force_texts('de-DE', 'en-GB') - batch1, ds = _get_batch('test1', ds, full=True) - batch1.set_language('de-DE') - batch1.hiding('q1', frange('8,9,96-99')) - batch1.slicing('q1', frange('9-4')) - batch2, ds = _get_batch('test2', ds) - batch2.add_x('q1') - batch2.add_y('Wave') - batch2.as_addition('test1') - n_ds = ds.from_batch('test1', 'RecordNo', 'de-DE', True, 'variables') - self.assertEqual(n_ds.codes('q1'), [7, 6, 5, 4]) - self.assertEqual(n_ds.variables(), [u'age', u'gender', u'q1', u'q2', - u'q6', u'q8a', u'q9a', u'Wave', - u'weight_a', u'RecordNo']) - self.assertEqual(n_ds['gender'].value_counts().values.tolist(), [3952]) - self.assertEqual(n_ds.value_texts('gender', 'en-GB'), [None, None]) - self.assertEqual(n_ds.value_texts('gender', 'de-DE'), [u'Male', u'Female']) - self.assertRaises(ValueError, ds.from_batch, 'test1', 'RecordNo', 'fr-FR') - - ########################## methods used in _get_batch #################### - - def test_add_x(self): - batch, ds = _get_batch('test') - batch.add_x(['q1', 'q2', 'q2b', {'q3': 'q3_label'}, 'q4', {'q5': 'q5_label'}, 'q14_1']) - b_meta = _get_meta(batch) - self.assertEqual(b_meta['xks'], ['q1', 'q2', 'q2b', 'q3', 'q4', 'q5', - u'q5_1', u'q5_2', u'q5_3', u'q5_4', u'q5_5', - u'q5_6', 'q14_1', u'q14r01c01', u'q14r02c01', - u'q14r03c01', u'q14r04c01', u'q14r05c01', u'q14r06c01', - u'q14r07c01', u'q14r08c01', u'q14r09c01', u'q14r10c01']) - self.assertEqual(b_meta['forced_names'], {'q3': 'q3_label', 'q5': 'q5_label'}) - self.assertEqual(b_meta['summaries'], ['q5', 'q14_1']) - x_y_map = [('q1', ['@']), ('q2', ['@']), ('q2b', ['@']), - ('q3', ['@']), ('q4', ['@']), ('q5', ['@']), - (u'q5_1', ['@']), (u'q5_2', ['@']), - (u'q5_3', ['@']), (u'q5_4', ['@']), - (u'q5_5', ['@']), (u'q5_6', ['@']), - ('q14_1', ['@']), (u'q14r01c01', ['@']), - (u'q14r02c01', ['@']), (u'q14r03c01', ['@']), - (u'q14r04c01', ['@']), (u'q14r05c01', ['@']), - (u'q14r06c01', ['@']), (u'q14r07c01', ['@']), - (u'q14r08c01', ['@']), (u'q14r09c01', ['@']), - (u'q14r10c01', ['@'])] - self.assertEqual(b_meta['x_y_map'], x_y_map) - - def test_add_y(self): - batch, ds = _get_batch('test') - batch.add_y(['gender', 'q2b']) - b_meta = _get_meta(batch) - self.assertEqual(b_meta['yks'], ['@', 'gender', 'q2b']) - self.assertRaises(KeyError, batch.add_y, ['@', 'GENDER']) - batch.add_x('q1') - x_y_map = [('q1', ['@', 'gender', 'q2b'])] - self.assertEqual(b_meta['x_y_map'], x_y_map) - - def test_add_open_ends(self): - batch, ds = _get_batch('test') - self.assertRaises(ValueError, batch.add_open_ends, ['q8a', 'q9a'], None, - True, False, True, 'open ends', None) - batch.add_filter('men only', {'gender': 1}) - batch.add_open_ends(['q8a', 'q9a'], 'RecordNo', filter_by={'age': is_ge(49)}) - b_meta = _get_meta(batch) - self.assertEqual(b_meta['verbatims']['open ends'].shape, (40, 3)) - self.assertEqual(b_meta['verbatim_names'], ['q8a', 'q9a']) - batch.add_open_ends(['q8a', 'q9a'], 'RecordNo', split=True, - title=['open ends', 'open ends2']) - self.assertEqual(b_meta['verbatims'].keys(), ['open ends', 'open ends2']) - - def test_add_filter(self): - batch, ds = _get_batch('test', full=True) - batch.add_x(['q1', 'q2b']) - batch.add_y('gender') - batch.add_filter('men only', {'gender': 1}) - b_meta = _get_meta(batch) - self.assertEqual(b_meta['filter'], {'men only': {'gender': 1}}) - x_filter_map = OrderedDict([('q1', {'men only': {'gender': 1}}), - ('q2b', {'men only': {'gender': 1}})]) - self.assertEqual(b_meta['x_filter_map'], x_filter_map) - self.assertEqual(b_meta['filter_names'], ['men only']) - - def test_set_weight(self): - batch, ds = _get_batch('test') - self.assertRaises(ValueError, batch.set_weights, 'Weight') - batch.set_weights('weight_a') - self.assertEqual(_get_meta(batch)['weights'], ['weight_a']) - self.assertEqual(batch.weights, ['weight_a']) - - ########################################################################## - - def test_copy(self): - batch1, ds = _get_batch('test', full=True) - batch2 = batch1.copy('test_copy') - attributes = ['xks', 'yks', 'filter', 'filter_names', 'x_y_map', - 'x_filter_map', 'y_on_y', 'forced_names', 'summaries', - 'transposed_arrays', 'extended_yks_global', 'extended_yks_per_x', - 'exclusive_yks_per_x', 'extended_filters_per_x', 'meta_edits', - 'cell_items', 'weights', 'sigproperties', 'additional', - 'sample_size', 'language'] - for a in attributes: - value = batch1.__dict__[a] - value2 = batch2.__dict__[a] - self.assertEqual(value, value2) - self.assertEqual(batch2.verbatims, OrderedDict()) - self.assertEqual(batch2.verbatim_names, []) - self.assertEqual(_get_meta(batch2)['name'], 'test_copy') - - def test_as_addition(self): - batch1, ds = _get_batch('test1', full=True) - batch2, ds = _get_batch('test2', ds, True) - batch2.as_addition('test1') - self.assertEqual(_get_meta(batch1)['additions'], ['test2']) - b_meta = _get_meta(batch2) - self.assertEqual(b_meta['additional'], True) - self.assertEqual(b_meta['verbatims'], {}) - self.assertEqual(b_meta['verbatim_names'], []) - self.assertEqual(b_meta['y_on_y'], []) - - def test_set_cell_items(self): - batch, ds = _get_batch('test', full=True) - self.assertRaises(ValueError, batch.set_cell_items, ['c', 'pc']) - batch.set_cell_items('c') - self.assertEqual(_get_meta(batch)['cell_items'], ['c']) - self.assertEqual(batch.cell_items, ['c']) - - def test_set_language(self): - batch, ds = _get_batch('test', full=True) - self.assertRaises(ValueError, batch.set_language, 'en-gb') - batch.set_language('sv-SE') - self.assertEqual(_get_meta(batch)['language'], 'sv-SE') - self.assertEqual(batch.language, 'sv-SE') - - def test_set_sigtest(self): - batch, ds = _get_batch('test', full=True) - self.assertRaises(TypeError, batch.set_sigtests, [0.05, '0.01']) - batch.set_sigtests(.05) - self.assertEqual(_get_meta(batch)['sigproperties']['siglevels'], [0.05]) - - def test_make_summaries_transpose_arrays(self): - batch, ds = _get_batch('test') - b_meta = _get_meta(batch) - batch.add_x(['q5', 'q6', 'q14_2', 'q14_3', 'q14_1']) - batch.make_summaries(None) - self.assertEqual(b_meta['summaries'], []) - batch.transpose_arrays(['q5', 'q6'], False) - batch.transpose_arrays(['q14_2', 'q14_3']) - self.assertEqual(b_meta['summaries'], ['q5', 'q6', 'q14_2', 'q14_3']) - t_a = {'q14_2': True, 'q14_3': True, 'q5': False, 'q6': False} - self.assertEqual(b_meta['transposed_arrays'], t_a) - batch.make_summaries('q5') - self.assertEqual(b_meta['transposed_arrays'], {'q5': False}) - self.assertRaises(ValueError, batch.make_summaries, 'q7') - - def test_extend_y(self): - batch1, ds = _get_batch('test1', full=True) - batch2, ds = _get_batch('test2', ds, True) - b_meta1 = _get_meta(batch1) - b_meta2 = _get_meta(batch2) - self.assertRaises(ValueError, batch1.extend_y, 'q2b', 'q5') - batch1.extend_y('q2b') - x_y_map = [('q1', ['@', 'gender', 'q2', 'q2b']), - ('q2', ['@', 'gender', 'q2', 'q2b']), - ('q6', ['@']), - (u'q6_1', ['@', 'gender', 'q2', 'q2b']), - (u'q6_2', ['@', 'gender', 'q2', 'q2b']), - (u'q6_3', ['@', 'gender', 'q2', 'q2b']), - ('age', ['@', 'gender', 'q2', 'q2b'])] - self.assertEqual(b_meta1['x_y_map'], x_y_map) - self.assertEqual(b_meta1['extended_yks_global'], ['q2b']) - batch2.extend_y('q2b', 'q2') - batch2.extend_y('q3', 'q6') - extended_yks_per_x = {u'q6_3': ['q3'], 'q2': ['q2b'], u'q6_1': ['q3'], - u'q6_2': ['q3'], 'q6': ['q3']} - self.assertEqual(b_meta2['extended_yks_per_x'], extended_yks_per_x) - x_y_map = [('q1', ['@', 'gender', 'q2']), - ('q2', ['@', 'gender', 'q2', 'q2b']), - ('q6', ['@']), - (u'q6_1', ['@', 'gender', 'q2', 'q3']), - (u'q6_2', ['@', 'gender', 'q2', 'q3']), - (u'q6_3', ['@', 'gender', 'q2', 'q3']), - ('age', ['@', 'gender', 'q2'])] - self.assertEqual(b_meta2['x_y_map'], x_y_map) - - def test_replace_y(self): - batch, ds = _get_batch('test', full=True) - b_meta = _get_meta(batch) - self.assertRaises(ValueError, batch.replace_y, 'q2b', 'q5') - batch.replace_y('q2b', 'q6') - exclusive_yks_per_x = {u'q6_3': ['@', 'q2b'], - u'q6_1': ['@', 'q2b'], - u'q6_2': ['@', 'q2b'], - 'q6': ['@', 'q2b']} - self.assertEqual(b_meta['exclusive_yks_per_x'], exclusive_yks_per_x) - x_y_map = [('q1', ['@', 'gender', 'q2']), - ('q2', ['@', 'gender', 'q2']), - ('q6', ['@']), - (u'q6_1', ['@', 'q2b']), - (u'q6_2', ['@', 'q2b']), - (u'q6_3', ['@', 'q2b']), - ('age', ['@', 'gender', 'q2'])] - self.assertEqual(b_meta['x_y_map'], x_y_map) - - def test_extend_filter(self): - batch, ds = _get_batch('test', full=True) - b_meta = _get_meta(batch) - ext_filters = {'q1': {'age': frange('20-25')}, ('q2', 'q6'): {'age': frange('30-35')}} - batch.extend_filter(ext_filters) - filter_names = ['men only', '(men only)+(q1)', '(men only)+(q2)', - '(men only)+(q6)', '(men only)+(q6_1)', - '(men only)+(q6_2)', '(men only)+(q6_3)'] - self.assertEqual(b_meta['filter_names'], filter_names) - x_filter_map = OrderedDict( - [('q1', {'(men only)+(q1)': intersection([{'gender': 1}, {'age': [20, 21, 22, 23, 24, 25]}])}), - ('q2', {'(men only)+(q2)': intersection([{'gender': 1}, {'age': [30, 31, 32, 33, 34, 35]}])}), - ('q6', {'(men only)+(q6)': intersection([{'gender': 1}, {'age': [30, 31, 32, 33, 34, 35]}])}), - (u'q6_1', {'(men only)+(q6_1)': intersection([{'gender': 1}, {'age': [30, 31, 32, 33, 34, 35]}])}), - (u'q6_2', {'(men only)+(q6_2)': intersection([{'gender': 1}, {'age': [30, 31, 32, 33, 34, 35]}])}), - (u'q6_3', {'(men only)+(q6_3)': intersection([{'gender': 1}, {'age': [30, 31, 32, 33, 34, 35]}])}), - ('age', {'men only': {'gender': 1}})]) - self.assertEqual(b_meta['x_filter_map'], x_filter_map) - - def test_add_y_on_y(self): - batch, ds = _get_batch('test', full=True) - b_meta = _get_meta(batch) - batch.add_y_on_y('cross', {'age': frange('20-30')}, 'extend') - batch.add_y_on_y('back', 'no_filter', 'replace') - self.assertEqual(b_meta['y_filter_map']['back'], 'no_filter') - self.assertEqual(b_meta['y_on_y'], ['cross', 'back']) - - - ######################### meta edit methods ############################## - - def test_hiding(self): - batch, ds = _get_batch('test', full=True) - b_meta = _get_meta(batch) - batch.hiding(['q1', 'q6'], [1, 2], ['x', 'y']) - for v in ['q1', u'q6_1', u'q6_2', u'q6_3']: - self.assertTrue(not b_meta['meta_edits'][v]['rules']['x'] == {}) - for v in ['q1', 'q6']: - self.assertTrue(not b_meta['meta_edits'][v]['rules']['y'] == {}) - - def test_sorting(self): - batch, ds = _get_batch('test', full=True) - b_meta = _get_meta(batch) - batch.sorting(['q1', 'q6']) - for v in ['q1', u'q6_1', u'q6_2', u'q6_3']: - self.assertTrue(not b_meta['meta_edits'][v]['rules']['x'] == {}) - self.assertTrue(b_meta['meta_edits']['q6'].get('rules') is None) - - def test_slicing(self): - batch, ds = _get_batch('test', full=True) - b_meta = _get_meta(batch) - self.assertRaises(KeyError, batch.slicing, 'q6', [1, 2]) - batch.slicing(['q1', 'q2'], [3, 2, 1], ['x', 'y']) - for v in ['q1', 'q2']: - for ax in ['x', 'y']: - self.assertTrue(not b_meta['meta_edits'][v]['rules'][ax] == {}) - +import unittest +import os.path +import numpy as np +import pandas as pd +import quantipy as qp + +from quantipy.core.tools.view.logic import ( + has_any, has_all, has_count, + not_any, not_all, not_count, + is_lt, is_ne, is_gt, + is_le, is_eq, is_ge, + union, intersection) + +from quantipy.core.tools.dp.prep import frange +from collections import OrderedDict + +def _get_dataset(): + path = os.path.dirname(os.path.abspath(__file__)) + '/' + name = 'Example Data (A)' + casedata = '{}.csv'.format(name) + metadata = '{}.json'.format(name) + dataset = qp.DataSet(name, False) + dataset.set_verbose_infomsg(False) + dataset.set_verbose_errmsg(False) + dataset.read_quantipy(path+metadata, path+casedata) + return dataset + +def _get_batch(name, dataset=None, full=False): + if not dataset: dataset = _get_dataset() + batch = qp.Batch(dataset, name) + if full: + if not 'men_only' in dataset: + dataset.add_filter_var('men_only', {'gender': 1}) + batch.add_downbreak(['q1', 'q2', 'q6', 'age']) + batch.add_crossbreak(['gender', 'q2']) + batch.add_open_ends(['q8a', 'q9a'], 'RecordNo') + batch.add_filter('men_only') + batch.set_weights('weight_a') + return batch, dataset + +def _get_meta(batch): + name = batch.name + return batch._meta['sets']['batches'][name] + +class TestBatch(unittest.TestCase): + + def test_dataset_add_batch(self): + dataset = _get_dataset() + batch1 = dataset.add_batch('batch1') + batch2 = dataset.add_batch('batch2', 'c', 'weight', .05) + self.assertTrue(isinstance(batch1, qp.Batch)) + self.assertEqual(len(_get_meta(batch1).keys()), 31) + b_meta = _get_meta(batch2) + self.assertEqual(b_meta['name'], 'batch2') + self.assertEqual(b_meta['cell_items'], ['c']) + self.assertEqual(b_meta['weights'], ['weight']) + self.assertEqual(b_meta['sigproperties']['siglevels'], [0.05]) + + def test_dataset_get_batch(self): + batch, ds = _get_batch('test', full=True) + self.assertRaises(KeyError, ds.get_batch, 'name') + b = ds.get_batch('test') + attr = [ + 'xks', 'yks', '_variables', 'filter', 'filter_names', + 'x_y_map', 'x_filter_map', 'y_on_y', 'y_on_y_filter', + 'forced_names', 'transposed', 'leveled', 'verbatims', + 'extended_yks_per_x', + 'exclusive_yks_per_x', 'extended_filters_per_x', 'meta_edits', + 'cell_items', 'weights', 'sigproperties', 'additional', + 'sample_size', 'language', 'name', 'skip_items', 'total', + 'unwgt_counts', 'y_filter_map', 'build_info', + '_section_starts'] + for a in attr: + self.assertEqual(batch.__dict__[a], b.__dict__[a]) + + def test_from_batch(self): + ds = _get_dataset() + ds.force_texts('de-DE', 'en-GB') + batch1, ds = _get_batch('test1', ds, full=True) + batch1.set_language('de-DE') + batch1.hiding('q1', frange('8,9,96-99')) + batch1.slicing('q1', frange('9-4')) + batch2, ds = _get_batch('test2', ds) + batch2.add_downbreak('q1') + batch2.add_crossbreak('Wave') + batch2.as_addition('test1') + n_ds = ds.from_batch('test1', 'RecordNo', 'de-DE', True, 'variables') + self.assertEqual(n_ds.codes('q1'), [7, 6, 5, 4]) + self.assertEqual(n_ds.variables(), [u'age', u'gender', u'q1', u'q2', + u'q6', u'q8a', u'q9a', u'Wave', + u'weight_a', u'RecordNo']) + self.assertEqual(n_ds['gender'].value_counts().values.tolist(), [3952]) + self.assertEqual(n_ds.value_texts('gender', 'en-GB'), [None, None]) + self.assertEqual(n_ds.value_texts('gender', 'de-DE'), [u'Male', u'Female']) + self.assertRaises(ValueError, ds.from_batch, 'test1', 'RecordNo', 'fr-FR') + + # ########################## methods used in _get_batch #################### + + def test_add_downbreak(self): + batch, ds = _get_batch('test') + batch.add_downbreak(['q1', 'q2', 'q2b', {'q3': 'q3_label'}, 'q4', {'q5': 'q5_label'}, 'q14_1']) + b_meta = _get_meta(batch) + self.assertEqual(b_meta['xks'], ['q1', 'q2', 'q2b', 'q3', 'q4', 'q5', + u'q5_1', u'q5_2', u'q5_3', u'q5_4', u'q5_5', + u'q5_6', 'q14_1', u'q14r01c01', u'q14r02c01', + u'q14r03c01', u'q14r04c01', u'q14r05c01', u'q14r06c01', + u'q14r07c01', u'q14r08c01', u'q14r09c01', u'q14r10c01']) + self.assertEqual(b_meta['forced_names'], {'q3': 'q3_label', 'q5': 'q5_label'}) + x_y_map = [('q1', ['@']), ('q2', ['@']), ('q2b', ['@']), + ('q3', ['@']), ('q4', ['@']), ('q5', ['@']), + (u'q5_1', ['@']), (u'q5_2', ['@']), + (u'q5_3', ['@']), (u'q5_4', ['@']), + (u'q5_5', ['@']), (u'q5_6', ['@']), + ('q14_1', ['@']), (u'q14r01c01', ['@']), + (u'q14r02c01', ['@']), (u'q14r03c01', ['@']), + (u'q14r04c01', ['@']), (u'q14r05c01', ['@']), + (u'q14r06c01', ['@']), (u'q14r07c01', ['@']), + (u'q14r08c01', ['@']), (u'q14r09c01', ['@']), + (u'q14r10c01', ['@'])] + self.assertEqual(b_meta['x_y_map'], x_y_map) + + def test_add_crossbreak(self): + batch, ds = _get_batch('test') + batch.add_crossbreak(['gender', 'q2b']) + b_meta = _get_meta(batch) + self.assertEqual(b_meta['yks'], ['@', 'gender', 'q2b']) + self.assertRaises(KeyError, batch.add_crossbreak, ['@', 'GENDER']) + batch.add_downbreak('q1') + x_y_map = [('q1', ['@', 'gender', 'q2b'])] + self.assertEqual(b_meta['x_y_map'], x_y_map) + + def test_add_open_ends(self): + batch, ds = _get_batch('test') + self.assertRaises(ValueError, batch.add_open_ends, ['q8a', 'q9a'], None, + True, False, True, 'open ends', None) + batch.add_filter('men_only', {'gender': 1}) + batch.add_open_ends(['q8a', 'q9a'], 'RecordNo', filter_by={'age': is_ge(49)}) + verbatims = _get_meta(batch)['verbatims'][0] + self.assertEqual(verbatims['filter'], 'men_only_open_ends_f') + self.assertEqual(verbatims['columns'], ['q8a', 'q9a']) + self.assertEqual(verbatims['break_by'], ['RecordNo']) + self.assertEqual(verbatims['title'], 'open ends') + batch.add_open_ends(['q8a', 'q9a'], 'RecordNo', split=True, + title=['open ends', 'open ends2'], overwrite=True) + verbatims = _get_meta(batch)['verbatims'] + self.assertEqual(len(verbatims), 2) + + def test_add_filter(self): + batch, ds = _get_batch('test', full=False) + batch.add_downbreak(['q1', 'q2b']) + batch.add_crossbreak('gender') + batch.add_filter('men_only', {'gender': 1}) + b_meta = _get_meta(batch) + self.assertEqual(b_meta['filter'], 'men_only') + x_filter_map = OrderedDict([('q1', 'men_only'), + ('q2b', 'men_only')]) + self.assertEqual(b_meta['x_filter_map'], x_filter_map) + self.assertEqual(b_meta['filter_names'], ['men_only']) + + def test_set_weight(self): + batch, ds = _get_batch('test') + self.assertRaises(ValueError, batch.set_weights, 'Weight') + batch.set_weights('weight_a') + self.assertEqual(_get_meta(batch)['weights'], ['weight_a']) + self.assertEqual(batch.weights, ['weight_a']) + + # ########################################################################## + + def test_copy(self): + batch1, ds = _get_batch('test', full=True) + batch2 = batch1.clone('test_copy') + batch3 = batch1.clone('test_copy2', as_addition=True) + attributes = ['xks', 'yks', 'filter', 'filter_names', 'x_y_map', + 'x_filter_map', 'y_on_y', 'forced_names', + 'transposed', 'extended_yks_per_x', + 'exclusive_yks_per_x', 'extended_filters_per_x', 'meta_edits', + 'cell_items', 'weights', 'sigproperties', 'additional', + 'sample_size', 'language', '_variables', 'y_on_y_filter', + 'leveled', 'skip_items', 'total', 'unwgt_counts', + '_section_starts'] + for a in attributes: + value = batch1.__dict__[a] + value2 = batch2.__dict__[a] + self.assertEqual(value, value2) + self.assertEqual(batch3.verbatims, []) + self.assertEqual(batch3.additional, True) + self.assertEqual(_get_meta(batch2)['name'], 'test_copy') + + def test_as_addition(self): + batch1, ds = _get_batch('test1', full=True) + batch2, ds = _get_batch('test2', ds, True) + batch2.as_addition('test1') + self.assertEqual(_get_meta(batch1)['additions'], ['test2']) + b_meta = _get_meta(batch2) + self.assertEqual(b_meta['additional'], True) + self.assertEqual(b_meta['verbatims'], []) + self.assertEqual(b_meta['y_on_y'], []) + + def test_set_cell_items(self): + batch, ds = _get_batch('test', full=True) + self.assertRaises(ValueError, batch.set_cell_items, ['c', 'pc']) + batch.set_cell_items('c') + self.assertEqual(_get_meta(batch)['cell_items'], ['c']) + self.assertEqual(batch.cell_items, ['c']) + + def test_set_language(self): + batch, ds = _get_batch('test', full=True) + self.assertRaises(ValueError, batch.set_language, 'en-gb') + batch.set_language('sv-SE') + self.assertEqual(_get_meta(batch)['language'], 'sv-SE') + self.assertEqual(batch.language, 'sv-SE') + + def test_set_sigtest(self): + batch, ds = _get_batch('test', full=True) + self.assertRaises(TypeError, batch.set_sigtests, [0.05, '0.01']) + batch.set_sigtests(.05) + self.assertEqual(_get_meta(batch)['sigproperties']['siglevels'], [0.05]) + + def test_level(self): + batch, ds = _get_batch('test', full=True) + batch.add_downbreak(['q5', 'q6']) + batch.level(['q5', 'q6']) + b_meta = _get_meta(batch) + leveled = { + 'q5': ['@', 'gender', 'q2'], + 'q6': ['@', 'gender', 'q2']} + self.assertEqual(b_meta['leveled'], leveled) + + def test_transpose(self): + batch, ds = _get_batch('test', full=True) + batch.add_downbreak(['q5', 'q6']) + batch.transpose(['q5']) + batch.exclusive_arrays(['q5', 'q6']) + b_meta = _get_meta(batch) + x_y_map = [ + ('q5', ['@']), + ('@', ['q5']), + ('q6', ['@'])] + self.assertEqual(b_meta['x_y_map'], x_y_map) + + # def test_make_summaries_transpose_arrays(self): + # batch, ds = _get_batch('test') + # b_meta = _get_meta(batch) + # batch.add_downbreak(['q5', 'q6', 'q14_2', 'q14_3', 'q14_1']) + # batch.make_summaries(None) + # self.assertEqual(b_meta['summaries'], []) + # batch.transpose_arrays(['q5', 'q6'], False) + # batch.transpose_arrays(['q14_2', 'q14_3'], True) + # self.assertEqual(b_meta['summaries'], ['q5', 'q6', 'q14_2', 'q14_3']) + # t_a = {'q14_2': True, 'q14_3': True, 'q5': False, 'q6': False} + # self.assertEqual(b_meta['transposed_arrays'], t_a) + # batch.make_summaries('q5') + # self.assertEqual(b_meta['transposed_arrays'], {'q5': False}) + # self.assertRaises(ValueError, batch.make_summaries, 'q7') + + def test_extend_y(self): + batch1, ds = _get_batch('test1', full=True) + batch2, ds = _get_batch('test2', ds, True) + b_meta1 = _get_meta(batch1) + b_meta2 = _get_meta(batch2) + self.assertRaises(ValueError, batch1.extend_y, 'q2b', 'q5') + batch1.extend_y('q2b') + x_y_map = [('q1', ['@', 'gender', 'q2', 'q2b']), + ('q2', ['@', 'gender', 'q2', 'q2b']), + ('q6', ['@']), + (u'q6_1', ['@', 'gender', 'q2', 'q2b']), + (u'q6_2', ['@', 'gender', 'q2', 'q2b']), + (u'q6_3', ['@', 'gender', 'q2', 'q2b']), + ('age', ['@', 'gender', 'q2', 'q2b'])] + self.assertEqual(b_meta1['x_y_map'], x_y_map) + batch2.extend_y('q2b', 'q2') + batch2.extend_y('q3', 'q6') + extended_yks_per_x = {u'q6_3': ['q3'], 'q2': ['q2b'], u'q6_1': ['q3'], + u'q6_2': ['q3']} + self.assertEqual(b_meta2['extended_yks_per_x'], extended_yks_per_x) + x_y_map = [('q1', ['@', 'gender', 'q2']), + ('q2', ['@', 'gender', 'q2', 'q2b']), + ('q6', ['@']), + (u'q6_1', ['@', 'gender', 'q2', 'q3']), + (u'q6_2', ['@', 'gender', 'q2', 'q3']), + (u'q6_3', ['@', 'gender', 'q2', 'q3']), + ('age', ['@', 'gender', 'q2'])] + self.assertEqual(b_meta2['x_y_map'], x_y_map) + + def test_replace_y(self): + batch, ds = _get_batch('test', full=True) + b_meta = _get_meta(batch) + self.assertRaises(ValueError, batch.replace_y, 'q2b', 'q5') + batch.replace_y('q2b', 'q6') + exclusive_yks_per_x = {u'q6_3': ['@', 'q2b'], + u'q6_1': ['@', 'q2b'], + u'q6_2': ['@', 'q2b']} + self.assertEqual(b_meta['exclusive_yks_per_x'], exclusive_yks_per_x) + x_y_map = [('q1', ['@', 'gender', 'q2']), + ('q2', ['@', 'gender', 'q2']), + ('q6', ['@']), + (u'q6_1', ['@', 'q2b']), + (u'q6_2', ['@', 'q2b']), + (u'q6_3', ['@', 'q2b']), + ('age', ['@', 'gender', 'q2'])] + self.assertEqual(b_meta['x_y_map'], x_y_map) + + def test_extend_filter(self): + batch, ds = _get_batch('test', full=True) + b_meta = _get_meta(batch) + ext_filters = {'q1': {'age': frange('20-25')}, ('q2', 'q6'): {'age': frange('30-35')}} + batch.extend_filter(ext_filters) + filter_names = ['men_only', 'men_only_q1', 'men_only_q2', 'men_only_q6'] + self.assertEqual(b_meta['filter_names'], filter_names) + x_filter_map = OrderedDict( + [('q1', 'men_only_q1'), + ('q2', 'men_only_q2'), + ('q6', 'men_only_q6'), + ('q6_1', 'men_only_q6'), + ('q6_2', 'men_only_q6'), + ('q6_3', 'men_only_q6'), + ('age', 'men_only')]) + self.assertEqual(b_meta['x_filter_map'], x_filter_map) + + def test_add_y_on_y(self): + batch, ds = _get_batch('test', full=True) + b_meta = _get_meta(batch) + batch.add_y_on_y('cross', {'age': frange('20-30')}, 'extend') + batch.add_y_on_y('back', None, 'replace') + self.assertEqual(b_meta['y_filter_map']['back'], None) + self.assertEqual(b_meta['y_on_y'], ['cross', 'back']) + + + ######################### meta edit methods ############################## + + def test_hiding(self): + batch, ds = _get_batch('test', full=True) + b_meta = _get_meta(batch) + batch.hiding(['q1', 'q6'], [1, 2], ['x', 'y']) + for v in ['q1', u'q6_1', u'q6_2', u'q6_3']: + self.assertTrue(not b_meta['meta_edits'][v]['rules']['x'] == {}) + for v in ['q1', 'q6']: + self.assertTrue(not b_meta['meta_edits'][v]['rules']['y'] == {}) + + def test_sorting(self): + batch, ds = _get_batch('test', full=True) + b_meta = _get_meta(batch) + batch.sorting(['q1', 'q6']) + for v in ['q1', u'q6_1', u'q6_2', u'q6_3']: + self.assertTrue(not b_meta['meta_edits'][v]['rules']['x'] == {}) + self.assertTrue(b_meta['meta_edits']['q6'].get('rules') is None) + + def test_slicing(self): + batch, ds = _get_batch('test', full=True) + b_meta = _get_meta(batch) + self.assertRaises(KeyError, batch.slicing, 'q6', [1, 2]) + batch.slicing(['q1', 'q2'], [3, 2, 1], ['x', 'y']) + for v in ['q1', 'q2']: + for ax in ['x', 'y']: + self.assertTrue(not b_meta['meta_edits'][v]['rules'][ax] == {}) + diff --git a/tests/test_dataset.py b/tests/test_dataset.py index ef631716c..28bb0e7f8 100644 --- a/tests/test_dataset.py +++ b/tests/test_dataset.py @@ -501,7 +501,7 @@ def test_sorting_rules_meta(self): 'between': False, 'ascending': False, 'sort_on': '@', - 'with_weight': None}}, + 'with_weight': 'auto'}}, 'y': {}} # rule correctly set?: i.e. code 100 removed from fix list since it # does not appear in the values meta? @@ -741,7 +741,7 @@ def test_get_variable_text(self): self.assertEqual(text, dataset.text('q6_1', False, 'en-GB')) text = 'Exercise alone' self.assertEqual(text, dataset.text('q6_1', True, 'en-GB')) - text = None + text = '' self.assertEqual(text, dataset.text('q6_1', True, 'en-GB', 'x')) def test_set_value_texts(self): diff --git a/tests/test_excel.py b/tests/test_excel.py index 70038275e..bdfe44412 100644 --- a/tests/test_excel.py +++ b/tests/test_excel.py @@ -71,6 +71,10 @@ def basic_chain_manager(self, stack): stack.add_link(x=self.flatten(p.XKEYS_BASIC), y=p.YKEYS_BASIC, views=p.VIEWS_BASIC, weights=p.WEIGHT_BASIC) + locality = stack[DATA_KEY].meta['columns']['locality'] + for idx in xrange(1, 4): + locality['values'][idx]['text'] = {'en-GB': '.'} + vm = ViewManager(stack) vm.get_views(cell_items=p.CELLS_BASIC, weight=p.WEIGHT_BASIC, @@ -297,12 +301,12 @@ def chain_manager(stack): p.FORMATS_BASIC, None, p.SHEET_PROPERTIES_EXCEL_BASIC ), ( - 'complex', p.PATH_COMPLEX_0, None, None, None, False, None, + 'complex', p.PATH_COMPLEX_0, None, None, None, False, None, None, p.FORMATS_0, None, None ), ( - 'complex', p.PATH_COMPLEX_1, p.SHEET_PROPERTIES_1, p.VIEW_GROUPS_1, - None, False, p.DECIMALS_1, p.IMAGE_1, p.FORMATS_1, None, None + 'complex', p.PATH_COMPLEX_1, p.SHEET_PROPERTIES_1, p.VIEW_GROUPS_1, + None, False, p.DECIMALS_1, p.IMAGE_1, p.FORMATS_1, None, None ), ( 'complex', p.PATH_COMPLEX_2, p.SHEET_PROPERTIES_2, p.VIEW_GROUPS_2, diff --git a/tests/test_io_dimensions.py b/tests/test_io_dimensions.py index f60bbdaab..1ecff862c 100644 --- a/tests/test_io_dimensions.py +++ b/tests/test_io_dimensions.py @@ -1,43 +1,53 @@ import unittest import os.path -import numpy -import pandas as pd -from pandas.util.testing import assert_frame_equal -import test_helper +import quantipy as qp import copy - -from collections import defaultdict, OrderedDict -from quantipy.core.stack import Stack -from quantipy.core.chain import Chain -from quantipy.core.link import Link -from quantipy.core.view_generators.view_mapper import ViewMapper -from quantipy.core.view_generators.view_maps import QuantipyViews -from quantipy.core.view import View -from quantipy.core.helpers import functions -from quantipy.core.helpers.functions import load_json - -class TestStackObject(unittest.TestCase): - - def setUp(self): - pass - - @classmethod - def tearDownClass(self): - pass - -if __name__ == '__main__': - unittest.main() - - - - - - - - - - - - - +from quantipy.core.tools.dp.dimensions.dimlabels import ( + qp_dim_languages, + DimLabels) + + +def _get_dataset(): + path = os.path.dirname(os.path.abspath(__file__)) + '/' + name = 'Example Data (A)' + casedata = '{}.csv'.format(name) + metadata = '{}.json'.format(name) + dataset = qp.DataSet(name, False) + dataset.set_verbose_infomsg(False) + dataset.set_verbose_errmsg(False) + dataset.read_quantipy(path+metadata, path+casedata) + return dataset + +def loop_for_text_objs(obj, func, name=None): + if isinstance(obj, dict): + for k, v in obj.items(): + if k == 'text' and isinstance(v, dict): + func(copy.deepcopy(v), name) + else: + loop_for_text_objs(v, func, k) + elif isinstance(obj, list): + for o in obj: + loop_for_text_objs(o, func, name) + +class TestDimLabels(unittest.TestCase): + + def _test_dimlabels(self, x, name): + d_labels = DimLabels(name, 'de-DE') + d_labels.add_text(x) + languages = {v: k for k, v in qp_dim_languages.items()} + for lab in d_labels.labels: + t1 = lab.default_lan == 'DEU' + if lab.labeltype: + t2 = lab.text == x[lab.labeltype].pop(languages[lab.language]) + if not x[lab.labeltype]: del x[lab.labeltype] + else: + t2 = lab.text == x.pop(languages[lab.language]) + self.assertTrue(t1 and t2) + self.assertEqual({}, x) + + def test_dimlabels(self): + dataset = _get_dataset() + dataset.set_variable_text('q1', 'test label', 'en-GB', 'x') + dataset.set_value_texts('q2b', dict(dataset.values('q2b')), 'sv-SE') + loop_for_text_objs(dataset._meta, self._test_dimlabels) diff --git a/tests/test_stack.py b/tests/test_stack.py index 060e56338..1fd410858 100644 --- a/tests/test_stack.py +++ b/tests/test_stack.py @@ -1108,19 +1108,17 @@ def test_stack_aggregate(self): b1, ds = _get_batch('test1', full=True) b2, ds = _get_batch('test2', ds, False) b3, ds = _get_batch('test3', ds, False) - b1.add_x(['q1', 'q6', 'age']) - b1.add_y(['gender', 'q2']) - b1.add_filter('men only', {'gender': 1}) + b1.add_downbreak(['q1', 'q6', 'age']) + b1.add_crossbreak(['gender', 'q2']) b1.extend_filter({'q1':{'age': [20, 21, 22]}}) b1.set_weights('weight_a') - b2.add_x(['q1', 'q6']) - b2.add_y(['gender', 'q2']) + b2.add_downbreak(['q1', 'q6']) + b2.add_crossbreak(['gender', 'q2']) b2.set_weights('weight_b') - b2.transpose_arrays('q6') - b3.add_x(['q1', 'q7']) - b3.add_y(['q2b']) + b2.transpose('q6') + b3.add_downbreak(['q1', 'q7']) + b3.add_crossbreak(['q2b']) b3.add_y_on_y('y_on_y') - b3.make_summaries(None) b3.set_weights(['weight_a', 'weight_b']) stack = ds.populate(verbose=False) stack.aggregate(['cbase', 'counts', 'c%'], True, @@ -1132,19 +1130,21 @@ def test_stack_aggregate(self): 'x|f|:|y|weight_a|c%', 'x|f|:|y|weight_b|c%', 'x|f|:||weight_a|counts', 'x|f|:||weight_b|counts', 'x|f|x:||weight_a|cbase', 'x|f|x:||weight_b|cbase', 'x|f|x:|||cbase'] - cols = ['@', 'age', 'q1', 'q2b', 'q6', u'q6_1', u'q6_2', u'q6_3', u'q7_1', + cols = ['@', 'age', 'q1', 'q2b', 'q6', u'q6_1', u'q6_2', u'q6_3', u'q7', u'q7_1', u'q7_2', u'q7_3', u'q7_4', u'q7_5', u'q7_6'] - values = [['NONE', 'NONE', 2.0, 2.0, 'NONE', 'NONE', 'NONE', 'NONE', 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], - ['NONE', 'NONE', 2.0, 2.0, 'NONE', 'NONE', 'NONE', 'NONE', 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], - ['NONE', 'NONE', 2.0, 2.0, 'NONE', 'NONE', 'NONE', 'NONE', 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], - ['NONE', 'NONE', 2.0, 2.0, 'NONE', 'NONE', 'NONE', 'NONE', 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], - ['NONE', 3.0, 5.0, 2.0, 1.0, 3.0, 3.0, 3.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], - [1.0, 'NONE', 4.0, 2.0, 'NONE', 3.0, 3.0, 3.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], - ['NONE', 3.0, 5.0, 2.0, 1.0, 3.0, 3.0, 3.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], - [1.0, 'NONE', 4.0, 2.0, 'NONE', 3.0, 3.0, 3.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], - ['NONE', 3.0, 5.0, 2.0, 1.0, 3.0, 3.0, 3.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], - [1.0, 'NONE', 4.0, 2.0, 'NONE', 3.0, 3.0, 3.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], - ['NONE', 3.0, 6.0, 'NONE', 'NONE', 6.0, 6.0, 6.0, 'NONE', 'NONE', 'NONE', 'NONE', 'NONE', 'NONE']] + values = [ + ['NONE', 'NONE', 2.0, 2.0, 'NONE', 'NONE', 'NONE', 'NONE', 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], + ['NONE', 'NONE', 2.0, 2.0, 'NONE', 'NONE', 'NONE', 'NONE', 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], + ['NONE', 'NONE', 2.0, 2.0, 'NONE', 'NONE', 'NONE', 'NONE', 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], + ['NONE', 'NONE', 2.0, 2.0, 'NONE', 'NONE', 'NONE', 'NONE', 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], + ['NONE', 3.0, 5.0, 2.0, 1.0, 3.0, 3.0, 3.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], + [1.0, 'NONE', 4.0, 2.0, 1.0, 3.0, 3.0, 3.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], + ['NONE', 3.0, 5.0, 2.0, 1.0, 3.0, 3.0, 3.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], + [1.0, 'NONE', 4.0, 2.0, 1.0, 3.0, 3.0, 3.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], + ['NONE', 3.0, 5.0, 2.0, 1.0, 3.0, 3.0, 3.0, 1.0, 2.0,2.0, 2.0, 2.0, 2.0, 2.0], + [1.0, 'NONE', 4.0, 2.0, 1.0, 3.0, 3.0, 3.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0], + [1.0, 3.0, 6.0, 'NONE', 2.0, 6.0, 6.0, 6.0, 'NONE', 'NONE', 'NONE', 'NONE', 'NONE', 'NONE', 'NONE']] + describe = stack.describe('view', 'x').replace(numpy.NaN, 'NONE') self.assertEqual(describe.index.tolist(), index) self.assertEqual(describe.columns.tolist(), cols) @@ -1164,7 +1164,7 @@ def test_cumulative_sum(self): ['NONE', 'NONE', 3.0, 'NONE', 'NONE', 'NONE', 'NONE'], ['NONE', 'NONE', 3.0, 'NONE', 'NONE', 'NONE', 'NONE'], [3.0, 3.0, 3.0, 1.0, 3.0, 3.0, 3.0], - [3.0, 3.0, 3.0, 'NONE', 3.0, 3.0, 3.0]] + [3.0, 3.0, 3.0, 1.0, 3.0, 3.0, 3.0]] self.assertEqual(describe.index.tolist(), index) self.assertEqual(describe.columns.tolist(), cols) self.assertEqual(describe.values.tolist(), values) @@ -1175,7 +1175,7 @@ def test_add_nets(self): stack.aggregate(['cbase', 'counts', 'c%'], batches='all', verbose=False) calcu = calc((2, '-', 1), 'difference', 'en-GB') stack.add_nets(['q1', 'q6'], [{'Net1': [1, 2]}, {'Net2': [3, 4]}], 'after', - calcu, _batches='all', verbose=False) + calcu, _batches='all', recode=False, verbose=False) index = ['x|f.c:f|x[{1,2}+],x[{3,4}+],x[{3,4}-{1,2}]*:|y|weight_a|net', 'x|f.c:f|x[{1,2}+],x[{3,4}+],x[{3,4}-{1,2}]*:||weight_a|net', 'x|f|:|y|weight_a|c%', 'x|f|:||weight_a|counts', @@ -1186,7 +1186,7 @@ def test_add_nets(self): ['NONE', 'NONE', 3.0, 'NONE', 'NONE', 'NONE', 'NONE'], ['NONE', 'NONE', 3.0, 'NONE', 'NONE', 'NONE', 'NONE'], [3.0, 3.0, 3.0, 1.0, 3.0, 3.0, 3.0], - [3.0, 3.0, 3.0, 'NONE', 3.0, 3.0, 3.0]] + [3.0, 3.0, 3.0, 1.0, 3.0, 3.0, 3.0]] describe = stack.describe('view', 'x').replace(numpy.NaN, 'NONE') self.assertEqual(describe.index.tolist(), index) self.assertEqual(describe.columns.tolist(), cols) @@ -1229,7 +1229,7 @@ def test_add_stats(self): ['NONE', 3.0, 3.0, 1.0, 3.0, 3.0, 3.0], ['NONE', 3.0, 3.0, 1.0, 3.0, 3.0, 3.0], [3.0, 3.0, 3.0, 1.0, 3.0, 3.0, 3.0], - [3.0, 3.0, 3.0, 'NONE', 3.0, 3.0, 3.0]] + [3.0, 3.0, 3.0, 1.0, 3.0, 3.0, 3.0]] describe = stack.describe('view', 'x').replace(numpy.NaN, 'NONE') self.assertEqual(describe.index.tolist(), index) self.assertEqual(describe.columns.tolist(), cols) @@ -1255,11 +1255,11 @@ def _factor_on_values(values, axis = 'x'): '[{}]'.format(v['value'])) for v in values) b1, ds = _get_batch('test1', full=True) - b1.add_x(['q1', 'q2b', 'q6']) + b1.add_downbreak(['q1', 'q2b', 'q6']) b1.set_variable_text('q1', 'some new text1') b1.set_variable_text('q6', 'some new text1') b2, ds = _get_batch('test2', ds, True) - b2.add_x(['q1', 'q2b', 'q6']) + b2.add_downbreak(['q1', 'q2b', 'q6']) b2.set_variable_text('q1', 'some new text2') stack = ds.populate(verbose=False) stack.aggregate(['cbase', 'counts', 'c%'], batches='all', verbose=False) diff --git a/tests/test_view_manager.py b/tests/test_view_manager.py index 7da27a526..3ac09f048 100644 --- a/tests/test_view_manager.py +++ b/tests/test_view_manager.py @@ -33,14 +33,14 @@ def _get_stack(self, unwgt=True, wgt=True, stats=True, nets=True, tests=True): else: w = None batch = dataset.add_batch('viewmanager', weights=w, tests=[0.05] if tests else None) - batch.add_x(x) - batch.add_y(y) + batch.add_downbreak(x) + batch.add_crossbreak(y) stack = dataset.populate() basic_views = ['cbase', 'counts', 'c%', 'counts_sum', 'c%_sum'] stack.aggregate(views=basic_views, verbose=False) if nets: - stack.add_nets(['q5', 'q9'], [{'Top3': [1, 2, 3]}], verbose=False) - stack.add_nets(['q8'], [{'Top2': [1, 2]}], expand='after', verbose=False) + stack.add_nets(['q5', 'q9'], [{'Top3': [1, 2, 3]}], verbose=False, recode=False) + stack.add_nets(['q8'], [{'Top2': [1, 2]}], expand='after', verbose=False, recode=False) if stats: stack.add_stats(x, ['mean'], rescale={1:100, 2:50, 3:0}, verbose=False) stack.add_stats('q5', ['mean', 'stddev'], custom_text='stat2', verbose=False) @@ -392,3 +392,4 @@ def test_vm_p_b_n_s_t_w_both(self): 'before', True) vm_views = vm.views self.assertEqual(vm_views, E['p_b_n_s_t_w_both']) +