├── .gitignore
├── .pytest_cache
├── README.md
└── v
│ └── cache
│ └── nodeids
├── LICENSE.txt
├── MANIFEST.in
├── README.md
├── autotests.py
├── docs
└── API
│ ├── Makefile
│ ├── YG_logo.jpg
│ ├── _build
│ ├── doctrees
│ │ ├── environment.pickle
│ │ ├── index.doctree
│ │ └── sites
│ │ │ ├── api_ref
│ │ │ ├── 00overview.doctree
│ │ │ ├── Chain.doctree
│ │ │ ├── Cluster.doctree
│ │ │ ├── DataSet.doctree
│ │ │ ├── QuantipyViews.doctree
│ │ │ ├── Rim_scheme.doctree
│ │ │ ├── View.doctree
│ │ │ ├── ViewMapper.doctree
│ │ │ ├── quantify_engine.doctree
│ │ │ └── stack.doctree
│ │ │ ├── lib_doc
│ │ │ ├── batch
│ │ │ │ ├── 00_overview.doctree
│ │ │ │ ├── 01_create_load.doctree
│ │ │ │ ├── 02_variables.doctree
│ │ │ │ ├── 03_properties.doctree
│ │ │ │ └── 04_subclass.doctree
│ │ │ ├── builds
│ │ │ │ ├── 00_overview.doctree
│ │ │ │ └── 01_chains.doctree
│ │ │ ├── dataprocessing
│ │ │ │ ├── 00_overview.doctree
│ │ │ │ ├── 01_components.doctree
│ │ │ │ ├── 02_io.doctree
│ │ │ │ ├── 02a_management.doctree
│ │ │ │ ├── 03_inspection.doctree
│ │ │ │ ├── 04_editing.doctree
│ │ │ │ ├── 05_transforming.doctree
│ │ │ │ ├── 06_logics.doctree
│ │ │ │ └── 07_custom_recoding.doctree
│ │ │ ├── engine
│ │ │ │ ├── 00_overview.doctree
│ │ │ │ ├── 01_links_stacks.doctree
│ │ │ │ ├── 02_quantity.doctree
│ │ │ │ ├── 03_test.doctree
│ │ │ │ └── 04_agg_methods.doctree
│ │ │ └── overview.doctree
│ │ │ └── release_notes
│ │ │ ├── 00_overview.doctree
│ │ │ ├── 01_latest.doctree
│ │ │ ├── 02_archive.doctree
│ │ │ ├── 03_how_to_snippets.doctree
│ │ │ └── how_to_snippets
│ │ │ ├── create_categorical_meta.doctree
│ │ │ ├── derotate.doctree
│ │ │ └── dimensions_comp.doctree
│ └── html
│ │ ├── .buildinfo
│ │ ├── _sources
│ │ ├── index.rst.txt
│ │ └── sites
│ │ │ ├── api_ref
│ │ │ ├── 00overview.rst.txt
│ │ │ ├── Chain.rst.txt
│ │ │ ├── Cluster.rst.txt
│ │ │ ├── DataSet.rst.txt
│ │ │ ├── QuantipyViews.rst.txt
│ │ │ ├── Rim_scheme.rst.txt
│ │ │ ├── View.rst.txt
│ │ │ ├── ViewMapper.rst.txt
│ │ │ ├── quantify_engine.rst.txt
│ │ │ └── stack.rst.txt
│ │ │ ├── lib_doc
│ │ │ ├── batch
│ │ │ │ ├── 00_overview.rst.txt
│ │ │ │ ├── 01_create_load.rst.txt
│ │ │ │ ├── 02_variables.rst.txt
│ │ │ │ ├── 03_properties.rst.txt
│ │ │ │ └── 04_subclass.rst.txt
│ │ │ ├── builds
│ │ │ │ ├── 00_overview.rst.txt
│ │ │ │ └── 01_chains.rst.txt
│ │ │ ├── dataprocessing
│ │ │ │ ├── 00_overview.rst.txt
│ │ │ │ ├── 01_components.rst.txt
│ │ │ │ ├── 02_io.rst.txt
│ │ │ │ ├── 02a_management.rst.txt
│ │ │ │ ├── 03_inspection.rst.txt
│ │ │ │ ├── 04_editing.rst.txt
│ │ │ │ ├── 05_transforming.rst.txt
│ │ │ │ ├── 06_logics.rst.txt
│ │ │ │ └── 07_custom_recoding.rst.txt
│ │ │ ├── engine
│ │ │ │ ├── 00_overview.rst.txt
│ │ │ │ ├── 01_links_stacks.rst.txt
│ │ │ │ ├── 02_quantity.rst.txt
│ │ │ │ ├── 03_test.rst.txt
│ │ │ │ └── 04_agg_methods.rst.txt
│ │ │ └── overview.rst.txt
│ │ │ └── release_notes
│ │ │ ├── 00_overview.rst.txt
│ │ │ ├── 01_latest.rst.txt
│ │ │ ├── 02_archive.rst.txt
│ │ │ ├── 03_how_to_snippets.rst.txt
│ │ │ └── how_to_snippets
│ │ │ ├── create_categorical_meta.rst.txt
│ │ │ ├── derotate.rst.txt
│ │ │ └── dimensions_comp.rst.txt
│ │ ├── _static
│ │ ├── ajax-loader.gif
│ │ ├── basic.css
│ │ ├── comment-bright.png
│ │ ├── comment-close.png
│ │ ├── comment.png
│ │ ├── doctools.js
│ │ ├── down-pressed.png
│ │ ├── down.png
│ │ ├── file.png
│ │ ├── jquery.js
│ │ ├── logo.jpg
│ │ ├── logo_small.jpg
│ │ ├── minus.png
│ │ ├── plus.png
│ │ ├── pygments.css
│ │ ├── searchtools.js
│ │ ├── up-pressed.png
│ │ ├── up.png
│ │ └── websupport.js
│ │ ├── genindex.html
│ │ ├── index.html
│ │ ├── objects.inv
│ │ ├── search.html
│ │ ├── searchindex.js
│ │ └── sites
│ │ ├── api_ref
│ │ ├── 00overview.html
│ │ ├── Chain.html
│ │ ├── Cluster.html
│ │ ├── DataSet.html
│ │ ├── QuantipyViews.html
│ │ ├── Rim_scheme.html
│ │ ├── View.html
│ │ ├── ViewMapper.html
│ │ ├── quantify_engine.html
│ │ └── stack.html
│ │ ├── lib_doc
│ │ ├── batch
│ │ │ ├── 00_overview.html
│ │ │ ├── 01_create_load.html
│ │ │ ├── 02_variables.html
│ │ │ ├── 03_properties.html
│ │ │ └── 04_subclass.html
│ │ ├── builds
│ │ │ ├── 00_overview.html
│ │ │ └── 01_chains.html
│ │ ├── dataprocessing
│ │ │ ├── 00_overview.html
│ │ │ ├── 01_components.html
│ │ │ ├── 02_io.html
│ │ │ ├── 02a_management.html
│ │ │ ├── 03_inspection.html
│ │ │ ├── 04_editing.html
│ │ │ ├── 05_transforming.html
│ │ │ ├── 06_logics.html
│ │ │ └── 07_custom_recoding.html
│ │ ├── engine
│ │ │ ├── 00_overview.html
│ │ │ ├── 01_links_stacks.html
│ │ │ ├── 02_quantity.html
│ │ │ ├── 03_test.html
│ │ │ └── 04_agg_methods.html
│ │ └── overview.html
│ │ └── release_notes
│ │ ├── 00_overview.html
│ │ ├── 01_latest.html
│ │ ├── 02_archive.html
│ │ ├── 03_how_to_snippets.html
│ │ └── how_to_snippets
│ │ ├── create_categorical_meta.html
│ │ ├── derotate.html
│ │ └── dimensions_comp.html
│ ├── _static
│ ├── logo.jpg
│ └── logo_small.jpg
│ ├── conf.py
│ ├── index.rst
│ ├── logo.jpg
│ ├── logo.png
│ ├── logo_small.jpg
│ ├── make.bat
│ ├── qp_overview.html
│ ├── qp_overview.jpg
│ └── sites
│ ├── api_ref
│ ├── 00overview.rst
│ ├── Chain.rst
│ ├── Cluster.rst
│ ├── DataSet.rst
│ ├── QuantipyViews.rst
│ ├── Rim_scheme.rst
│ ├── View.rst
│ ├── ViewMapper.rst
│ ├── quantify_engine.rst
│ └── stack.rst
│ ├── lib_doc
│ ├── batch
│ │ ├── 00_overview.rst
│ │ ├── 01_create_load.rst
│ │ ├── 02_variables.rst
│ │ ├── 03_properties.rst
│ │ └── 04_subclass.rst
│ ├── builds
│ │ ├── 00_overview.rst
│ │ └── 01_chains.rst
│ ├── dataprocessing
│ │ ├── 00_overview.rst
│ │ ├── 01_components.rst
│ │ ├── 02_io.rst
│ │ ├── 02a_management.rst
│ │ ├── 03_inspection.rst
│ │ ├── 04_editing.rst
│ │ ├── 05_transforming.rst
│ │ ├── 06_logics.rst
│ │ └── 07_custom_recoding.rst
│ └── engine
│ │ ├── 00_overview.rst
│ │ ├── 01_links_stacks.rst
│ │ ├── 02_quantity.rst
│ │ ├── 03_test.rst
│ │ └── 04_agg_methods.rst
│ ├── release_notes
│ ├── 00_overview.rst
│ ├── 01_latest.rst
│ ├── 02_archive.rst
│ ├── 03_how_to_snippets.rst
│ └── how_to_snippets
│ │ ├── create_categorical_meta.rst
│ │ ├── derotate.rst
│ │ └── dimensions_comp.rst
│ ├── xlsx_output_annotations.JPG
│ ├── xlsx_output_groupedviews_simple.JPG
│ ├── xlsx_output_simple.JPG
│ └── xlsx_toc_simple_table.JPG
├── install_dev.sh
├── quantipy
├── __init__.py
├── core
│ ├── __init__.py
│ ├── batch.py
│ ├── builds
│ │ ├── __init__.py
│ │ ├── excel
│ │ │ ├── __init__.py
│ │ │ ├── excel_painter.py
│ │ │ └── formats
│ │ │ │ ├── __init__.py
│ │ │ │ ├── logo
│ │ │ │ └── qplogo_invert.png
│ │ │ │ └── xlsx_formats.py
│ │ └── powerpoint
│ │ │ ├── __init__.py
│ │ │ ├── add_shapes.py
│ │ │ ├── helpers.py
│ │ │ ├── pptx_painter.py
│ │ │ ├── templates
│ │ │ ├── __init__.py
│ │ │ └── default_template.pptx
│ │ │ ├── transformations.py
│ │ │ └── visual_editor.py
│ ├── cache.py
│ ├── chain.py
│ ├── cluster.py
│ ├── dataset.py
│ ├── helpers
│ │ ├── __init__.py
│ │ ├── constants.py
│ │ ├── functions.py
│ │ └── parrot.gif
│ ├── link.py
│ ├── options.py
│ ├── quantify
│ │ ├── __init__.py
│ │ └── engine.py
│ ├── rules.py
│ ├── srv
│ │ ├── __init__.py
│ │ ├── core.py
│ │ ├── handlers.py
│ │ ├── html_templates
│ │ │ └── webedit.html
│ │ ├── libs
│ │ │ └── jsoneditor
│ │ │ │ └── img
│ │ │ │ └── jsoneditor-icons.png
│ │ └── servers.py
│ ├── stack.py
│ ├── tools
│ │ ├── __init__.py
│ │ ├── audit.py
│ │ ├── dp
│ │ │ ├── __init__.py
│ │ │ ├── ascribe
│ │ │ │ ├── __init__.py
│ │ │ │ └── reader.py
│ │ │ ├── decipher
│ │ │ │ ├── __init__.py
│ │ │ │ └── reader.py
│ │ │ ├── dimensions
│ │ │ │ ├── __init__.py
│ │ │ │ ├── _create_ddf.dms
│ │ │ │ ├── dimlabels.py
│ │ │ │ ├── map_dim_qp_languages.xlsx
│ │ │ │ ├── reader.py
│ │ │ │ └── writer.py
│ │ │ ├── io.py
│ │ │ ├── prep.py
│ │ │ ├── query.py
│ │ │ └── spss
│ │ │ │ ├── __init__.py
│ │ │ │ ├── reader.py
│ │ │ │ └── writer.py
│ │ ├── qp_decorators.py
│ │ └── view
│ │ │ ├── __init__.py
│ │ │ ├── agg.py
│ │ │ ├── logic.py
│ │ │ ├── meta.py
│ │ │ ├── query.py
│ │ │ └── struct.py
│ ├── view.py
│ ├── view_generators
│ │ ├── __init__.py
│ │ ├── view_mapper.py
│ │ ├── view_maps.py
│ │ └── view_specs.py
│ └── weights
│ │ ├── __init__.py
│ │ ├── rim.py
│ │ └── weight_engine.py
├── sandbox
│ ├── __init__.py
│ ├── excel.py
│ ├── excel_formats.py
│ ├── excel_formats_constants.py
│ ├── pptx
│ │ ├── PptxChainClass.py
│ │ ├── PptxDefaultsClass.py
│ │ ├── PptxPainterClass.py
│ │ ├── __init__.py
│ │ ├── enumerations.py
│ │ └── pptx_defaults.py
│ └── sandbox.py
└── version.py
├── requirements.txt
├── requirements_dev.txt
├── savReaderWriter
├── COPYRIGHT
├── VERSION
├── __init__.py
├── cWriterow
│ ├── __init__.py
│ ├── cWriterow.c
│ ├── cWriterow.html
│ ├── cWriterow.pyx
│ ├── cWriterow.so
│ ├── readme.txt
│ └── setup.py
├── debug.py
├── documentation
│ ├── conf.py
│ ├── dates.xls
│ ├── formats.xls
│ ├── index.rst
│ ├── make.bat
│ └── platforms.xls
├── error.py
├── generic.py
├── header.py
├── py3k.py
├── savHeaderReader.py
├── savReader.py
├── savWriter.py
├── spssio
│ ├── documents
│ │ └── Input-Output Module.pdf
│ ├── include
│ │ ├── spssdio.h
│ │ └── spssdiocodes.h
│ ├── license
│ │ ├── LA_cs
│ │ ├── LA_de
│ │ ├── LA_el
│ │ ├── LA_en
│ │ ├── LA_es
│ │ ├── LA_fr
│ │ ├── LA_in
│ │ ├── LA_it
│ │ ├── LA_ja
│ │ ├── LA_ko
│ │ ├── LA_lt
│ │ ├── LA_pl
│ │ ├── LA_pt
│ │ ├── LA_ru
│ │ ├── LA_sl
│ │ ├── LA_tr
│ │ ├── LA_zh
│ │ ├── LA_zh_TW
│ │ └── notices
│ ├── lin64
│ │ ├── libicudata.so.48.1
│ │ ├── libicui18n.so.48.1
│ │ ├── libicuuc.so.48.1
│ │ ├── libspssdio.so.1
│ │ ├── libspssjdio.so.1
│ │ └── libzlib123spss.so
│ └── win64
│ │ ├── icudt48.dll
│ │ ├── icuin48.dll
│ │ ├── icuuc48.dll
│ │ ├── spssdio.vb
│ │ ├── spssio64.dll
│ │ ├── spssio64.lib
│ │ ├── spssjdio.dll
│ │ └── zlib123spss.dll
└── test_data
│ ├── spssio_test.pdf
│ ├── spssio_test.sps
│ ├── spssio_test.spv
│ └── zlib_compressed.zsav
├── setup.cfg
├── setup.py
└── tests
├── .project
├── .pydevproject
├── Example Data (A).csv
├── Example Data (A).json
├── ViewManager_expectations.py
├── __init__.py
├── basic.xlsx
├── complex_0.xlsx
├── complex_1.xlsx
├── complex_2.xlsx
├── complex_3.xlsx
├── engine_A_data.csv
├── engine_B_data.csv
├── engine_B_meta.json
├── example.csv
├── parameters_chain.py
├── parameters_excel.py
├── test_a.py
├── test_banked_chains.py
├── test_batch.py
├── test_chain.py
├── test_chain_old.py
├── test_cluster.py
├── test_complex_logic.py
├── test_dataset.py
├── test_excel.py
├── test_helper.py
├── test_io_dimensions.py
├── test_link.py
├── test_logic_views.py
├── test_merging.py
├── test_recode.py
├── test_rim.py
├── test_rules.py
├── test_stack.py
├── test_view.py
├── test_view_manager.py
├── test_view_mapper.py
├── test_view_maps.py
├── test_weight_engine.py
└── test_xlsx_formats.py
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | /tests/*.pyc
3 | /quantipy/*.pyc
4 | /tests/StackName.stack
5 | /tests/ChainName.chain
6 | /tests/ClusterName.cluster
7 | dist/
8 |
9 | .coverage
10 | htmlcov/
11 |
12 | 1.*.stack
13 | README.html
14 |
15 | *.sav
16 | run.py
17 |
18 | .DS_Store
19 | core/ExcelPainter_old.py
20 | core/ExcelPainter_old2.py
21 | core/ExcelPainter_latest.py
22 | qplogo_invert_lg.png
23 | temp.chain
24 | tests/Example Data (A).cache
25 | *.css
26 | *.ttf
27 | *.js
28 | *.eot
29 | *.svg
30 | *.woff
31 |
32 | *.js
33 |
34 | docs/API/_static/
35 | docs/API/_templates/
36 |
37 | *.egg-info
38 | *.egg
39 | .eggs/
40 | .cache
41 | .pytest_cache/*
42 | build
43 |
--------------------------------------------------------------------------------
/.pytest_cache/README.md:
--------------------------------------------------------------------------------
1 | # pytest cache directory #
2 |
3 | This directory contains data from the pytest's cache plugin,
4 | which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
5 |
6 | **Do not** commit this to version control.
7 |
8 | See [the docs](https://docs.pytest.org/en/latest/cache.html) for more information.
9 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 YouGov Plc
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | recursive-include savReaderWriter *
2 | recursive-include quantipy/core/tools/dp *
--------------------------------------------------------------------------------
/autotests.py:
--------------------------------------------------------------------------------
1 | import os
2 | import sys
3 | import time
4 | import logging
5 | from watchdog.observers import Observer
6 | from watchdog.events import FileSystemEventHandler
7 |
8 | """
9 | The autotests.py runs the tests if any files change in the ./core/ folder.
10 |
11 | CODE COVERAGE ::
12 | Code coverage can be run by using `coverage run -m unittest discover`
13 |
14 | CODE COVERAGE REPORTS ::
15 | To create html coverage reports use `coverage html`, that creates a folder
16 | named /htmlcov/. Open /htmlcov/index.html using a browser to view the report
17 |
18 | note :: the reports must be created after running the coverage
19 |
20 | CODE COVERAGE INSTALL ::
21 | `pip install coverage`
22 |
23 | """
24 |
25 | class TestHandler(FileSystemEventHandler):
26 | def on_modified(self, event):
27 | print "Changes detected..."
28 | print "Running tests..."
29 | os.system('python -m unittest discover')
30 | # os.system('coverage run -m unittest discover')
31 |
32 | if __name__ == "__main__":
33 | os.system('python -m unittest discover')
34 | path = sys.argv[1] if len(sys.argv) > 1 else './core/'
35 | event_handler = TestHandler()
36 | observer = Observer()
37 | observer.schedule(event_handler, path, recursive=True)
38 | observer.start()
39 | try:
40 | while True:
41 | time.sleep(1)
42 | except KeyboardInterrupt:
43 | observer.stop()
44 | observer.join()
45 |
--------------------------------------------------------------------------------
/docs/API/YG_logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/YG_logo.jpg
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/environment.pickle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/environment.pickle
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/index.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/index.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/api_ref/00overview.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/api_ref/00overview.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/api_ref/Chain.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/api_ref/Chain.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/api_ref/Cluster.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/api_ref/Cluster.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/api_ref/DataSet.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/api_ref/DataSet.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/api_ref/QuantipyViews.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/api_ref/QuantipyViews.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/api_ref/Rim_scheme.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/api_ref/Rim_scheme.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/api_ref/View.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/api_ref/View.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/api_ref/ViewMapper.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/api_ref/ViewMapper.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/api_ref/quantify_engine.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/api_ref/quantify_engine.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/api_ref/stack.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/api_ref/stack.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/batch/00_overview.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/batch/00_overview.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/batch/01_create_load.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/batch/01_create_load.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/batch/02_variables.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/batch/02_variables.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/batch/03_properties.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/batch/03_properties.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/batch/04_subclass.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/batch/04_subclass.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/builds/00_overview.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/builds/00_overview.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/builds/01_chains.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/builds/01_chains.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/00_overview.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/00_overview.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/01_components.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/01_components.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/02_io.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/02_io.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/02a_management.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/02a_management.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/03_inspection.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/03_inspection.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/04_editing.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/04_editing.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/05_transforming.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/05_transforming.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/06_logics.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/06_logics.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/07_custom_recoding.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/dataprocessing/07_custom_recoding.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/engine/00_overview.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/engine/00_overview.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/engine/01_links_stacks.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/engine/01_links_stacks.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/engine/02_quantity.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/engine/02_quantity.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/engine/03_test.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/engine/03_test.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/engine/04_agg_methods.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/engine/04_agg_methods.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/lib_doc/overview.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/lib_doc/overview.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/release_notes/00_overview.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/release_notes/00_overview.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/release_notes/01_latest.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/release_notes/01_latest.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/release_notes/02_archive.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/release_notes/02_archive.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/release_notes/03_how_to_snippets.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/release_notes/03_how_to_snippets.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/release_notes/how_to_snippets/create_categorical_meta.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/release_notes/how_to_snippets/create_categorical_meta.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/release_notes/how_to_snippets/derotate.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/release_notes/how_to_snippets/derotate.doctree
--------------------------------------------------------------------------------
/docs/API/_build/doctrees/sites/release_notes/how_to_snippets/dimensions_comp.doctree:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/doctrees/sites/release_notes/how_to_snippets/dimensions_comp.doctree
--------------------------------------------------------------------------------
/docs/API/_build/html/.buildinfo:
--------------------------------------------------------------------------------
1 | # Sphinx build info version 1
2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3 | config: 3c8d31b3ee2b61e092a93342a4c7e2d0
4 | tags: 645f666f9bcd5a90fca523b33c5a78b7
5 |
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/index.rst.txt:
--------------------------------------------------------------------------------
1 | .. Quantipy documentation master file, created by
2 | sphinx-quickstart on Wed May 20 09:00:43 2015.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | .. toctree::
7 | :maxdepth: 5
8 | :hidden:
9 |
10 | sites/release_notes/00_overview
11 | sites/lib_doc/dataprocessing/00_overview
12 | sites/lib_doc/batch/00_overview
13 | sites/lib_doc/engine/00_overview
14 | sites/lib_doc/builds/00_overview
15 | sites/api_ref/00overview
16 |
17 |
18 | """"
19 |
20 | Quantipy: Python survey data toolkit
21 | ====================================
22 | Quantipy is an open-source data processing, analysis and reporting software
23 | project that builds on the excellent `pandas `_
24 | and `numpy `_ libraries. Aimed at social and marketing research survey data, Quantipy offers support for native handling of special data types like multiple choice variables, statistical analysis using case or observation weights, dataset metadata and customizable reporting exports.
25 |
26 | """"
27 |
28 | .. note::
29 | We are currently moving our documentation and reorganizing it. Sorry for the
30 | lack of latest information.
31 |
32 | """"
33 |
34 | Key features
35 | """"""""""""
36 |
37 | * Reads plain .csv, converts from Dimensions, SPSS, Decipher, or Ascribe
38 | * Open metadata format to describe and manage datasets
39 | * Powerful, metadata-driven cleaning, editing, recoding and transformation of datasets
40 | * Computation and assessment of data weights
41 | * Easy-to-use analysis interface
42 | * Automated data aggregation using ``Batch`` defintions
43 | * Structured analysis and reporting via Chain and Cluster containers
44 | * Export to SPSS, Dimensions ddf/mdd, table spreadsheets and chart decks
45 |
46 | """"
47 |
48 | **Contributors**
49 | Kerstin Müller, Alexander Buchhammer, Alasdair Eaglestone, James Griffiths
50 |
51 | Birgir Hrafn Sigurðsson and Geir Freysson of `datasmoothie `_
52 |
53 | """"
54 |
55 | * :ref:`genindex`
56 | * :ref:`modindex`
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/api_ref/00overview.rst.txt:
--------------------------------------------------------------------------------
1 |
2 | API references
3 | ==============
4 |
5 | .. toctree::
6 | :maxdepth: 3
7 |
8 | Chain
9 | Cluster
10 | DataSet
11 | quantify_engine
12 | QuantipyViews
13 | Rim_scheme
14 | Stack
15 | View
16 | ViewMapper
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/api_ref/Chain.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | Chain
5 | =====
6 |
7 | .. autoclass:: quantipy.Chain
8 | :members:
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/api_ref/Cluster.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | Cluster
5 | =======
6 |
7 | .. autoclass:: quantipy.Cluster
8 | :members:
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/api_ref/DataSet.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | DataSet
5 | =======
6 |
7 | .. autoclass:: quantipy.DataSet
8 | :members:
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/api_ref/QuantipyViews.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | QuantipyViews
5 | =============
6 |
7 | .. autoclass:: quantipy.QuantipyViews
8 | :members:
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/api_ref/Rim_scheme.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | Rim
5 | ===
6 |
7 | .. autoclass:: quantipy.Rim
8 | :members:
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/api_ref/View.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | View
5 | ====
6 |
7 | .. autoclass:: quantipy.View
8 | :members:
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/api_ref/ViewMapper.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | ViewMapper
5 | ==========
6 |
7 | .. autoclass:: quantipy.ViewMapper
8 | :members:
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/api_ref/quantify_engine.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | quantify.engine
5 | ===============
6 |
7 | .. autoclass:: quantipy.Quantity
8 | :members:
9 | .. autoclass:: quantipy.Test
10 | :members:
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/api_ref/stack.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | Stack
5 | =====
6 |
7 | .. autoclass:: quantipy.Stack
8 | :members:
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/lib_doc/batch/00_overview.rst.txt:
--------------------------------------------------------------------------------
1 |
2 | =========
3 | ``Batch``
4 | =========
5 |
6 | ``qp.Batch`` is a subclass of ``qp.DataSet`` and is a container for
7 | structuring a ``qp.Link`` collection's specifications.
8 |
9 | ``qp.Batch`` is not only a subclass of ``qp.DataSet``, it also takes a
10 | DataSet instance as input argument, inheriting a few of its attributes, e.g.
11 | ``_meta``, ``_data``, ``valid_tks`` and ``text_key``.
12 | All other ``Batch`` attributes are used as construction plans for populating a
13 | ``qp.Stack``, these get stored in the belonging ``DataSet`` meta component in
14 | ``_meta['sets']['batches'][batchname]``.
15 |
16 | In general, it does not matter in which order ``Batch`` attributes are set by
17 | methods, the class ensures that all attributes are kept consistent.
18 |
19 | All next sections are working with the following ``qp.DataSet`` instance::
20 |
21 | import quantipy as qp
22 |
23 | dataset = qp.DataSet('Example Data (A)')
24 | dataset.read_quantipy('Example Data (A).json', 'Example Data (A).csv')
25 |
26 | The json and csv files you can find in ``quantipy/tests``.
27 |
28 | .. toctree::
29 | :maxdepth: 5
30 | :includehidden:
31 |
32 | 01_create_load
33 | 02_variables
34 | 03_properties
35 | 04_subclass
36 |
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/lib_doc/batch/01_create_load.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | =========================================
6 | Creating/ Loading a ``qp.Batch`` instance
7 | =========================================
8 |
9 | As mentioned, a ``Batch`` instance has a close connection to its belonging
10 | ``DataSet`` instance and we can easily create a new ``Batch`` from a ``DataSet``
11 | as per::
12 |
13 | batch1 = dataset.add_batch(name='batch1')
14 | batch2 = dataset.add_batch(name='batch2', ci=['c'], weights='weight')
15 |
16 | It is also possible to load an already existing instance out of the meta
17 | stored in ``dataset._meta['sets']['batches']``::
18 |
19 | batch = dataset.get_batch('batch1')
20 |
21 | Both methods, ``.add_batch()`` and ``.get_batch()``, are an easier way to
22 | use the ``__init__()`` method of ``qp.Batch``.
23 |
24 | An other way to get a new ``qp.Batch`` instance is to copy an existing one, in
25 | that case all added open ends are removed from the new instance::
26 |
27 | copy_batch = batch.copy('copy_of_batch1')
28 |
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/lib_doc/batch/02_variables.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | ===========================================
6 | Adding variables to a ``qp.Batch`` instance
7 | ===========================================
8 |
9 | -----------------
10 | x-keys and y-keys
11 | -----------------
12 |
13 | The included variables in a ``Batch`` constitute the main structure for the
14 | ``qp.Stack`` construction plan. Variables can be added as x-keys or y-keys, for
15 | arrays all belonging items are automatically added and the ``qp.Stack`` gets
16 | populated with all cross-tabulations of these keys:
17 |
18 | >>> batch.add_x(['q1', 'q2', 'q6'])
19 | >>> batch.add_y(['gender', 'q1'])
20 | Array summaries setup: Creating ['q6'].
21 |
22 | x-specific y-keys can be produced by manipulating the main y-keys, this edit
23 | can be extending or replacing the existing keys:
24 |
25 | >>> batch.extend_y(['locality', 'ethnicity'], on=['q1'])
26 | >>> batch.replace_y(['locality', 'ethnicity'], on=['q2'])
27 |
28 | With these settings the construction plan looks like that:
29 |
30 | >>> print batch.x_y_map
31 | OrderedDict([('q1', ['@', 'gender', 'q1', 'locality', 'ethnicity']),
32 | ('q2', ['locality', 'ethnicity']),
33 | ('q6', ['@']),
34 | (u'q6_1', ['@', 'gender', 'q1']),
35 | (u'q6_2', ['@', 'gender', 'q1']),
36 | (u'q6_3', ['@', 'gender', 'q1'])])
37 |
38 | ------
39 | Arrays
40 | ------
41 |
42 | A special case exists if the added variables contain arrays. As default for all
43 | arrays in x-keys array summaries are created (array as x-key and ``'@'``-referenced total as
44 | y-key), see the output below (``Array summaries setup: Creating ['q6'].``).
45 | If array summaries are requested only for a selection of variables or for none,
46 | use ``.make_summaries()``:
47 |
48 | >>> batch.make_summaries(None)
49 | Array summaries setup: Creating no summaries!
50 |
51 | Arrays can also be transposed (``'@'``-referenced total as x-key and array name
52 | as y-key). If they are not in the batch summary list before, they are
53 | automatically added and depending on the ``replace`` parameter only the
54 | transposed or both types of summaries are added to the ``qp.Stack``:
55 |
56 | >>> batch.transpose_array('q6', replace=False)
57 | Array summaries setup: Creating ['q6'].
58 |
59 | The construction plan now shows that both summary types are included:
60 |
61 | >>> print batch.x_y_map
62 | OrderedDict([('q1', ['@', 'gender', 'q1', 'locality', 'ethnicity']),
63 | ('q2', ['locality', 'ethnicity']),
64 | ('q6', ['@']),
65 | ('@', ['q6']),
66 | (u'q6_1', ['@', 'gender', 'q1']),
67 | (u'q6_2', ['@', 'gender', 'q1']),
68 | (u'q6_3', ['@', 'gender', 'q1'])])
69 |
70 | --------------------
71 | Verbatims/ open ends
72 | --------------------
73 |
74 | Another special case are verbatims. They will not be aggregated in a ``qp.Stack``,
75 | but they have to be defined in a ``qp.Batch`` to add them later to a ``qp.Cluster``.
76 |
77 | There are two different ways to add verbatims: Either all to one ``qp.Cluster``
78 | key or each gets its own key. But both options can be done with the same method.
79 |
80 | For splitting the verbatims, set ``split=True`` and insert as many titles as
81 | included verbatims/ open ends:
82 |
83 | >>> batch.add_open_ends(['q8a', 'q9a'], break_by=['record_number', 'age'],
84 | split=True, title=['oe_q8', 'oe_q9'])
85 |
86 | For collecting all verbatims in one Cluster key, set ``split=False`` and add
87 | only one ``title`` or use the default parameters:
88 |
89 | >>> batch.add_open_ends(['q8a', 'q9a'], break_by=['record_number', 'age'])
90 |
91 | --------------------
92 | Special aggregations
93 | --------------------
94 |
95 | It is possible to add some special aggregations to a ``qp.Batch``, that are
96 | not stored in the main construction plan ``.x_y_map``. One option is to give a
97 | name for a Cluster key in which all y-keys are cross-tabulated against each
98 | other:
99 |
100 | >>> batch.add_y_on_y('y-keys')
101 |
102 | Another possibility is to add a ``qp.Batch`` instance to an other instance.
103 | The added Batch loses all information about verbatims and ``.y_on_y``, that
104 | means only the main construction plan in ``.x_y_map`` gets adopted. Each of
105 | the two batches is aggregated discretely in the ``qp.Stack``, but the added
106 | instance gets included into the ``qp.Cluster`` of the first ``qp.Batch`` in
107 | a key named by its instance name.
108 |
109 | >>> batch1 = dataset.get_batch('batch1')
110 | >>> batch2 = dataset.get_batch('batch2')
111 | >>> batch2.add_x('q2b')
112 | Array summaries setup: Creating no summaries!
113 | >>> batch2.add_y('gender')
114 | >>> batch2.as_addition('batch1')
115 | Batch 'batch2' specified as addition to Batch 'batch1'. Any open end summaries and 'y_on_y' agg. have been removed!
116 |
117 | The connection between the two ``qp.Batch`` instances you can see in ``.additional``
118 | for the added instance and in ``._meta['sets']['batches']['batchname']['additions']``
119 | for the first instance.
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/lib_doc/batch/03_properties.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | ================================
6 | Set properties of a ``qp.Batch``
7 | ================================
8 |
9 | The section before explained how the main construction plan (``batch.x_y_map``)
10 | is built, that describes which x-keys and y-keys are used to add ``qp.Link``\s
11 | to a ``qp.Stack``. Now you will get to know how the missing information for the
12 | ``Link``\s are defined and which specific views get extracted for the
13 | ``qp.Cluster`` by adding some property options the ``qp.Batch`` instance.
14 |
15 | ----------------------------------------
16 | Filter, weights and significance testing
17 | ----------------------------------------
18 |
19 | ``qp.Link``\s can be added to a ``qp.Stack`` data_key-level by defining its x
20 | and y-keys, which is already done in ``.x_y_map``, and setting a filter.
21 | This property can be edited in a ``qp.Batch`` instance with the
22 | following methods:
23 |
24 | >>> batch.add_filter('men only', {'gender': 1})
25 | >>> batch.extend_filter({'q1': {'age': [20, 21, 22, 23, 24, 25]}})
26 |
27 | Filters can be added globally or for a selection of x-keys only. Out of the
28 | global filter, ``.sample_size`` is automatically calculated for each ``qp.Batch``
29 | defintion.
30 |
31 | Now all information are collected in the ``qp.Batch`` instance and the ``Stack``
32 | can be populated with ``Link``\s in form of ``stack[data_key][filter_key][x_key][y_key]``.
33 |
34 | For each ``Link`` ``qp.View``\s can be added, these views depend on a weight
35 | definition, which is also defined in the ``qp.Batch``:
36 |
37 | >>> batch.set_weights(['weight_a'])
38 |
39 | Significance tests are a special ``View``; the sig. levels which they are
40 | calculated on can be added to the ``qp.Batch`` like this:
41 |
42 | >>> batch.set_sigtests(levels=[0.05])
43 |
44 | -----------------------
45 | Cell items and language
46 | -----------------------
47 |
48 | As ``qp.Stack`` is a container for a large amount of aggregations, it will
49 | accommodate various ``qp.View``\s. The ``qp.Batch`` property ``.cell_items`` is
50 | used to define which specfic ``Views`` will be taken to create a ``qp.Cluster``:
51 |
52 | >>> batch.set_cell_items(['c', 'p'])
53 |
54 | The property ``.language`` allows the user to define which ``text`` labels from
55 | the meta data should be used for the extracted ``Views`` by entering a valid
56 | text key:
57 |
58 | >>> batch.set_language('en-GB')
59 |
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/lib_doc/batch/04_subclass.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | ================================
6 | Inherited ``qp.DataSet`` methods
7 | ================================
8 |
9 | Being a ``qp.DataSet`` subclasss, ``qp.Batch`` inherits some of its methods.
10 | The important ones are these which allow the manipulation of the meta component.
11 | That means meta-edits can be applied globally (run methods on ``qp.DataSet``) or
12 | ``Batch``-specific (run methods on ``qp.Batch``). Batch meta-edits
13 | always overwrite global meta-edits and while building a ``qp.Cluster`` from a
14 | ``qp.Batch``, the modified meta information is taken from ``.meta_edits``.
15 |
16 | The following methods can be used to create meta-edits for a ``qp.Batch``:
17 |
18 | >>> batch.hiding('q1', [2], axis='y')
19 | >>> batch.sorting('q2', fix=[97, 98])
20 | >>> batch.slicing('q1', [1, 2, 3, 4, 5], axis='x')
21 | >>> batch.set_variable_text('gender', 'Gender???')
22 | >>> batch.set_value_texts('gender', {1: 'Men', 2: 'Women'})
23 | >>> batch.set_property('q1', 'base_text', 'This var has a second filter.')
24 |
25 | Some methods are not allowed to be used for a ``Batch``. These will raise a
26 | ``NotImplementedError`` to prevent inconsistent case and meta data states.
27 |
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/lib_doc/builds/00_overview.rst.txt:
--------------------------------------------------------------------------------
1 | ======
2 | Builds
3 | ======
4 |
5 | .. toctree::
6 | :maxdepth: 5
7 | :includehidden:
8 |
9 | 01_chains
10 |
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/lib_doc/builds/01_chains.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | =================
6 | Combining results
7 | =================
8 |
9 | --------------------------------
10 | Organizing ``View`` aggregations
11 | --------------------------------
12 |
13 | -------------------------------
14 | Creating ``Chain`` aggregations
15 | -------------------------------
16 |
17 | What is a ``Chain``?
18 | --------------------
19 |
20 | Customizing results
21 | -------------------
22 |
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/00_overview.rst.txt:
--------------------------------------------------------------------------------
1 | ---------------
2 | Data processing
3 | ---------------
4 |
5 | .. toctree::
6 | :maxdepth: 5
7 | :includehidden:
8 |
9 | 01_components
10 | 02_io
11 | 02a_management
12 | 03_inspection
13 | 04_editing
14 | 05_transforming
15 | 06_logics
16 | 07_custom_recoding
17 |
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/02a_management.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | ==================
6 | DataSet management
7 | ==================
8 |
9 | --------------------------
10 | Setting the variable order
11 | --------------------------
12 | The global variable order of a ``DataSet`` is dictated by the content of the
13 | ``meta['sets']['data file']['items']`` list and reflected in the structure of
14 | the case data component's ``pd.DataFrame.columns``. There are two ways to set
15 | a new order using the ``order(new_order=None, reposition=None)`` method:
16 |
17 | **Define a full order**
18 |
19 | Using this apporach requires that all ``DataSet`` variable names are passed
20 | via the ``new_order`` parameter. Providing only a subset of the variables will
21 | raise a ``ValueError``:
22 |
23 | >>> dataset.order(['q1', 'q8'])
24 | ValueError: 'new_order' must contain all DataSet variables.
25 |
26 | Text...
27 |
28 | **Change positions relatively**
29 |
30 | Often only a few changes to the natural order of the ``DataSet`` are necessary,
31 | e.g. derived variables should be moved alongside their originating ones or specific
32 | sets of variables (demographics, etc.) should be grouped together. We can achieve
33 | this using the ``reposition`` parameter as follows:
34 |
35 | Text...
36 |
37 | ---------------------------------
38 | Cloning, filtering and subsetting
39 | ---------------------------------
40 |
41 | 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.
42 | a specific part of the questionnaire). To not permanently change an existing
43 | ``DataSet`` by accident, draw a copy of it first:
44 |
45 | >>> copy_ds = dataset.clone()
46 |
47 | Then you can use ``filter()`` to restrict cases (rows) or ``subset()`` to keep
48 | only a selected range of variables (columns). Both methods can be used inplace
49 | but will return a new object by default.
50 |
51 | >>> keep = {'Wave': [1]}
52 | >>> copy_ds.filter(alias='first wave', condition=keep, inplace=True)
53 | >>> copy_ds._data.shape
54 | (1621, 76)
55 |
56 | 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
57 | to describe the arbitrarily complex filter ``condition``) is attached to the
58 | instance:
59 |
60 | >>> copy_ds.filtered
61 | only first wave
62 |
63 | We are now further reducing the ``DataSet`` by dropping all variables except the three ``array`` variables ``'q5'``, ``'q6'``, and ``'q7'`` using ``subset()``.
64 |
65 | >>> reduced_ds = copy_ds.subset(variables=['q5', 'q6', 'q7'])
66 |
67 | We can see that only the requested variables (``masks`` defintitions and the
68 | constructing ``array`` items) remain in ``reduced_ds``:
69 |
70 | >>> reduced_ds.by_type()
71 | size: 1621 single delimited set array int float string date time N/A
72 | 0 q5_1 q5
73 | 1 q5_2 q7
74 | 2 q5_3 q6
75 | 3 q5_4
76 | 4 q5_5
77 | 5 q5_6
78 | 6 q6_1
79 | 7 q6_2
80 | 8 q6_3
81 | 9 q7_1
82 | 10 q7_2
83 | 11 q7_3
84 | 12 q7_4
85 | 13 q7_5
86 | 14 q7_6
87 |
88 | -------
89 | Merging
90 | -------
91 |
92 | Intro text... As opposed to reducing an existing file...
93 |
94 | Vertical (cases/rows) merging
95 | -----------------------------
96 |
97 | Text
98 |
99 | Horizontal (variables/columns) merging
100 | --------------------------------------
101 |
102 | Text
103 |
104 | -----------------------------
105 | Savepoints and state rollback
106 | -----------------------------
107 |
108 | When working with big ``DataSet``\s and needing to perform a lot of data
109 | preparation (deriving large amounts of new variables, lots of meta editing,
110 | complex cleaning, ...) it can be beneficial to quickly store a snapshot of a
111 | clean and consistent state of the ``DataSet``. This is most useful when working
112 | in interactive sessions like **IPython** or **Jupyter notebooks** and might
113 | prevent you from reloading files from disk or waiting for previous processes
114 | to finish.
115 |
116 | Savepoints are stored via ``save()`` and can be restored via ``revert()``.
117 |
118 | .. note::
119 | Savepoints only exists in memory and are not written to disk. Only one
120 | savepoint can exist, so repeated ``save()`` calls will overwrite any previous
121 | versions of the ``DataSet``. To permanently save your data, please use one
122 | of the ``write`` methods, e.g. ``write_quantipy()``.
123 |
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/lib_doc/dataprocessing/06_logics.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | =======================
6 | Logic and set operaters
7 | =======================
8 |
9 | ------
10 | Ranges
11 | ------
12 | The ``frange()`` function takes a string of abbreviated ranges, possibly delimited
13 | by a comma (or some other character) and extrapolates its full,
14 | unabbreviated list of ints.
15 |
16 | >>> from quantipy.core.tools.dp.prep import frange
17 |
18 | **Basic range**:
19 |
20 | >>> frange('1-5')
21 | [1, 2, 3, 4, 5]
22 |
23 | **Range in reverse**:
24 |
25 | >>> frange('15-11')
26 | [15, 14, 13, 12, 11]
27 |
28 | **Combination**:
29 |
30 | >>> frange('1-5,7,9,15-11')
31 | [1, 2, 3, 4, 5, 7, 9, 15, 14, 13, 12, 11]
32 |
33 | **May include spaces for clarity**:
34 |
35 | >>> frange('1-5, 7, 9, 15-11')
36 | [1, 2, 3, 4, 5, 7, 9, 15, 14, 13, 12, 11]
37 |
38 | -------------
39 | Complex logic
40 | -------------
41 | Multiple conditions can be combined using ``union`` or ``intersection`` set
42 | statements. Logical mappers can be arbitrarily nested as long as they are
43 | well-formed.
44 |
45 | ``union``
46 | ---------
47 | ``union`` takes a list of logical conditions that will be treated with
48 | **or** logic.
49 |
50 | Where **any** of logic_A, logic_B **or** logic_C are ``True``:
51 |
52 | >>> union([logic_A, logic_B, logic_C])
53 |
54 | ``intersection``
55 | ----------------
56 | ``intersection`` takes a list of conditions that will be
57 | treated with **and** logic.
58 |
59 | Where **all** of logic_A, logic_B **and** logic_C are ``True``:
60 |
61 | >>> intersection([logic_A, logic_B, logic_C])
62 |
63 | "List" logic
64 | ------------
65 | Instead of using the verbose ``has_any`` operator, we can express simple, non-nested
66 | *or* logics simply as a list of codes. For example ``{"q1_1": [1, 2]}`` is an
67 | example of list-logic, where ``[1, 2]`` will be interpreted as ``has_any([1, 2])``,
68 | meaning if **q1_1** has any of the values **1** or **2**.
69 |
70 | ``q1_1`` has any of the responses 1, 2 or 3:
71 |
72 | >>> l = {"q1_1": [1, 2, 3]}
73 |
74 |
75 | ``has_any``
76 | -----------
77 | ``q1_1`` has any of the responses 1, 2 or 3:
78 |
79 | >>> l = {"q1_1": has_any([1, 2, 3])}
80 |
81 | ``q1_1`` has any of the responses 1, 2 or 3 and no others:
82 |
83 | >>> l = {"q1_1": has_any([1, 2, 3], exclusive=True)}
84 |
85 |
86 | ``not_any``
87 | -----------
88 | ``q1_1`` doesn't have any of the responses 1, 2 or 3:
89 |
90 | >>> l = {"q1_1": not_any([1, 2, 3])}
91 |
92 | ``q1_1`` doesn't have any of the responses 1, 2 or 3 but has some others:
93 |
94 | >>> l = {"q1_1": not_any([1, 2, 3], exclusive=True)}
95 |
96 | ``has_all``
97 | -----------
98 | ``q1_1`` has all of the responses 1, 2 and 3:
99 |
100 | >>> l = {"q1_1": has_all([1, 2, 3])}
101 |
102 | ``q1_1`` has all of the responses 1, 2 and 3 and no others:
103 |
104 | >>> l = {"q1_1": has_all([1, 2, 3], exclusive=True)}
105 |
106 | ``not_all``
107 | -----------
108 | ``q1_1`` doesn't have all of the responses 1, 2 and 3:
109 |
110 | >>> l = {"q1_1": not_all([1, 2, 3])}
111 |
112 | ``q1_1`` doesn't have all of the responses 1, 2 and 3 but has some others:
113 |
114 | >>> l = {"q1_1": not_all([1, 2, 3], exclusive=True)}
115 |
116 | ``has_count``
117 | -------------
118 |
119 | ``q1_1`` has exactly 2 responses:
120 |
121 | >>> l = {"q1_1": has_count(2)}
122 |
123 | ``q1_1`` has 1, 2 or 3 responses:
124 |
125 | >>> l = {"q1_1": has_count([1, 3])}
126 |
127 | ``q1_1`` has 1 or more responses:
128 |
129 | >>> l = {"q1_1": has_count([is_ge(1)])}
130 |
131 | ``q1_1`` has 1, 2 or 3 responses from the response group 5, 6, 7, 8 or 9:
132 |
133 | >>> l = {"q1_1": has_count([1, 3, [5, 6, 7, 8, 9]])}
134 |
135 | ``q1_1`` has 1 or more responses from the response group 5, 6, 7, 8 or 9:
136 |
137 | >>> l = {"q1_1": has_count([is_ge(1), [5, 6, 7, 8, 9]])}
138 |
139 | ``not_count``
140 | -------------
141 | ``q1_1`` doesn't have exactly 2 responses:
142 |
143 | >>> l = {"q1_1": not_count(2)}
144 |
145 | ``q1_1`` doesn't have 1, 2 or 3 responses:
146 |
147 | >>> l = {"q1_1": not_count([1, 3])}
148 |
149 | ``q1_1`` doesn't have 1 or more responses:
150 |
151 | >>> l = {"q1_1": not_count([is_ge(1)])}
152 |
153 | ``q1_1`` doesn't have 1, 2 or 3 responses from the response group 5, 6, 7, 8 or 9:
154 |
155 | >>> l = {"q1_1": not_count([1, 3, [5, 6, 7, 8, 9]])}
156 |
157 | ``q1_1`` doesn't have 1 or more responses from the response group 5, 6, 7, 8 or 9:
158 |
159 | >>> l = {"q1_1": not_count([is_ge(1), [5, 6, 7, 8, 9]])}
160 |
161 | ----------------------------------
162 | Boolean slicers and code existence
163 | ----------------------------------
164 | ``any()``, ``all()``
165 | ``code_count()``, ``is_nan()``
166 |
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/lib_doc/engine/00_overview.rst.txt:
--------------------------------------------------------------------------------
1 | ----------------------
2 | Analysis & aggregation
3 | ----------------------
4 |
5 | .. toctree::
6 | :maxdepth: 5
7 | :includehidden:
8 |
9 | 01_links_stacks
10 | 02_quantity
11 | 03_test
12 | 04_agg_methods
13 |
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/lib_doc/engine/02_quantity.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | ========================
6 | The computational engine
7 | ========================
8 |
9 |
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/lib_doc/engine/03_test.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | ====================
6 | Significance testing
7 | ====================
8 |
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/lib_doc/overview.rst.txt:
--------------------------------------------------------------------------------
1 | =============
2 | Documentation
3 | =============
4 |
5 | .. toctree::
6 | :maxdepth: 5
7 | :hidden:
8 |
9 | dataprocessing/00_overview
10 | batch/00_overview
11 | engine/00_overview
12 | builds/00_overview
13 |
14 |
15 |
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/release_notes/00_overview.rst.txt:
--------------------------------------------------------------------------------
1 | -------------
2 | Release notes
3 | -------------
4 |
5 | .. toctree::
6 | :maxdepth: 5
7 | :includehidden:
8 |
9 | 01_latest
10 | 02_archive
11 |
12 |
13 | .. toctree::
14 | :maxdepth: 5
15 | :hidden:
16 |
17 | 03_how_to_snippets
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/release_notes/01_latest.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | ===================
6 | Latest (01/10/2018)
7 | ===================
8 |
9 | **New**: "rewrite" of Rules module (affecting sorting):
10 |
11 | **sorting "normal" columns**:
12 |
13 | * ``sort_on`` always '@'
14 | * ``fix`` any categories
15 | * ``sort_by_weight`` default is unweighted (None), but each weight (included
16 | in data) can be used
17 |
18 | If sort_by_weight and the view-weight differ, a warning is shown.
19 |
20 | **sorting "expanded net" columns**:
21 |
22 | * ``sort_on`` always '@'
23 | * ``fix`` any categories
24 | * sorting ``within`` or ``between`` net groups is available
25 | * ``sort_by_weight``: as default the weight of the first found
26 | expanded-net-view is taken. Only weights of aggregated net-views are possible
27 |
28 | **sorting "array summaries"**:
29 |
30 | * ``sort_on`` can be any desc ('median', 'stddev', 'sem', 'max', 'min',
31 | 'mean', 'upper_q', 'lower_q') or nets ('net_1', 'net_2', .... enumerated
32 | by the net_def)
33 | * ``sort_by_weight``: as default the weight of the first found desc/net-view
34 | is taken. Only weights of aggregated desc/net-views are possible
35 | * ``sort_on`` can also be any category, here each weight can be used to sort_on
36 |
37 | """"
38 |
39 | **New**: ``DataSet.min_value_count()``
40 |
41 | A new wrapper for ``DataSet.hiding()`` is included. All values are hidden,
42 | that have less counts than the included number ``min``.
43 | The used data can be weighted or filtered using the parameters ``weight`` and
44 | ``condition``.
45 |
46 | Usage as Batch method:
47 | ``Batch.min_value_count()`` without the parameters ``weight`` and
48 | ``condition`` automatically grabs ``Batch.weights[0]`` and ``Batch.filter``
49 | to calculate low value counts.
50 |
51 | """"
52 |
53 | **New**: Prevent weak duplicated in data
54 |
55 | As Python is case sensitive it is possible to have two or more variables with
56 | the same name, but in lower- and uppercases. Most other software do not support
57 | that, so a warning is shown if a weak dupe is created. Additionally
58 | ``Dataset.write_dimensions()`` performs auto-renaming is weak dupes are detected.
59 |
60 | """"
61 |
62 | **New**: Prevent single-cat delimited sets
63 |
64 | ``DataSet.add_meta(..., qtype='delimited set', categories=[...], ...)``
65 | automatically switches ``qtype`` to single if only one category is defined.
66 | ``DataSet.convert(name, 'single')`` allows conversion from ``delimited set`` to
67 | ``single`` if the variable has only one category.
68 | ``DataSet.repair()`` and ``DataSt.remove_values()`` convert delimited sets
69 | automatically to singles if only one category is included.
70 |
71 | """"
72 |
73 | **Update**: merge warnings + merging delimites sets
74 |
75 | Warnings in ``hmerge()`` and ``vmerge()`` are updated. If a column exists in
76 | the left and the right dataset, the type is compared. Some type inconsistencies
77 | are allowed, but return a warning, while others end up in a raise.
78 |
79 | delimited sets in ``vmerge()``:
80 |
81 | If a column is a delimited set in the left dataset, but a single, int or float
82 | in the right dataset, the data of the right column is converted into a delimited
83 | set.
84 |
85 | delimited sets in ``hmerge(...merge_existing=None)``:
86 |
87 | For the hmerge a new parameter ``merge_existing`` is included, which can be
88 | ``None``, a list of variable-names or ``'all'``.
89 |
90 | If delimited sets are included in left and right dataset:
91 |
92 | * ``merge_existing=None``: Only meta is adjusted. Data is untouched (left data
93 | is taken).
94 | * ``merge_existing='all'``: Meta and data are merged for all delimited sets,
95 | that are included in both datasets.
96 | * ``merge_existing=[variable-names]``: Meta and data are merged for all
97 | delimited sets, that are listed and included in both datasets.
98 |
99 | """"
100 |
101 | **Update**: encoding in ``DataSet.get_batch(name)``
102 |
103 | The method is not that encoding sensitive anymore. It returns the depending
104 | ``Batch``, no matter if ``'...'``, ``u'...'`` or ``'...'.decode('utf8')`` is
105 | included as name.
106 |
107 | """"
108 |
109 | **Update**: warning in weight engine
110 |
111 | Missing codes in the sample are only alerted, if the belonging target is not 0.
112 |
113 | """"
114 |
115 | **Update**: ``DataSet.to_array(..., variables, ...)``
116 |
117 | Duplicated vars in ``variables`` are not allowed anymore, these were causing
118 | problems in the ChainManager class.
119 |
120 | """"
121 |
122 | **Update**: ``Batch.add_open_ends()``
123 |
124 | Method raises an error if no vars are included in ``oe`` and ``break_by``. The
125 | empty dataframe was causing issues in the ChainManager class.
126 |
127 | """"
128 |
129 | **Update**: ``Batch.extend_x()``
130 |
131 | The method automatically checks if the included variables are arrays and adds
132 | them to ``Batch.summaries`` if they are included yet.
133 |
134 | """"
135 |
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/release_notes/03_how_to_snippets.rst.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 | ===============
4 | How-to-snippets
5 | ===============
6 |
7 | .. toctree::
8 | :maxdepth: 5
9 |
10 | how_to_snippets/dimensions_comp
11 | how_to_snippets/create_categorical_meta
12 | how_to_snippets/derotate
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/release_notes/how_to_snippets/create_categorical_meta.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :hidden:
4 |
5 | =============================================
6 | Different ways of creating categorical values
7 | =============================================
8 |
9 | The ``DataSet`` methods ``add_meta()``, ``extend_values()`` and ``derive()``
10 | offer three alternatives for specifying the categorical values of ``'single'``
11 | and ``'delimited set'`` typed variables. The approaches differ with respect to
12 | how the mapping of numerical value codes to value text labels is handled.
13 |
14 | **(1) Providing a list of text labels**
15 |
16 | By providing the category labels only as a list of ``str``, ``DataSet``
17 | is going to create the numerical codes by simple enumeration:
18 |
19 | >>> name, qtype, label = 'test_var', 'single', 'The test variable label'
20 |
21 | >>> cats = ['test_cat_1', 'test_cat_2', 'test_cat_3']
22 | >>> dataset.add_meta(name, qtype, label, cats)
23 |
24 | >>> dataset.meta('test_var')
25 | single codes texts missing
26 | test_var: The test variable label
27 | 1 1 test_cat_1 None
28 | 2 2 test_cat_2 None
29 | 3 3 test_cat_3 None
30 |
31 | **(2) Providing a list of numerical codes**
32 |
33 | If only the desired numerical codes are provided, the label information for all
34 | categories consequently will appear blank. In such a case the user will, however,
35 | get reminded to add the ``'text'`` meta in a separate step:
36 |
37 | >>> cats = [1, 2, 98]
38 | >>> dataset.add_meta(name, qtype, label, cats)
39 | ...\\quantipy\core\dataset.py:1287: UserWarning: 'text' label information missing,
40 | only numerical codes created for the values object. Remember to add value 'text' metadata manually!
41 |
42 | >>> dataset.meta('test_var')
43 | single codes texts missing
44 | test_var: The test variable label
45 | 1 1 None
46 | 2 2 None
47 | 3 98 None
48 |
49 | **(3) Pairing numerical codes with text labels**
50 |
51 | To explicitly assign codes to corresponding labels, categories can also be
52 | defined as a list of tuples of codes and labels:
53 |
54 | >>> cats = [(1, 'test_cat_1') (2, 'test_cat_2'), (98, 'Don\'t know')]
55 | >>> dataset.add_meta(name, qtype, label, cats)
56 |
57 | >>> dataset.meta('test_var')
58 | single codes texts missing
59 | test_var: The test variable label
60 | 1 1 test_cat_1 None
61 | 2 2 test_cat_2 None
62 | 3 98 Don't know None
63 |
64 | .. note::
65 | All three approaches are also valid for defining the ``items`` object for
66 | ``array``-typed ``masks``.
--------------------------------------------------------------------------------
/docs/API/_build/html/_sources/sites/release_notes/how_to_snippets/dimensions_comp.rst.txt:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :hidden:
4 |
5 | ====================================
6 | ``DataSet`` Dimensions compatibility
7 | ====================================
8 |
9 | DTO-downloaded and Dimensions converted variable naming conventions are following
10 | specific rules for ``array`` names and corresponding ``ìtems``. ``DataSet``
11 | offers a compatibility mode for Dimensions scenarios and handles the proper
12 | renaming automatically. Here is what you should know...
13 |
14 | ----------------------
15 | The compatibility mode
16 | ----------------------
17 |
18 | A ``DataSet`` will (by default) support Dimensions-like ``array`` naming for its connected data files when constructed. An ``array`` ``masks`` meta defintition
19 | of a variable called ``q5`` looking like this...::
20 |
21 | {u'items': [{u'source': u'columns@q5_1', u'text': {u'en-GB': u'Surfing'}},
22 | {u'source': u'columns@q5_2', u'text': {u'en-GB': u'Snowboarding'}},
23 | {u'source': u'columns@q5_3', u'text': {u'en-GB': u'Kite boarding'}},
24 | {u'source': u'columns@q5_4', u'text': {u'en-GB': u'Parachuting'}},
25 | {u'source': u'columns@q5_5', u'text': {u'en-GB': u'Cave diving'}},
26 | {u'source': u'columns@q5_6', u'text': {u'en-GB': u'Windsurfing'}}],
27 | u'subtype': u'single',
28 | u'text': {u'en-GB': u'How likely are you to do each of the following in the next year?'},
29 | u'type': u'array',
30 | u'values': u'lib@values@q5'}
31 |
32 | ...will be converted into its "Dimensions equivalent" as per:
33 |
34 | >>> dataset = qp.DataSet(name_data, dimensions_comp=True)
35 | >>> dataset.read_quantipy(path_data+name_data, path_data+name_data)
36 | DataSet: ../Data/Quantipy/Example Data (A)
37 | rows: 8255 - columns: 75
38 | Dimensions compatibilty mode: True
39 |
40 | >>> dataset.masks()
41 | ['q5.q5_grid', 'q6.q6_grid', 'q7.q7_grid']
42 |
43 | >>> dataset._meta['masks']['q5.q5_grid']
44 | {u'items': [{u'source': 'columns@q5[{q5_1}].q5_grid',
45 | u'text': {u'en-GB': u'Surfing'}},
46 | {u'source': 'columns@q5[{q5_2}].q5_grid',
47 | u'text': {u'en-GB': u'Snowboarding'}},
48 | {u'source': 'columns@q5[{q5_3}].q5_grid',
49 | u'text': {u'en-GB': u'Kite boarding'}},
50 | {u'source': 'columns@q5[{q5_4}].q5_grid',
51 | u'text': {u'en-GB': u'Parachuting'}},
52 | {u'source': 'columns@q5[{q5_5}].q5_grid',
53 | u'text': {u'en-GB': u'Cave diving'}},
54 | {u'source': 'columns@q5[{q5_6}].q5_grid',
55 | u'text': {u'en-GB': u'Windsurfing'}}],
56 | 'name': 'q5.q5_grid',
57 | u'subtype': u'single',
58 | u'text': {u'en-GB': u'How likely are you to do each of the following in the next year?'},
59 | u'type': u'array',
60 | u'values': 'lib@values@q5.q5_grid'}
61 |
62 | -------------------------------------
63 | Accessing and creating ``array`` data
64 | -------------------------------------
65 |
66 | Since new names are converted automatically by ``DataSet`` methods, there is
67 | no need to write down the full (DTO-like) Dimensions ``array`` name when adding
68 | new metadata. However, querying variables is always requiring the proper name:
69 |
70 | >>> name, qtype, label = 'array_var', 'single', 'ARRAY LABEL'
71 | >>> cats = ['A', 'B', 'C']
72 | >>> items = ['1', '2', '3']
73 | >>> dataset.add_meta(name, qtype, label, cats, items)
74 |
75 | >>> dataset.masks()
76 | ['q5.q5_grid', 'array_var.array_var_grid', 'q6.q6_grid', 'q7.q7_grid']
77 |
78 | >>> dataset.meta('array_var.array_var_grid')
79 | single items item texts codes texts missing
80 | array_var.array_var_grid: ARRAY LABEL
81 | 1 array_var[{array_var_1}].array_var_grid 1 1 A None
82 | 2 array_var[{array_var_2}].array_var_grid 2 2 B None
83 | 3 array_var[{array_var_3}].array_var_grid 3 3 C None
84 |
85 | >>> dataset['array_var.array_var_grid'].head(5)
86 | array_var[{array_var_1}].array_var_grid array_var[{array_var_2}].array_var_grid array_var[{array_var_3}].array_var_grid
87 | 0 NaN NaN NaN
88 | 1 NaN NaN NaN
89 | 2 NaN NaN NaN
90 | 3 NaN NaN NaN
91 | 4 NaN NaN NaN
92 |
93 | As can been seen above, both the ``masks`` name as well as the ``array`` item
94 | elements are being properly converted to match DTO/Dimensions
95 | conventions.
96 |
97 | When using ``rename()``, ``copy()`` or ``transpose()``, the same behaviour
98 | applies:
99 |
100 | >>> dataset.rename('q6.q6_grid', 'q6new')
101 | >>> dataset.masks()
102 | ['q5.q5_grid', 'array_var.array_var_grid', 'q6new.q6new_grid', 'q7.q7_grid']
103 |
104 | >>> dataset.copy('q6new.q6new_grid', suffix='q6copy')
105 | >>> dataset.masks()
106 | ['q5.q5_grid', 'q6new_q6copy.q6new_q6copy_grid', 'array_var.array_var_grid', 'q6new.q6new_grid', 'q7.q7_grid']
107 |
108 | >>> dataset.transpose('q6new_q6copy.q6new_q6copy_grid')
109 | >>> dataset.masks()
110 | ['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']
--------------------------------------------------------------------------------
/docs/API/_build/html/_static/ajax-loader.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/html/_static/ajax-loader.gif
--------------------------------------------------------------------------------
/docs/API/_build/html/_static/comment-bright.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/html/_static/comment-bright.png
--------------------------------------------------------------------------------
/docs/API/_build/html/_static/comment-close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/html/_static/comment-close.png
--------------------------------------------------------------------------------
/docs/API/_build/html/_static/comment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/html/_static/comment.png
--------------------------------------------------------------------------------
/docs/API/_build/html/_static/down-pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/html/_static/down-pressed.png
--------------------------------------------------------------------------------
/docs/API/_build/html/_static/down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/html/_static/down.png
--------------------------------------------------------------------------------
/docs/API/_build/html/_static/file.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/html/_static/file.png
--------------------------------------------------------------------------------
/docs/API/_build/html/_static/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/html/_static/logo.jpg
--------------------------------------------------------------------------------
/docs/API/_build/html/_static/logo_small.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/html/_static/logo_small.jpg
--------------------------------------------------------------------------------
/docs/API/_build/html/_static/minus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/html/_static/minus.png
--------------------------------------------------------------------------------
/docs/API/_build/html/_static/plus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/html/_static/plus.png
--------------------------------------------------------------------------------
/docs/API/_build/html/_static/pygments.css:
--------------------------------------------------------------------------------
1 | .highlight .hll { background-color: #ffffcc }
2 | .highlight { background: #eeffcc; }
3 | .highlight .c { color: #408090; font-style: italic } /* Comment */
4 | .highlight .err { border: 1px solid #FF0000 } /* Error */
5 | .highlight .k { color: #007020; font-weight: bold } /* Keyword */
6 | .highlight .o { color: #666666 } /* Operator */
7 | .highlight .ch { color: #408090; font-style: italic } /* Comment.Hashbang */
8 | .highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */
9 | .highlight .cp { color: #007020 } /* Comment.Preproc */
10 | .highlight .cpf { color: #408090; font-style: italic } /* Comment.PreprocFile */
11 | .highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */
12 | .highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
13 | .highlight .gd { color: #A00000 } /* Generic.Deleted */
14 | .highlight .ge { font-style: italic } /* Generic.Emph */
15 | .highlight .gr { color: #FF0000 } /* Generic.Error */
16 | .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
17 | .highlight .gi { color: #00A000 } /* Generic.Inserted */
18 | .highlight .go { color: #333333 } /* Generic.Output */
19 | .highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
20 | .highlight .gs { font-weight: bold } /* Generic.Strong */
21 | .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
22 | .highlight .gt { color: #0044DD } /* Generic.Traceback */
23 | .highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
24 | .highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
25 | .highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
26 | .highlight .kp { color: #007020 } /* Keyword.Pseudo */
27 | .highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
28 | .highlight .kt { color: #902000 } /* Keyword.Type */
29 | .highlight .m { color: #208050 } /* Literal.Number */
30 | .highlight .s { color: #4070a0 } /* Literal.String */
31 | .highlight .na { color: #4070a0 } /* Name.Attribute */
32 | .highlight .nb { color: #007020 } /* Name.Builtin */
33 | .highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
34 | .highlight .no { color: #60add5 } /* Name.Constant */
35 | .highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */
36 | .highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */
37 | .highlight .ne { color: #007020 } /* Name.Exception */
38 | .highlight .nf { color: #06287e } /* Name.Function */
39 | .highlight .nl { color: #002070; font-weight: bold } /* Name.Label */
40 | .highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
41 | .highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */
42 | .highlight .nv { color: #bb60d5 } /* Name.Variable */
43 | .highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */
44 | .highlight .w { color: #bbbbbb } /* Text.Whitespace */
45 | .highlight .mb { color: #208050 } /* Literal.Number.Bin */
46 | .highlight .mf { color: #208050 } /* Literal.Number.Float */
47 | .highlight .mh { color: #208050 } /* Literal.Number.Hex */
48 | .highlight .mi { color: #208050 } /* Literal.Number.Integer */
49 | .highlight .mo { color: #208050 } /* Literal.Number.Oct */
50 | .highlight .sa { color: #4070a0 } /* Literal.String.Affix */
51 | .highlight .sb { color: #4070a0 } /* Literal.String.Backtick */
52 | .highlight .sc { color: #4070a0 } /* Literal.String.Char */
53 | .highlight .dl { color: #4070a0 } /* Literal.String.Delimiter */
54 | .highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
55 | .highlight .s2 { color: #4070a0 } /* Literal.String.Double */
56 | .highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
57 | .highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */
58 | .highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
59 | .highlight .sx { color: #c65d09 } /* Literal.String.Other */
60 | .highlight .sr { color: #235388 } /* Literal.String.Regex */
61 | .highlight .s1 { color: #4070a0 } /* Literal.String.Single */
62 | .highlight .ss { color: #517918 } /* Literal.String.Symbol */
63 | .highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */
64 | .highlight .fm { color: #06287e } /* Name.Function.Magic */
65 | .highlight .vc { color: #bb60d5 } /* Name.Variable.Class */
66 | .highlight .vg { color: #bb60d5 } /* Name.Variable.Global */
67 | .highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */
68 | .highlight .vm { color: #bb60d5 } /* Name.Variable.Magic */
69 | .highlight .il { color: #208050 } /* Literal.Number.Integer.Long */
--------------------------------------------------------------------------------
/docs/API/_build/html/_static/up-pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/html/_static/up-pressed.png
--------------------------------------------------------------------------------
/docs/API/_build/html/_static/up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/html/_static/up.png
--------------------------------------------------------------------------------
/docs/API/_build/html/objects.inv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_build/html/objects.inv
--------------------------------------------------------------------------------
/docs/API/_static/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_static/logo.jpg
--------------------------------------------------------------------------------
/docs/API/_static/logo_small.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/_static/logo_small.jpg
--------------------------------------------------------------------------------
/docs/API/index.rst:
--------------------------------------------------------------------------------
1 | .. Quantipy documentation master file, created by
2 | sphinx-quickstart on Wed May 20 09:00:43 2015.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | .. toctree::
7 | :maxdepth: 5
8 | :hidden:
9 |
10 | sites/release_notes/00_overview
11 | sites/lib_doc/dataprocessing/00_overview
12 | sites/lib_doc/batch/00_overview
13 | sites/lib_doc/engine/00_overview
14 | sites/lib_doc/builds/00_overview
15 | sites/api_ref/00overview
16 |
17 |
18 | """"
19 |
20 | Quantipy: Python survey data toolkit
21 | ====================================
22 | Quantipy is an open-source data processing, analysis and reporting software
23 | project that builds on the excellent `pandas `_
24 | and `numpy `_ libraries. Aimed at social and marketing research survey data, Quantipy offers support for native handling of special data types like multiple choice variables, statistical analysis using case or observation weights, dataset metadata and customizable reporting exports.
25 |
26 | """"
27 |
28 | .. note::
29 | We are currently moving our documentation and reorganizing it. Sorry for the
30 | lack of latest information.
31 |
32 | """"
33 |
34 | Key features
35 | """"""""""""
36 |
37 | * Reads plain .csv, converts from Dimensions, SPSS, Decipher, or Ascribe
38 | * Open metadata format to describe and manage datasets
39 | * Powerful, metadata-driven cleaning, editing, recoding and transformation of datasets
40 | * Computation and assessment of data weights
41 | * Easy-to-use analysis interface
42 | * Automated data aggregation using ``Batch`` defintions
43 | * Structured analysis and reporting via Chain and Cluster containers
44 | * Export to SPSS, Dimensions ddf/mdd, table spreadsheets and chart decks
45 |
46 | """"
47 |
48 | **Contributors**
49 | Kerstin Müller, Alexander Buchhammer, Alasdair Eaglestone, James Griffiths
50 |
51 | Birgir Hrafn Sigurðsson and Geir Freysson of `datasmoothie `_
52 |
53 | """"
54 |
55 | * :ref:`genindex`
56 | * :ref:`modindex`
--------------------------------------------------------------------------------
/docs/API/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/logo.jpg
--------------------------------------------------------------------------------
/docs/API/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/logo.png
--------------------------------------------------------------------------------
/docs/API/logo_small.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/logo_small.jpg
--------------------------------------------------------------------------------
/docs/API/qp_overview.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | qp_overview
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/docs/API/qp_overview.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/qp_overview.jpg
--------------------------------------------------------------------------------
/docs/API/sites/api_ref/00overview.rst:
--------------------------------------------------------------------------------
1 |
2 | API references
3 | ==============
4 |
5 | .. toctree::
6 | :maxdepth: 3
7 |
8 | Chain
9 | Cluster
10 | DataSet
11 | quantify_engine
12 | QuantipyViews
13 | Rim_scheme
14 | Stack
15 | View
16 | ViewMapper
--------------------------------------------------------------------------------
/docs/API/sites/api_ref/Chain.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | Chain
5 | =====
6 |
7 | .. autoclass:: quantipy.Chain
8 | :members:
--------------------------------------------------------------------------------
/docs/API/sites/api_ref/Cluster.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | Cluster
5 | =======
6 |
7 | .. autoclass:: quantipy.Cluster
8 | :members:
--------------------------------------------------------------------------------
/docs/API/sites/api_ref/DataSet.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | DataSet
5 | =======
6 |
7 | .. autoclass:: quantipy.DataSet
8 | :members:
--------------------------------------------------------------------------------
/docs/API/sites/api_ref/QuantipyViews.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | QuantipyViews
5 | =============
6 |
7 | .. autoclass:: quantipy.QuantipyViews
8 | :members:
--------------------------------------------------------------------------------
/docs/API/sites/api_ref/Rim_scheme.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | Rim
5 | ===
6 |
7 | .. autoclass:: quantipy.Rim
8 | :members:
--------------------------------------------------------------------------------
/docs/API/sites/api_ref/View.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | View
5 | ====
6 |
7 | .. autoclass:: quantipy.View
8 | :members:
--------------------------------------------------------------------------------
/docs/API/sites/api_ref/ViewMapper.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | ViewMapper
5 | ==========
6 |
7 | .. autoclass:: quantipy.ViewMapper
8 | :members:
--------------------------------------------------------------------------------
/docs/API/sites/api_ref/quantify_engine.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | quantify.engine
5 | ===============
6 |
7 | .. autoclass:: quantipy.Quantity
8 | :members:
9 | .. autoclass:: quantipy.Test
10 | :members:
--------------------------------------------------------------------------------
/docs/API/sites/api_ref/stack.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 3
3 |
4 | Stack
5 | =====
6 |
7 | .. autoclass:: quantipy.Stack
8 | :members:
--------------------------------------------------------------------------------
/docs/API/sites/lib_doc/batch/00_overview.rst:
--------------------------------------------------------------------------------
1 |
2 | =========
3 | ``Batch``
4 | =========
5 |
6 | ``qp.Batch`` is a subclass of ``qp.DataSet`` and is a container for
7 | structuring a ``qp.Link`` collection's specifications.
8 |
9 | ``qp.Batch`` is not only a subclass of ``qp.DataSet``, it also takes a
10 | DataSet instance as input argument, inheriting a few of its attributes, e.g.
11 | ``_meta``, ``_data``, ``valid_tks`` and ``text_key``.
12 | All other ``Batch`` attributes are used as construction plans for populating a
13 | ``qp.Stack``, these get stored in the belonging ``DataSet`` meta component in
14 | ``_meta['sets']['batches'][batchname]``.
15 |
16 | In general, it does not matter in which order ``Batch`` attributes are set by
17 | methods, the class ensures that all attributes are kept consistent.
18 |
19 | All next sections are working with the following ``qp.DataSet`` instance::
20 |
21 | import quantipy as qp
22 |
23 | dataset = qp.DataSet('Example Data (A)')
24 | dataset.read_quantipy('Example Data (A).json', 'Example Data (A).csv')
25 |
26 | The json and csv files you can find in ``quantipy/tests``.
27 |
28 | .. toctree::
29 | :maxdepth: 5
30 | :includehidden:
31 |
32 | 01_create_load
33 | 02_variables
34 | 03_properties
35 | 04_subclass
36 |
--------------------------------------------------------------------------------
/docs/API/sites/lib_doc/batch/01_create_load.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | =========================================
6 | Creating/ Loading a ``qp.Batch`` instance
7 | =========================================
8 |
9 | As mentioned, a ``Batch`` instance has a close connection to its belonging
10 | ``DataSet`` instance and we can easily create a new ``Batch`` from a ``DataSet``
11 | as per::
12 |
13 | batch1 = dataset.add_batch(name='batch1')
14 | batch2 = dataset.add_batch(name='batch2', ci=['c'], weights='weight')
15 |
16 | It is also possible to load an already existing instance out of the meta
17 | stored in ``dataset._meta['sets']['batches']``::
18 |
19 | batch = dataset.get_batch('batch1')
20 |
21 | Both methods, ``.add_batch()`` and ``.get_batch()``, are an easier way to
22 | use the ``__init__()`` method of ``qp.Batch``.
23 |
24 | An other way to get a new ``qp.Batch`` instance is to copy an existing one, in
25 | that case all added open ends are removed from the new instance::
26 |
27 | copy_batch = batch.copy('copy_of_batch1')
28 |
--------------------------------------------------------------------------------
/docs/API/sites/lib_doc/batch/02_variables.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | ===========================================
6 | Adding variables to a ``qp.Batch`` instance
7 | ===========================================
8 |
9 | -----------------
10 | x-keys and y-keys
11 | -----------------
12 |
13 | The included variables in a ``Batch`` constitute the main structure for the
14 | ``qp.Stack`` construction plan. Variables can be added as x-keys or y-keys, for
15 | arrays all belonging items are automatically added and the ``qp.Stack`` gets
16 | populated with all cross-tabulations of these keys:
17 |
18 | >>> batch.add_x(['q1', 'q2', 'q6'])
19 | >>> batch.add_y(['gender', 'q1'])
20 | Array summaries setup: Creating ['q6'].
21 |
22 | x-specific y-keys can be produced by manipulating the main y-keys, this edit
23 | can be extending or replacing the existing keys:
24 |
25 | >>> batch.extend_y(['locality', 'ethnicity'], on=['q1'])
26 | >>> batch.replace_y(['locality', 'ethnicity'], on=['q2'])
27 |
28 | With these settings the construction plan looks like that:
29 |
30 | >>> print batch.x_y_map
31 | OrderedDict([('q1', ['@', 'gender', 'q1', 'locality', 'ethnicity']),
32 | ('q2', ['locality', 'ethnicity']),
33 | ('q6', ['@']),
34 | (u'q6_1', ['@', 'gender', 'q1']),
35 | (u'q6_2', ['@', 'gender', 'q1']),
36 | (u'q6_3', ['@', 'gender', 'q1'])])
37 |
38 | ------
39 | Arrays
40 | ------
41 |
42 | A special case exists if the added variables contain arrays. As default for all
43 | arrays in x-keys array summaries are created (array as x-key and ``'@'``-referenced total as
44 | y-key), see the output below (``Array summaries setup: Creating ['q6'].``).
45 | If array summaries are requested only for a selection of variables or for none,
46 | use ``.make_summaries()``:
47 |
48 | >>> batch.make_summaries(None)
49 | Array summaries setup: Creating no summaries!
50 |
51 | Arrays can also be transposed (``'@'``-referenced total as x-key and array name
52 | as y-key). If they are not in the batch summary list before, they are
53 | automatically added and depending on the ``replace`` parameter only the
54 | transposed or both types of summaries are added to the ``qp.Stack``:
55 |
56 | >>> batch.transpose_array('q6', replace=False)
57 | Array summaries setup: Creating ['q6'].
58 |
59 | The construction plan now shows that both summary types are included:
60 |
61 | >>> print batch.x_y_map
62 | OrderedDict([('q1', ['@', 'gender', 'q1', 'locality', 'ethnicity']),
63 | ('q2', ['locality', 'ethnicity']),
64 | ('q6', ['@']),
65 | ('@', ['q6']),
66 | (u'q6_1', ['@', 'gender', 'q1']),
67 | (u'q6_2', ['@', 'gender', 'q1']),
68 | (u'q6_3', ['@', 'gender', 'q1'])])
69 |
70 | --------------------
71 | Verbatims/ open ends
72 | --------------------
73 |
74 | Another special case are verbatims. They will not be aggregated in a ``qp.Stack``,
75 | but they have to be defined in a ``qp.Batch`` to add them later to a ``qp.Cluster``.
76 |
77 | There are two different ways to add verbatims: Either all to one ``qp.Cluster``
78 | key or each gets its own key. But both options can be done with the same method.
79 |
80 | For splitting the verbatims, set ``split=True`` and insert as many titles as
81 | included verbatims/ open ends:
82 |
83 | >>> batch.add_open_ends(['q8a', 'q9a'], break_by=['record_number', 'age'],
84 | split=True, title=['oe_q8', 'oe_q9'])
85 |
86 | For collecting all verbatims in one Cluster key, set ``split=False`` and add
87 | only one ``title`` or use the default parameters:
88 |
89 | >>> batch.add_open_ends(['q8a', 'q9a'], break_by=['record_number', 'age'])
90 |
91 | --------------------
92 | Special aggregations
93 | --------------------
94 |
95 | It is possible to add some special aggregations to a ``qp.Batch``, that are
96 | not stored in the main construction plan ``.x_y_map``. One option is to give a
97 | name for a Cluster key in which all y-keys are cross-tabulated against each
98 | other:
99 |
100 | >>> batch.add_y_on_y('y-keys')
101 |
102 | Another possibility is to add a ``qp.Batch`` instance to an other instance.
103 | The added Batch loses all information about verbatims and ``.y_on_y``, that
104 | means only the main construction plan in ``.x_y_map`` gets adopted. Each of
105 | the two batches is aggregated discretely in the ``qp.Stack``, but the added
106 | instance gets included into the ``qp.Cluster`` of the first ``qp.Batch`` in
107 | a key named by its instance name.
108 |
109 | >>> batch1 = dataset.get_batch('batch1')
110 | >>> batch2 = dataset.get_batch('batch2')
111 | >>> batch2.add_x('q2b')
112 | Array summaries setup: Creating no summaries!
113 | >>> batch2.add_y('gender')
114 | >>> batch2.as_addition('batch1')
115 | Batch 'batch2' specified as addition to Batch 'batch1'. Any open end summaries and 'y_on_y' agg. have been removed!
116 |
117 | The connection between the two ``qp.Batch`` instances you can see in ``.additional``
118 | for the added instance and in ``._meta['sets']['batches']['batchname']['additions']``
119 | for the first instance.
--------------------------------------------------------------------------------
/docs/API/sites/lib_doc/batch/03_properties.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | ================================
6 | Set properties of a ``qp.Batch``
7 | ================================
8 |
9 | The section before explained how the main construction plan (``batch.x_y_map``)
10 | is built, that describes which x-keys and y-keys are used to add ``qp.Link``\s
11 | to a ``qp.Stack``. Now you will get to know how the missing information for the
12 | ``Link``\s are defined and which specific views get extracted for the
13 | ``qp.Cluster`` by adding some property options the ``qp.Batch`` instance.
14 |
15 | ----------------------------------------
16 | Filter, weights and significance testing
17 | ----------------------------------------
18 |
19 | ``qp.Link``\s can be added to a ``qp.Stack`` data_key-level by defining its x
20 | and y-keys, which is already done in ``.x_y_map``, and setting a filter.
21 | This property can be edited in a ``qp.Batch`` instance with the
22 | following methods:
23 |
24 | >>> batch.add_filter('men only', {'gender': 1})
25 | >>> batch.extend_filter({'q1': {'age': [20, 21, 22, 23, 24, 25]}})
26 |
27 | Filters can be added globally or for a selection of x-keys only. Out of the
28 | global filter, ``.sample_size`` is automatically calculated for each ``qp.Batch``
29 | defintion.
30 |
31 | Now all information are collected in the ``qp.Batch`` instance and the ``Stack``
32 | can be populated with ``Link``\s in form of ``stack[data_key][filter_key][x_key][y_key]``.
33 |
34 | For each ``Link`` ``qp.View``\s can be added, these views depend on a weight
35 | definition, which is also defined in the ``qp.Batch``:
36 |
37 | >>> batch.set_weights(['weight_a'])
38 |
39 | Significance tests are a special ``View``; the sig. levels which they are
40 | calculated on can be added to the ``qp.Batch`` like this:
41 |
42 | >>> batch.set_sigtests(levels=[0.05])
43 |
44 | -----------------------
45 | Cell items and language
46 | -----------------------
47 |
48 | As ``qp.Stack`` is a container for a large amount of aggregations, it will
49 | accommodate various ``qp.View``\s. The ``qp.Batch`` property ``.cell_items`` is
50 | used to define which specfic ``Views`` will be taken to create a ``qp.Cluster``:
51 |
52 | >>> batch.set_cell_items(['c', 'p'])
53 |
54 | The property ``.language`` allows the user to define which ``text`` labels from
55 | the meta data should be used for the extracted ``Views`` by entering a valid
56 | text key:
57 |
58 | >>> batch.set_language('en-GB')
59 |
--------------------------------------------------------------------------------
/docs/API/sites/lib_doc/batch/04_subclass.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | ================================
6 | Inherited ``qp.DataSet`` methods
7 | ================================
8 |
9 | Being a ``qp.DataSet`` subclasss, ``qp.Batch`` inherits some of its methods.
10 | The important ones are these which allow the manipulation of the meta component.
11 | That means meta-edits can be applied globally (run methods on ``qp.DataSet``) or
12 | ``Batch``-specific (run methods on ``qp.Batch``). Batch meta-edits
13 | always overwrite global meta-edits and while building a ``qp.Cluster`` from a
14 | ``qp.Batch``, the modified meta information is taken from ``.meta_edits``.
15 |
16 | The following methods can be used to create meta-edits for a ``qp.Batch``:
17 |
18 | >>> batch.hiding('q1', [2], axis='y')
19 | >>> batch.sorting('q2', fix=[97, 98])
20 | >>> batch.slicing('q1', [1, 2, 3, 4, 5], axis='x')
21 | >>> batch.set_variable_text('gender', 'Gender???')
22 | >>> batch.set_value_texts('gender', {1: 'Men', 2: 'Women'})
23 | >>> batch.set_property('q1', 'base_text', 'This var has a second filter.')
24 |
25 | Some methods are not allowed to be used for a ``Batch``. These will raise a
26 | ``NotImplementedError`` to prevent inconsistent case and meta data states.
27 |
--------------------------------------------------------------------------------
/docs/API/sites/lib_doc/builds/00_overview.rst:
--------------------------------------------------------------------------------
1 | ======
2 | Builds
3 | ======
4 |
5 | .. toctree::
6 | :maxdepth: 5
7 | :includehidden:
8 |
9 | 01_chains
10 |
--------------------------------------------------------------------------------
/docs/API/sites/lib_doc/builds/01_chains.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | =================
6 | Combining results
7 | =================
8 |
9 | --------------------------------
10 | Organizing ``View`` aggregations
11 | --------------------------------
12 |
13 | -------------------------------
14 | Creating ``Chain`` aggregations
15 | -------------------------------
16 |
17 | What is a ``Chain``?
18 | --------------------
19 |
20 | Customizing results
21 | -------------------
22 |
--------------------------------------------------------------------------------
/docs/API/sites/lib_doc/dataprocessing/00_overview.rst:
--------------------------------------------------------------------------------
1 | ---------------
2 | Data processing
3 | ---------------
4 |
5 | .. toctree::
6 | :maxdepth: 5
7 | :includehidden:
8 |
9 | 01_components
10 | 02_io
11 | 02a_management
12 | 03_inspection
13 | 04_editing
14 | 05_transforming
15 | 06_logics
16 | 07_custom_recoding
17 |
--------------------------------------------------------------------------------
/docs/API/sites/lib_doc/dataprocessing/02a_management.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | ==================
6 | DataSet management
7 | ==================
8 |
9 | --------------------------
10 | Setting the variable order
11 | --------------------------
12 | The global variable order of a ``DataSet`` is dictated by the content of the
13 | ``meta['sets']['data file']['items']`` list and reflected in the structure of
14 | the case data component's ``pd.DataFrame.columns``. There are two ways to set
15 | a new order using the ``order(new_order=None, reposition=None)`` method:
16 |
17 | **Define a full order**
18 |
19 | Using this apporach requires that all ``DataSet`` variable names are passed
20 | via the ``new_order`` parameter. Providing only a subset of the variables will
21 | raise a ``ValueError``:
22 |
23 | >>> dataset.order(['q1', 'q8'])
24 | ValueError: 'new_order' must contain all DataSet variables.
25 |
26 | Text...
27 |
28 | **Change positions relatively**
29 |
30 | Often only a few changes to the natural order of the ``DataSet`` are necessary,
31 | e.g. derived variables should be moved alongside their originating ones or specific
32 | sets of variables (demographics, etc.) should be grouped together. We can achieve
33 | this using the ``reposition`` parameter as follows:
34 |
35 | Text...
36 |
37 | ---------------------------------
38 | Cloning, filtering and subsetting
39 | ---------------------------------
40 |
41 | 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.
42 | a specific part of the questionnaire). To not permanently change an existing
43 | ``DataSet`` by accident, draw a copy of it first:
44 |
45 | >>> copy_ds = dataset.clone()
46 |
47 | Then you can use ``filter()`` to restrict cases (rows) or ``subset()`` to keep
48 | only a selected range of variables (columns). Both methods can be used inplace
49 | but will return a new object by default.
50 |
51 | >>> keep = {'Wave': [1]}
52 | >>> copy_ds.filter(alias='first wave', condition=keep, inplace=True)
53 | >>> copy_ds._data.shape
54 | (1621, 76)
55 |
56 | 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
57 | to describe the arbitrarily complex filter ``condition``) is attached to the
58 | instance:
59 |
60 | >>> copy_ds.filtered
61 | only first wave
62 |
63 | We are now further reducing the ``DataSet`` by dropping all variables except the three ``array`` variables ``'q5'``, ``'q6'``, and ``'q7'`` using ``subset()``.
64 |
65 | >>> reduced_ds = copy_ds.subset(variables=['q5', 'q6', 'q7'])
66 |
67 | We can see that only the requested variables (``masks`` defintitions and the
68 | constructing ``array`` items) remain in ``reduced_ds``:
69 |
70 | >>> reduced_ds.by_type()
71 | size: 1621 single delimited set array int float string date time N/A
72 | 0 q5_1 q5
73 | 1 q5_2 q7
74 | 2 q5_3 q6
75 | 3 q5_4
76 | 4 q5_5
77 | 5 q5_6
78 | 6 q6_1
79 | 7 q6_2
80 | 8 q6_3
81 | 9 q7_1
82 | 10 q7_2
83 | 11 q7_3
84 | 12 q7_4
85 | 13 q7_5
86 | 14 q7_6
87 |
88 | -------
89 | Merging
90 | -------
91 |
92 | Intro text... As opposed to reducing an existing file...
93 |
94 | Vertical (cases/rows) merging
95 | -----------------------------
96 |
97 | Text
98 |
99 | Horizontal (variables/columns) merging
100 | --------------------------------------
101 |
102 | Text
103 |
104 | -----------------------------
105 | Savepoints and state rollback
106 | -----------------------------
107 |
108 | When working with big ``DataSet``\s and needing to perform a lot of data
109 | preparation (deriving large amounts of new variables, lots of meta editing,
110 | complex cleaning, ...) it can be beneficial to quickly store a snapshot of a
111 | clean and consistent state of the ``DataSet``. This is most useful when working
112 | in interactive sessions like **IPython** or **Jupyter notebooks** and might
113 | prevent you from reloading files from disk or waiting for previous processes
114 | to finish.
115 |
116 | Savepoints are stored via ``save()`` and can be restored via ``revert()``.
117 |
118 | .. note::
119 | Savepoints only exists in memory and are not written to disk. Only one
120 | savepoint can exist, so repeated ``save()`` calls will overwrite any previous
121 | versions of the ``DataSet``. To permanently save your data, please use one
122 | of the ``write`` methods, e.g. ``write_quantipy()``.
123 |
--------------------------------------------------------------------------------
/docs/API/sites/lib_doc/dataprocessing/06_logics.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | =======================
6 | Logic and set operaters
7 | =======================
8 |
9 | ------
10 | Ranges
11 | ------
12 | The ``frange()`` function takes a string of abbreviated ranges, possibly delimited
13 | by a comma (or some other character) and extrapolates its full,
14 | unabbreviated list of ints.
15 |
16 | >>> from quantipy.core.tools.dp.prep import frange
17 |
18 | **Basic range**:
19 |
20 | >>> frange('1-5')
21 | [1, 2, 3, 4, 5]
22 |
23 | **Range in reverse**:
24 |
25 | >>> frange('15-11')
26 | [15, 14, 13, 12, 11]
27 |
28 | **Combination**:
29 |
30 | >>> frange('1-5,7,9,15-11')
31 | [1, 2, 3, 4, 5, 7, 9, 15, 14, 13, 12, 11]
32 |
33 | **May include spaces for clarity**:
34 |
35 | >>> frange('1-5, 7, 9, 15-11')
36 | [1, 2, 3, 4, 5, 7, 9, 15, 14, 13, 12, 11]
37 |
38 | -------------
39 | Complex logic
40 | -------------
41 | Multiple conditions can be combined using ``union`` or ``intersection`` set
42 | statements. Logical mappers can be arbitrarily nested as long as they are
43 | well-formed.
44 |
45 | ``union``
46 | ---------
47 | ``union`` takes a list of logical conditions that will be treated with
48 | **or** logic.
49 |
50 | Where **any** of logic_A, logic_B **or** logic_C are ``True``:
51 |
52 | >>> union([logic_A, logic_B, logic_C])
53 |
54 | ``intersection``
55 | ----------------
56 | ``intersection`` takes a list of conditions that will be
57 | treated with **and** logic.
58 |
59 | Where **all** of logic_A, logic_B **and** logic_C are ``True``:
60 |
61 | >>> intersection([logic_A, logic_B, logic_C])
62 |
63 | "List" logic
64 | ------------
65 | Instead of using the verbose ``has_any`` operator, we can express simple, non-nested
66 | *or* logics simply as a list of codes. For example ``{"q1_1": [1, 2]}`` is an
67 | example of list-logic, where ``[1, 2]`` will be interpreted as ``has_any([1, 2])``,
68 | meaning if **q1_1** has any of the values **1** or **2**.
69 |
70 | ``q1_1`` has any of the responses 1, 2 or 3:
71 |
72 | >>> l = {"q1_1": [1, 2, 3]}
73 |
74 |
75 | ``has_any``
76 | -----------
77 | ``q1_1`` has any of the responses 1, 2 or 3:
78 |
79 | >>> l = {"q1_1": has_any([1, 2, 3])}
80 |
81 | ``q1_1`` has any of the responses 1, 2 or 3 and no others:
82 |
83 | >>> l = {"q1_1": has_any([1, 2, 3], exclusive=True)}
84 |
85 |
86 | ``not_any``
87 | -----------
88 | ``q1_1`` doesn't have any of the responses 1, 2 or 3:
89 |
90 | >>> l = {"q1_1": not_any([1, 2, 3])}
91 |
92 | ``q1_1`` doesn't have any of the responses 1, 2 or 3 but has some others:
93 |
94 | >>> l = {"q1_1": not_any([1, 2, 3], exclusive=True)}
95 |
96 | ``has_all``
97 | -----------
98 | ``q1_1`` has all of the responses 1, 2 and 3:
99 |
100 | >>> l = {"q1_1": has_all([1, 2, 3])}
101 |
102 | ``q1_1`` has all of the responses 1, 2 and 3 and no others:
103 |
104 | >>> l = {"q1_1": has_all([1, 2, 3], exclusive=True)}
105 |
106 | ``not_all``
107 | -----------
108 | ``q1_1`` doesn't have all of the responses 1, 2 and 3:
109 |
110 | >>> l = {"q1_1": not_all([1, 2, 3])}
111 |
112 | ``q1_1`` doesn't have all of the responses 1, 2 and 3 but has some others:
113 |
114 | >>> l = {"q1_1": not_all([1, 2, 3], exclusive=True)}
115 |
116 | ``has_count``
117 | -------------
118 |
119 | ``q1_1`` has exactly 2 responses:
120 |
121 | >>> l = {"q1_1": has_count(2)}
122 |
123 | ``q1_1`` has 1, 2 or 3 responses:
124 |
125 | >>> l = {"q1_1": has_count([1, 3])}
126 |
127 | ``q1_1`` has 1 or more responses:
128 |
129 | >>> l = {"q1_1": has_count([is_ge(1)])}
130 |
131 | ``q1_1`` has 1, 2 or 3 responses from the response group 5, 6, 7, 8 or 9:
132 |
133 | >>> l = {"q1_1": has_count([1, 3, [5, 6, 7, 8, 9]])}
134 |
135 | ``q1_1`` has 1 or more responses from the response group 5, 6, 7, 8 or 9:
136 |
137 | >>> l = {"q1_1": has_count([is_ge(1), [5, 6, 7, 8, 9]])}
138 |
139 | ``not_count``
140 | -------------
141 | ``q1_1`` doesn't have exactly 2 responses:
142 |
143 | >>> l = {"q1_1": not_count(2)}
144 |
145 | ``q1_1`` doesn't have 1, 2 or 3 responses:
146 |
147 | >>> l = {"q1_1": not_count([1, 3])}
148 |
149 | ``q1_1`` doesn't have 1 or more responses:
150 |
151 | >>> l = {"q1_1": not_count([is_ge(1)])}
152 |
153 | ``q1_1`` doesn't have 1, 2 or 3 responses from the response group 5, 6, 7, 8 or 9:
154 |
155 | >>> l = {"q1_1": not_count([1, 3, [5, 6, 7, 8, 9]])}
156 |
157 | ``q1_1`` doesn't have 1 or more responses from the response group 5, 6, 7, 8 or 9:
158 |
159 | >>> l = {"q1_1": not_count([is_ge(1), [5, 6, 7, 8, 9]])}
160 |
161 | ----------------------------------
162 | Boolean slicers and code existence
163 | ----------------------------------
164 | ``any()``, ``all()``
165 | ``code_count()``, ``is_nan()``
166 |
--------------------------------------------------------------------------------
/docs/API/sites/lib_doc/engine/00_overview.rst:
--------------------------------------------------------------------------------
1 | ----------------------
2 | Analysis & aggregation
3 | ----------------------
4 |
5 | .. toctree::
6 | :maxdepth: 5
7 | :includehidden:
8 |
9 | 01_links_stacks
10 | 02_quantity
11 | 03_test
12 | 04_agg_methods
13 |
--------------------------------------------------------------------------------
/docs/API/sites/lib_doc/engine/02_quantity.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | ========================
6 | The computational engine
7 | ========================
8 |
9 |
--------------------------------------------------------------------------------
/docs/API/sites/lib_doc/engine/03_test.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | ====================
6 | Significance testing
7 | ====================
8 |
--------------------------------------------------------------------------------
/docs/API/sites/release_notes/00_overview.rst:
--------------------------------------------------------------------------------
1 | -------------
2 | Release notes
3 | -------------
4 |
5 | .. toctree::
6 | :maxdepth: 5
7 | :includehidden:
8 |
9 | 01_latest
10 | 02_archive
11 |
12 |
13 | .. toctree::
14 | :maxdepth: 5
15 | :hidden:
16 |
17 | 03_how_to_snippets
--------------------------------------------------------------------------------
/docs/API/sites/release_notes/01_latest.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :includehidden:
4 |
5 | ===================
6 | Latest (01/10/2018)
7 | ===================
8 |
9 | **New**: "rewrite" of Rules module (affecting sorting):
10 |
11 | **sorting "normal" columns**:
12 |
13 | * ``sort_on`` always '@'
14 | * ``fix`` any categories
15 | * ``sort_by_weight`` default is unweighted (None), but each weight (included
16 | in data) can be used
17 |
18 | If sort_by_weight and the view-weight differ, a warning is shown.
19 |
20 | **sorting "expanded net" columns**:
21 |
22 | * ``sort_on`` always '@'
23 | * ``fix`` any categories
24 | * sorting ``within`` or ``between`` net groups is available
25 | * ``sort_by_weight``: as default the weight of the first found
26 | expanded-net-view is taken. Only weights of aggregated net-views are possible
27 |
28 | **sorting "array summaries"**:
29 |
30 | * ``sort_on`` can be any desc ('median', 'stddev', 'sem', 'max', 'min',
31 | 'mean', 'upper_q', 'lower_q') or nets ('net_1', 'net_2', .... enumerated
32 | by the net_def)
33 | * ``sort_by_weight``: as default the weight of the first found desc/net-view
34 | is taken. Only weights of aggregated desc/net-views are possible
35 | * ``sort_on`` can also be any category, here each weight can be used to sort_on
36 |
37 | """"
38 |
39 | **New**: ``DataSet.min_value_count()``
40 |
41 | A new wrapper for ``DataSet.hiding()`` is included. All values are hidden,
42 | that have less counts than the included number ``min``.
43 | The used data can be weighted or filtered using the parameters ``weight`` and
44 | ``condition``.
45 |
46 | Usage as Batch method:
47 | ``Batch.min_value_count()`` without the parameters ``weight`` and
48 | ``condition`` automatically grabs ``Batch.weights[0]`` and ``Batch.filter``
49 | to calculate low value counts.
50 |
51 | """"
52 |
53 | **New**: Prevent weak duplicated in data
54 |
55 | As Python is case sensitive it is possible to have two or more variables with
56 | the same name, but in lower- and uppercases. Most other software do not support
57 | that, so a warning is shown if a weak dupe is created. Additionally
58 | ``Dataset.write_dimensions()`` performs auto-renaming is weak dupes are detected.
59 |
60 | """"
61 |
62 | **New**: Prevent single-cat delimited sets
63 |
64 | ``DataSet.add_meta(..., qtype='delimited set', categories=[...], ...)``
65 | automatically switches ``qtype`` to single if only one category is defined.
66 | ``DataSet.convert(name, 'single')`` allows conversion from ``delimited set`` to
67 | ``single`` if the variable has only one category.
68 | ``DataSet.repair()`` and ``DataSt.remove_values()`` convert delimited sets
69 | automatically to singles if only one category is included.
70 |
71 | """"
72 |
73 | **Update**: merge warnings + merging delimites sets
74 |
75 | Warnings in ``hmerge()`` and ``vmerge()`` are updated. If a column exists in
76 | the left and the right dataset, the type is compared. Some type inconsistencies
77 | are allowed, but return a warning, while others end up in a raise.
78 |
79 | delimited sets in ``vmerge()``:
80 |
81 | If a column is a delimited set in the left dataset, but a single, int or float
82 | in the right dataset, the data of the right column is converted into a delimited
83 | set.
84 |
85 | delimited sets in ``hmerge(...merge_existing=None)``:
86 |
87 | For the hmerge a new parameter ``merge_existing`` is included, which can be
88 | ``None``, a list of variable-names or ``'all'``.
89 |
90 | If delimited sets are included in left and right dataset:
91 |
92 | * ``merge_existing=None``: Only meta is adjusted. Data is untouched (left data
93 | is taken).
94 | * ``merge_existing='all'``: Meta and data are merged for all delimited sets,
95 | that are included in both datasets.
96 | * ``merge_existing=[variable-names]``: Meta and data are merged for all
97 | delimited sets, that are listed and included in both datasets.
98 |
99 | """"
100 |
101 | **Update**: encoding in ``DataSet.get_batch(name)``
102 |
103 | The method is not that encoding sensitive anymore. It returns the depending
104 | ``Batch``, no matter if ``'...'``, ``u'...'`` or ``'...'.decode('utf8')`` is
105 | included as name.
106 |
107 | """"
108 |
109 | **Update**: warning in weight engine
110 |
111 | Missing codes in the sample are only alerted, if the belonging target is not 0.
112 |
113 | """"
114 |
115 | **Update**: ``DataSet.to_array(..., variables, ...)``
116 |
117 | Duplicated vars in ``variables`` are not allowed anymore, these were causing
118 | problems in the ChainManager class.
119 |
120 | """"
121 |
122 | **Update**: ``Batch.add_open_ends()``
123 |
124 | Method raises an error if no vars are included in ``oe`` and ``break_by``. The
125 | empty dataframe was causing issues in the ChainManager class.
126 |
127 | """"
128 |
129 | **Update**: ``Batch.extend_x()``
130 |
131 | The method automatically checks if the included variables are arrays and adds
132 | them to ``Batch.summaries`` if they are included yet.
133 |
134 | """"
135 |
--------------------------------------------------------------------------------
/docs/API/sites/release_notes/03_how_to_snippets.rst:
--------------------------------------------------------------------------------
1 |
2 |
3 | ===============
4 | How-to-snippets
5 | ===============
6 |
7 | .. toctree::
8 | :maxdepth: 5
9 |
10 | how_to_snippets/dimensions_comp
11 | how_to_snippets/create_categorical_meta
12 | how_to_snippets/derotate
--------------------------------------------------------------------------------
/docs/API/sites/release_notes/how_to_snippets/create_categorical_meta.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :hidden:
4 |
5 | =============================================
6 | Different ways of creating categorical values
7 | =============================================
8 |
9 | The ``DataSet`` methods ``add_meta()``, ``extend_values()`` and ``derive()``
10 | offer three alternatives for specifying the categorical values of ``'single'``
11 | and ``'delimited set'`` typed variables. The approaches differ with respect to
12 | how the mapping of numerical value codes to value text labels is handled.
13 |
14 | **(1) Providing a list of text labels**
15 |
16 | By providing the category labels only as a list of ``str``, ``DataSet``
17 | is going to create the numerical codes by simple enumeration:
18 |
19 | >>> name, qtype, label = 'test_var', 'single', 'The test variable label'
20 |
21 | >>> cats = ['test_cat_1', 'test_cat_2', 'test_cat_3']
22 | >>> dataset.add_meta(name, qtype, label, cats)
23 |
24 | >>> dataset.meta('test_var')
25 | single codes texts missing
26 | test_var: The test variable label
27 | 1 1 test_cat_1 None
28 | 2 2 test_cat_2 None
29 | 3 3 test_cat_3 None
30 |
31 | **(2) Providing a list of numerical codes**
32 |
33 | If only the desired numerical codes are provided, the label information for all
34 | categories consequently will appear blank. In such a case the user will, however,
35 | get reminded to add the ``'text'`` meta in a separate step:
36 |
37 | >>> cats = [1, 2, 98]
38 | >>> dataset.add_meta(name, qtype, label, cats)
39 | ...\\quantipy\core\dataset.py:1287: UserWarning: 'text' label information missing,
40 | only numerical codes created for the values object. Remember to add value 'text' metadata manually!
41 |
42 | >>> dataset.meta('test_var')
43 | single codes texts missing
44 | test_var: The test variable label
45 | 1 1 None
46 | 2 2 None
47 | 3 98 None
48 |
49 | **(3) Pairing numerical codes with text labels**
50 |
51 | To explicitly assign codes to corresponding labels, categories can also be
52 | defined as a list of tuples of codes and labels:
53 |
54 | >>> cats = [(1, 'test_cat_1') (2, 'test_cat_2'), (98, 'Don\'t know')]
55 | >>> dataset.add_meta(name, qtype, label, cats)
56 |
57 | >>> dataset.meta('test_var')
58 | single codes texts missing
59 | test_var: The test variable label
60 | 1 1 test_cat_1 None
61 | 2 2 test_cat_2 None
62 | 3 98 Don't know None
63 |
64 | .. note::
65 | All three approaches are also valid for defining the ``items`` object for
66 | ``array``-typed ``masks``.
--------------------------------------------------------------------------------
/docs/API/sites/release_notes/how_to_snippets/dimensions_comp.rst:
--------------------------------------------------------------------------------
1 | .. toctree::
2 | :maxdepth: 5
3 | :hidden:
4 |
5 | ====================================
6 | ``DataSet`` Dimensions compatibility
7 | ====================================
8 |
9 | DTO-downloaded and Dimensions converted variable naming conventions are following
10 | specific rules for ``array`` names and corresponding ``ìtems``. ``DataSet``
11 | offers a compatibility mode for Dimensions scenarios and handles the proper
12 | renaming automatically. Here is what you should know...
13 |
14 | ----------------------
15 | The compatibility mode
16 | ----------------------
17 |
18 | A ``DataSet`` will (by default) support Dimensions-like ``array`` naming for its connected data files when constructed. An ``array`` ``masks`` meta defintition
19 | of a variable called ``q5`` looking like this...::
20 |
21 | {u'items': [{u'source': u'columns@q5_1', u'text': {u'en-GB': u'Surfing'}},
22 | {u'source': u'columns@q5_2', u'text': {u'en-GB': u'Snowboarding'}},
23 | {u'source': u'columns@q5_3', u'text': {u'en-GB': u'Kite boarding'}},
24 | {u'source': u'columns@q5_4', u'text': {u'en-GB': u'Parachuting'}},
25 | {u'source': u'columns@q5_5', u'text': {u'en-GB': u'Cave diving'}},
26 | {u'source': u'columns@q5_6', u'text': {u'en-GB': u'Windsurfing'}}],
27 | u'subtype': u'single',
28 | u'text': {u'en-GB': u'How likely are you to do each of the following in the next year?'},
29 | u'type': u'array',
30 | u'values': u'lib@values@q5'}
31 |
32 | ...will be converted into its "Dimensions equivalent" as per:
33 |
34 | >>> dataset = qp.DataSet(name_data, dimensions_comp=True)
35 | >>> dataset.read_quantipy(path_data+name_data, path_data+name_data)
36 | DataSet: ../Data/Quantipy/Example Data (A)
37 | rows: 8255 - columns: 75
38 | Dimensions compatibilty mode: True
39 |
40 | >>> dataset.masks()
41 | ['q5.q5_grid', 'q6.q6_grid', 'q7.q7_grid']
42 |
43 | >>> dataset._meta['masks']['q5.q5_grid']
44 | {u'items': [{u'source': 'columns@q5[{q5_1}].q5_grid',
45 | u'text': {u'en-GB': u'Surfing'}},
46 | {u'source': 'columns@q5[{q5_2}].q5_grid',
47 | u'text': {u'en-GB': u'Snowboarding'}},
48 | {u'source': 'columns@q5[{q5_3}].q5_grid',
49 | u'text': {u'en-GB': u'Kite boarding'}},
50 | {u'source': 'columns@q5[{q5_4}].q5_grid',
51 | u'text': {u'en-GB': u'Parachuting'}},
52 | {u'source': 'columns@q5[{q5_5}].q5_grid',
53 | u'text': {u'en-GB': u'Cave diving'}},
54 | {u'source': 'columns@q5[{q5_6}].q5_grid',
55 | u'text': {u'en-GB': u'Windsurfing'}}],
56 | 'name': 'q5.q5_grid',
57 | u'subtype': u'single',
58 | u'text': {u'en-GB': u'How likely are you to do each of the following in the next year?'},
59 | u'type': u'array',
60 | u'values': 'lib@values@q5.q5_grid'}
61 |
62 | -------------------------------------
63 | Accessing and creating ``array`` data
64 | -------------------------------------
65 |
66 | Since new names are converted automatically by ``DataSet`` methods, there is
67 | no need to write down the full (DTO-like) Dimensions ``array`` name when adding
68 | new metadata. However, querying variables is always requiring the proper name:
69 |
70 | >>> name, qtype, label = 'array_var', 'single', 'ARRAY LABEL'
71 | >>> cats = ['A', 'B', 'C']
72 | >>> items = ['1', '2', '3']
73 | >>> dataset.add_meta(name, qtype, label, cats, items)
74 |
75 | >>> dataset.masks()
76 | ['q5.q5_grid', 'array_var.array_var_grid', 'q6.q6_grid', 'q7.q7_grid']
77 |
78 | >>> dataset.meta('array_var.array_var_grid')
79 | single items item texts codes texts missing
80 | array_var.array_var_grid: ARRAY LABEL
81 | 1 array_var[{array_var_1}].array_var_grid 1 1 A None
82 | 2 array_var[{array_var_2}].array_var_grid 2 2 B None
83 | 3 array_var[{array_var_3}].array_var_grid 3 3 C None
84 |
85 | >>> dataset['array_var.array_var_grid'].head(5)
86 | array_var[{array_var_1}].array_var_grid array_var[{array_var_2}].array_var_grid array_var[{array_var_3}].array_var_grid
87 | 0 NaN NaN NaN
88 | 1 NaN NaN NaN
89 | 2 NaN NaN NaN
90 | 3 NaN NaN NaN
91 | 4 NaN NaN NaN
92 |
93 | As can been seen above, both the ``masks`` name as well as the ``array`` item
94 | elements are being properly converted to match DTO/Dimensions
95 | conventions.
96 |
97 | When using ``rename()``, ``copy()`` or ``transpose()``, the same behaviour
98 | applies:
99 |
100 | >>> dataset.rename('q6.q6_grid', 'q6new')
101 | >>> dataset.masks()
102 | ['q5.q5_grid', 'array_var.array_var_grid', 'q6new.q6new_grid', 'q7.q7_grid']
103 |
104 | >>> dataset.copy('q6new.q6new_grid', suffix='q6copy')
105 | >>> dataset.masks()
106 | ['q5.q5_grid', 'q6new_q6copy.q6new_q6copy_grid', 'array_var.array_var_grid', 'q6new.q6new_grid', 'q7.q7_grid']
107 |
108 | >>> dataset.transpose('q6new_q6copy.q6new_q6copy_grid')
109 | >>> dataset.masks()
110 | ['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']
--------------------------------------------------------------------------------
/docs/API/sites/xlsx_output_annotations.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/sites/xlsx_output_annotations.JPG
--------------------------------------------------------------------------------
/docs/API/sites/xlsx_output_groupedviews_simple.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/sites/xlsx_output_groupedviews_simple.JPG
--------------------------------------------------------------------------------
/docs/API/sites/xlsx_output_simple.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/sites/xlsx_output_simple.JPG
--------------------------------------------------------------------------------
/docs/API/sites/xlsx_toc_simple_table.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/docs/API/sites/xlsx_toc_simple_table.JPG
--------------------------------------------------------------------------------
/install_dev.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | conda remove -n qp --all
4 | conda create -n qp python=2.7 scipy
5 | source activate qp
6 | pip install -r requirements_dev.txt
7 |
8 |
--------------------------------------------------------------------------------
/quantipy/__init__.py:
--------------------------------------------------------------------------------
1 |
2 | from quantipy.core.options import set_option, OPTIONS
3 | from quantipy.core.dataset import DataSet
4 | from quantipy.core.batch import Batch
5 | from quantipy.core.link import Link
6 | from quantipy.core.view import View
7 | from quantipy.core.chain import Chain
8 | from quantipy.core.stack import Stack
9 | from quantipy.core.cluster import Cluster
10 | from quantipy.core.weights.rim import Rim
11 | from quantipy.core.weights.weight_engine import WeightEngine
12 | from quantipy.core.view_generators.view_mapper import ViewMapper
13 | from quantipy.core.view_generators.view_maps import QuantipyViews
14 | from quantipy.core.view_generators.view_specs import (net, calc, ViewManager)
15 | from quantipy.core.helpers.functions import parrot
16 | import quantipy.core.helpers.functions as helpers
17 | import quantipy.core.tools.dp as dp
18 | import quantipy.core.tools.view as v
19 |
20 | # from quantipy.sandbox import sandbox
21 |
22 | from quantipy.core.tools.dp.io import (
23 | read_quantipy, write_quantipy,
24 | read_ascribe,
25 | read_decipher,
26 | read_dimensions,write_dimensions,
27 | read_spss, write_spss)
28 |
29 | from quantipy.core.quantify.engine import Quantity, Test
30 |
31 | from quantipy.core.builds.excel.excel_painter import ExcelPainter
32 |
33 | from quantipy.core.builds.powerpoint.pptx_painter import PowerPointPainter
34 |
35 | from quantipy.version import version as __version__
36 |
37 |
--------------------------------------------------------------------------------
/quantipy/core/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/core/__init__.py
--------------------------------------------------------------------------------
/quantipy/core/builds/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/core/builds/__init__.py
--------------------------------------------------------------------------------
/quantipy/core/builds/excel/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/core/builds/excel/__init__.py
--------------------------------------------------------------------------------
/quantipy/core/builds/excel/formats/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/core/builds/excel/formats/__init__.py
--------------------------------------------------------------------------------
/quantipy/core/builds/excel/formats/logo/qplogo_invert.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/core/builds/excel/formats/logo/qplogo_invert.png
--------------------------------------------------------------------------------
/quantipy/core/builds/powerpoint/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/core/builds/powerpoint/__init__.py
--------------------------------------------------------------------------------
/quantipy/core/builds/powerpoint/templates/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/core/builds/powerpoint/templates/__init__.py
--------------------------------------------------------------------------------
/quantipy/core/builds/powerpoint/templates/default_template.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/core/builds/powerpoint/templates/default_template.pptx
--------------------------------------------------------------------------------
/quantipy/core/cache.py:
--------------------------------------------------------------------------------
1 | from collections import defaultdict
2 |
3 | class Cache(defaultdict):
4 |
5 |
6 | def __init__(self):
7 | # The 'lock_cache' raises an exception in the
8 | super(Cache, self).__init__(Cache)
9 |
10 | def __reduce__(self):
11 | return self.__class__, tuple(), None, None, self.iteritems()
12 |
13 |
14 | def set_obj(self, collection, key, obj):
15 | '''
16 | Save a Quantipy resource inside the cache.
17 |
18 | Parameters
19 | ----------
20 | collection : {'matrices', 'weight_vectors', 'quantities',
21 | 'mean_view_names', 'count_view_names'}
22 | The key of the collection the object should be placed in.
23 | key : str
24 | The reference key for the object.
25 | obj : Specific Quantipy or arbitrary Python object.
26 | The object to store inside the cache.
27 |
28 | Returns
29 | -------
30 | None
31 | '''
32 | self[collection][key] = obj
33 |
34 | def get_obj(self, collection, key):
35 | '''
36 | Look up if an object exists in the cache and return it.
37 |
38 | Parameters
39 | ----------
40 | collection : {'matrices', 'weight_vectors', 'quantities',
41 | 'mean_view_names', 'count_view_names'}
42 | The key of the collection to look into.
43 | key : str
44 | The reference key for the object.
45 |
46 | Returns
47 | -------
48 | obj : Specific Quantipy or arbitrary Python object.
49 | The cached object mapped to the passed key.
50 | '''
51 | if collection == 'matrices':
52 | return self[collection].get(key, (None, None))
53 | elif collection == 'squeezed':
54 | return self[collection].get(key, (None, None, None, None, None, None, None))
55 | else:
56 | return self[collection].get(key, None)
57 |
--------------------------------------------------------------------------------
/quantipy/core/helpers/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/core/helpers/__init__.py
--------------------------------------------------------------------------------
/quantipy/core/helpers/constants.py:
--------------------------------------------------------------------------------
1 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | ''' Constant mapping appropriate quantipy types to pandas dtypes
3 | '''
4 | DTYPE_MAP = {
5 | "float": ["float64", "float32", "float16"],
6 | "int": ["int64", "int32", "int16", "int8", "int0", "float64", "float32", "float16"],
7 | "string": ["object"],
8 | "date": ["datetime64"],
9 | "time": ["timedelta64"],
10 | "bool": ["bool"],
11 | "single": ["int64", "int32", "int16", "int8", "int0", "float64", "float32", "float16"],
12 | "dichotomous set": [],
13 | "categorical set": [],
14 | "delimited set": ["object"],
15 | "grid": []
16 | }
17 |
18 | MAPPED_PATTERN = "^[^@].*[@].*[^@]$"
--------------------------------------------------------------------------------
/quantipy/core/helpers/parrot.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/core/helpers/parrot.gif
--------------------------------------------------------------------------------
/quantipy/core/link.py:
--------------------------------------------------------------------------------
1 | #-*- coding: utf-8 -*-
2 | import numpy as np
3 | from view_generators.view_maps import QuantipyViews as View
4 |
5 |
6 | class Link(dict):
7 | """
8 | The Link object is a subclassed dictionary that generates an instance of
9 | Pandas.DataFrame for every view method applied
10 | """
11 | def __init__(self,
12 | the_filter,
13 | y,
14 | x,
15 | data_key,
16 | stack,
17 | views=None,
18 | store_view=False,
19 | create_views=True):
20 |
21 | self.filter = the_filter
22 | self.y = y
23 | self.x = x
24 | self.data_key = data_key
25 | self.stack = stack
26 |
27 | # If this variable is set to true, then the view will be transposed.
28 | self.transpose = False
29 |
30 | if isinstance(views, str):
31 | views = View(views)
32 | elif isinstance(views, list):
33 | views = View(*views)
34 | elif views is None:
35 | views = View()
36 |
37 | if store_view:
38 | self.view = views
39 |
40 | data = stack[data_key].data
41 | if create_views:
42 | if '@1' not in data.keys():
43 | data['@1'] = np.ones(len(data.index))
44 | views._apply_to(self, weights)
45 |
46 | def get_meta(self):
47 | stack = self.stack
48 | data_key = self.data_key
49 | return stack[data_key].meta
50 |
51 | def get_data(self):
52 | stack = self.stack
53 | data_key = self.data_key
54 | filter_def = self.filter
55 | return stack[data_key][filter_def].data
56 |
57 | def get_cache(self):
58 | return self.stack[self.data_key].cache
59 |
60 | def merge(self, link, views=None, overwrite=False):
61 | """
62 | Merge the views from link into self.
63 | """
64 |
65 | if views is None:
66 | views = link.keys()
67 |
68 | for vk in views:
69 | if overwrite or not vk in self:
70 | self[vk] = link.pop(vk)
71 |
72 | def __getitem__(self, key):
73 | """ The 'get' method for the Link(dict)
74 |
75 | If the 'transpose' variable is set to True THEN this method tries
76 | to transpose the result.
77 |
78 | Note: Only the numpy.T method has been implemented.
79 | """
80 | val = dict.__getitem__(self, key)
81 |
82 | if self.transpose:
83 | if "T" in dir(val):
84 | return val.T
85 | else:
86 | return val
87 | else:
88 | return val
89 |
--------------------------------------------------------------------------------
/quantipy/core/options.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # -*- coding: utf-8 -*-
3 |
4 | OPTIONS = {
5 | 'new_rules': False,
6 | 'new_chains': False,
7 | 'short_item_texts': False,
8 | 'convert_chains': False,
9 | 'fast_stack_filters': False
10 | }
11 |
12 | def set_option(option, val):
13 | """
14 | """
15 | if not option in OPTIONS:
16 | err = "'{}' is not a valid option!".format(option)
17 | raise ValueError(err)
18 | OPTIONS[option] = val
19 | return None
20 |
21 |
--------------------------------------------------------------------------------
/quantipy/core/quantify/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/core/quantify/__init__.py
--------------------------------------------------------------------------------
/quantipy/core/srv/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/core/srv/__init__.py
--------------------------------------------------------------------------------
/quantipy/core/srv/core.py:
--------------------------------------------------------------------------------
1 | import SocketServer
2 | import threading
3 | import json
4 | import time
5 | import os
6 | import shutil
7 |
8 |
9 | from shutil import copyfile
10 |
11 |
12 | def copy_html_template(name, new_string=None, old_string=None,
13 | path="core/srv/html_templates",
14 | tmp_path="core/srv/tmp"):
15 | """ Copies a file from html_templates/ to tmp/ and replaces a string
16 | in the contents if it finds it.
17 | """
18 | filepath = "{}/{path}/{name}".format(
19 | os.getcwd(), path=path, name=name)
20 |
21 | tmp_filepath = "{}/{path}/{name}".format(
22 | os.getcwd(), path=tmp_path, name=name)
23 |
24 | copyfile(filepath, tmp_filepath)
25 |
26 | if all([new_string, old_string]):
27 | with open(tmp_filepath, "w+b") as fout:
28 | with open(filepath, "r+b") as fin:
29 | for line in fin:
30 | fout.write(line.replace(old_string, new_string))
31 |
32 | def save_string_in_tmp_folder(data, filename, path="core/srv/tmp"):
33 | filepath = "{}/{path}/{name}".format(
34 | os.getcwd(), path=path, name=filename)
35 | with open(filepath, "w+b") as text_file:
36 | text_file.write(data)
37 |
38 | def open_tmp_file(filename):
39 | filepath = "{}/core/srv/tmp/{name}".format(
40 | os.getcwd(), name=filename)
41 | return open(filepath, "r+b")
42 |
43 | def cleanup_tmp_folder():
44 | folder = "{}/core/srv/tmp".format(os.getcwd())
45 | for the_file in os.listdir(folder):
46 | file_path = os.path.join(folder, the_file)
47 | try:
48 | if os.path.isfile(file_path):
49 | os.unlink(file_path)
50 | elif os.path.isdir(file_path): shutil.rmtree(file_path)
51 | except Exception, e:
52 | pass
53 | # print e
54 |
55 | def is_port_taken(host, port):
56 | """ Return True/False depending on if the port is taken or not"""
57 | socket = SocketServer.socket
58 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
59 | try:
60 | s.connect((host, port))
61 | s.shutdown(1)
62 | time.sleep(2)
63 | return True
64 | except:
65 | return False
66 |
67 | def shutdown_server(server_target):
68 | """ Spawns a thread that triggers the TCPServer.shutdown method """
69 | assassin = threading.Thread(target=server_target.shutdown)
70 | assassin.daemon = True
71 | assassin.start()
72 |
73 | def print_server_message(host, port, handler):
74 | print "Quantipy http server version 1.0"
75 | print "Serving at: http://{host}:{port}".format(host=host, port=port)
76 | print "Handler : {name}".format(name=handler.__name__)
77 |
78 | def start_server(host, port, handler):
79 | """ Starts a SimpleHTTPServer with a speciffic handler.
80 |
81 | The handler needs to trigger the TCPServer.shutdown method or
82 | else the server runs until doomsday.
83 | """
84 | httpd = SocketServer.TCPServer((host, port), handler)
85 | print_server_message(host, port, handler)
86 | httpd.serve_forever() # This is stopped by using the handler
87 |
--------------------------------------------------------------------------------
/quantipy/core/srv/handlers.py:
--------------------------------------------------------------------------------
1 | import SimpleHTTPServer
2 | import urlparse
3 | import cgi
4 |
5 | from .core import shutdown_server, save_string_in_tmp_folder
6 |
7 | class WebEditHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
8 |
9 | def do_GET(self):
10 | """ Shut down if it's a get request """
11 | if 'shutdown' in self.path:
12 | shutdown_server(server_target=self.server)
13 | SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
14 |
15 | def do_POST(self):
16 | """ Store the result in a file, shut down the serve and
17 | then continue the script """
18 | form = cgi.FieldStorage(
19 | fp=self.rfile,
20 | headers=self.headers,
21 | environ={'REQUEST_METHOD':'POST',
22 | 'CONTENT_TYPE':self.headers['Content-Type'],
23 | })
24 | for item in form.list:
25 | print item.name
26 | if item.name == "obj_json":
27 | save_string_in_tmp_folder(
28 | data=item.value,
29 | filename="obj.json")
30 | break
31 |
32 | shutdown_server(server_target=self.server)
33 | SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
34 |
--------------------------------------------------------------------------------
/quantipy/core/srv/html_templates/webedit.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | JSONEditor | Basic usage
5 |
6 |
7 |
8 |
9 |
10 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
Message
42 |
43 |
44 |
45 |
46 |
47 |
48 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/quantipy/core/srv/libs/jsoneditor/img/jsoneditor-icons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/core/srv/libs/jsoneditor/img/jsoneditor-icons.png
--------------------------------------------------------------------------------
/quantipy/core/srv/servers.py:
--------------------------------------------------------------------------------
1 | import json
2 | import webbrowser
3 | from collections import OrderedDict
4 |
5 | from .core import start_server, copy_html_template, open_tmp_file, cleanup_tmp_folder
6 | from .handlers import WebEditHandler
7 |
8 |
9 | def webeditor(obj, host="localhost", port=8000):
10 | cleanup_tmp_folder()
11 | url = "http://{host}:{port}/core/srv/tmp/webedit.html".format(
12 | host=host,
13 | port=port)
14 |
15 | json_string = json.dumps(obj, sort_keys=True)
16 | copy_html_template('webedit.html', json_string, "REPLACEJSON")
17 | tab = webbrowser.open_new_tab(url)
18 |
19 | # This runs forever and can only be shut down in the handler or by
20 | # ctr+c
21 | start_server(host=host, port=port, handler=WebEditHandler)
22 |
23 | try:
24 | obj = json.loads(
25 | open_tmp_file('obj.json').readline(),
26 | object_pairs_hook=OrderedDict)
27 | except:
28 | pass
29 |
30 | cleanup_tmp_folder()
31 | return obj
32 |
--------------------------------------------------------------------------------
/quantipy/core/tools/__init__.py:
--------------------------------------------------------------------------------
1 | import dp
2 | import view
--------------------------------------------------------------------------------
/quantipy/core/tools/dp/__init__.py:
--------------------------------------------------------------------------------
1 | import io
2 | import prep
3 | import query
--------------------------------------------------------------------------------
/quantipy/core/tools/dp/ascribe/__init__.py:
--------------------------------------------------------------------------------
1 | import reader
--------------------------------------------------------------------------------
/quantipy/core/tools/dp/ascribe/reader.py:
--------------------------------------------------------------------------------
1 |
2 | import pandas as pd
3 | import json
4 | import xmltodict
5 | import warnings
6 | from quantipy.core.tools.dp.prep import start_meta, condense_dichotomous_set
7 |
8 |
9 | def quantipy_from_ascribe(path_xml, path_txt, text_key='main'):
10 |
11 | # Read the AScribe data (tab-delimited)
12 | meta_ascribe = xmltodict.parse(open(path_xml))
13 | data_ascribe = pd.DataFrame.from_csv(
14 | path_txt,
15 | sep='\t',
16 | header=0,
17 | encoding='utf-16'
18 | )
19 | data_ascribe[data_ascribe.index.name] = data_ascribe.index
20 |
21 | # Start a Quantipy meta document
22 | meta = start_meta(text_key=text_key)
23 | meta['columns']['responseid'] = {
24 | 'name': 'responseid',
25 | 'type': 'int',
26 | 'text': {text_key: 'responseid'},
27 | 'parent': {},
28 | 'properties': {}
29 | }
30 | meta['sets']['data file']['items'] = ['columns@responseid']
31 |
32 | MultiForm = meta_ascribe['CodedQuestions']['MultiForm']
33 | if not isinstance(MultiForm, list):
34 | meta_ascribe['CodedQuestions']['MultiForm'] = [MultiForm]
35 |
36 | # Container to record the names, in order, of the resulting
37 | # coded columns
38 | coded_names = []
39 |
40 | for var in meta_ascribe['CodedQuestions']['MultiForm']:
41 | name = var['Name']
42 | if var['Answers'] is None:
43 | msg = ("The variable '%s' has no answer codes "
44 | "and will be skipped.") % (name)
45 | warnings.warn(msg)
46 | continue
47 | coded_names.append(name)
48 | coded_from = var['FormTexts']['FormText']['Title']
49 | var_text = var['FormTexts']['FormText']['Text']
50 | var_text = '' if var_text is None else var_text.replace('\n', ' ')
51 | if var_text is None: var_text = 'Label not provided'
52 | var_text = {text_key: var_text}
53 | columns = []
54 | values = []
55 | for val in var['Answers']['Answer']:
56 | value = int(val['@Precode'])
57 | if value==0:
58 | msg = (
59 | "The value 0 has been assigned to a code for the "
60 | "variable '%s'."
61 | ) % (name)
62 | warnings.warn(msg)
63 | val_text = val['Texts']['Text']['#text']
64 | val_text = '' if val_text is None else val_text.replace('\n', ' ')
65 | if val_text is None: val_text = 'Label not provided'
66 | val_text = {text_key: val_text}
67 | values.append({'value': value, 'text': val_text})
68 | columns.append('%s_%s' % (name, value))
69 |
70 | # Create a single series from the dichotomous set
71 | data_ascribe[name] = condense_dichotomous_set(
72 | data_ascribe[columns],
73 | sniff_single=True
74 | )
75 |
76 | # Determine the Quantipy type of the returned
77 | # series from its dtype (see 'sniff_sinlge' in
78 | # condense_dichotomous_set()
79 | if data_ascribe[columns].sum(axis=1).max()==1:
80 | col_type = 'single'
81 | else:
82 | col_type = 'delimited set'
83 |
84 | # Create the new Quantipy column meta
85 | column = {
86 | 'name': name,
87 | 'type': col_type,
88 | 'text': var_text,
89 | 'values': values,
90 | 'parent': {},
91 | 'properties': {}
92 | }
93 |
94 | # Add the newly defined column to the Quantipy meta
95 | meta['columns'][name] = column
96 |
97 | meta['sets']['data file']['items'].extend([
98 | 'columns@%s' % (col_name)
99 | for col_name in coded_names
100 | ])
101 |
102 | # Keep only the slice that has been converted.
103 | data = data_ascribe[[data_ascribe.index.name]+coded_names]
104 |
105 | return meta, data
106 |
--------------------------------------------------------------------------------
/quantipy/core/tools/dp/decipher/__init__.py:
--------------------------------------------------------------------------------
1 | import reader
--------------------------------------------------------------------------------
/quantipy/core/tools/dp/dimensions/__init__.py:
--------------------------------------------------------------------------------
1 | import reader, writer
--------------------------------------------------------------------------------
/quantipy/core/tools/dp/dimensions/_create_ddf.dms:
--------------------------------------------------------------------------------
1 |
2 | Event(OnBeforeJobStart)
3 |
4 | Dim fso, DM, target
5 | Set fso = CreateObject("Scripting.FileSystemObject")
6 | If fso.FileExists(MASTER_INPUT+".ddf") Then fso.DeleteFile(MASTER_INPUT+".ddf",True)
7 |
8 | End Event
9 |
10 |
11 | InputDatasource(my_MASTER_DataSource)
12 |
13 | ConnectionString = "Provider = mrOleDB.Provider.2; _
14 | Data Source=mrCsvDsc; _
15 | Location = "+MASTER_INPUT+"_paired.csv; _
16 | Initial Catalog = "+MASTER_INPUT+".mdd"
17 |
18 | End InputDatasource
19 |
20 |
21 | OutputDatasource(my_DDF_OutputDataSource)
22 |
23 | ConnectionString = "Provider=mrOleDB.Provider.2; _
24 | Data Source=mrDataFileDsc; _
25 | mr Init Overwrite=1; _
26 | Location="+MASTER_INPUT+".ddf"
27 | MetadataOutputName=MASTER_INPUT+".mdd"
28 |
29 | End OutputDatasource
30 |
31 |
32 | Event(OnJobStart)
33 |
34 | 'Line separator const.
35 | Const adCR = 13, adCRLF = -1, adLF = 10
36 |
37 | Set dmgrGlobal.CaseData = CreateObject("ADODB.Stream")
38 |
39 | dmgrGlobal.CaseData.CharSet = "utf-8"
40 | Select Case CRLF
41 | Case "CR"
42 | dmgrGlobal.CaseData.LineSeparator = adCR
43 | Case "CRLF"
44 | dmgrGlobal.CaseData.LineSeparator = adCRLF
45 | Case "LF"
46 | dmgrGlobal.CaseData.LineSeparator = adLF
47 | Case Else
48 | Debug.Log("Unknown CRLF.")
49 | End Select
50 | dmgrGlobal.CaseData.Open()
51 | dmgrGlobal.CaseData.LoadFromFile(MASTER_INPUT+"_datastore.csv")
52 |
53 | Set dmgrGlobal.Columns = dmgrGlobal.CaseData.ReadText(-2)
54 |
55 | 'Set decimal separator
56 | Dim oExcel
57 | dmgrJob.GlobalVariables.Add("DecimalSeparator")
58 | dmgrJob.GlobalVariables.DecimalSeparator = "."
59 | Set oExcel = createobject("Excel.Application")
60 | if oExcel.DecimalSeparator="," Then dmgrJob.GlobalVariables.DecimalSeparator = ","
61 |
62 | dmgrGlobal.Add("vars_failed")
63 | dmgrGlobal.Add("var_failed")
64 | dmgrGlobal.vars_failed = ""
65 |
66 | End Event
67 |
68 |
69 | Event(OnNextCase)
70 |
71 | const MaxValue = 2147483647
72 | const MinValue = -2147483648
73 |
74 | Dim i, oA, oA_value
75 | Dim columns, col, data
76 | Dim gSplit, gName, gElement, gField
77 | Dim response
78 |
79 | data = dmgrGlobal.CaseData.ReadText(-2)
80 | data = Split(data, ",")
81 | columns = Split(dmgrGlobal.Columns, ",")
82 |
83 | i = 0
84 | For Each col in columns
85 | If col.Find("{") <> -1 Then
86 | gSplit = col.Split(".")
87 | gField = gSplit[1]
88 | gSplit = gSplit[0].Split("[{")
89 | gName = gSplit[0]
90 | gElement = gSplit[1].Replace("}]", "")
91 | Set oA = dmgrJob.Questions[gName].Item[gElement].Item[gField]
92 | Else
93 | Set oA = dmgrJob.Questions[col]
94 | End If
95 | Select Case oA.QuestionDataType
96 | Case 1
97 | If data[i] = "NULL" Then
98 | oA = NULL
99 | Else
100 | oA_value=data[i]
101 | if dmgrJob.GlobalVariables.DecimalSeparator = "," Then
102 | oA_value = Replace(CText(oA_value),".",",")
103 | End If
104 | If CDouble(oA_value) > MaxValue or CDouble(oA_value) < MinValue then
105 | Debug.Log("Value: " + CText(oA_value) + " for variable: '" + oA.label + "' exceeds limit for variable of type Long. Dropping set variable")
106 | If dmgrGlobal.var_failed <> oA.label Then
107 | dmgrGlobal.vars_failed = dmgrGlobal.vars_failed + oA.label + ", "
108 | dmgrGlobal.var_failed = oA.label
109 | End If
110 | Else
111 | oA = oA_value
112 | End If
113 | End If
114 | Case 6, 7
115 | If data[i] = "NULL" Then
116 | oA = NULL
117 | Else
118 | oA_value=data[i]
119 | if dmgrJob.GlobalVariables.DecimalSeparator = "," Then
120 | oA_value = Replace(CText(oA_value),".",",")
121 | End If
122 | oA = oA_value
123 | End If
124 | Case 2
125 | oA = data[i].Replace(">_>_>", ",")
126 | If oA = "" Then oA = NULL
127 | Case 3
128 | Select Case oA.Validation.MaxValue
129 | Case 1
130 | If data[i] <> NULL Then oA = cCategorical(data[i])
131 | Case Else
132 | If data[i] <> ";" Then
133 | For Each response in Split(data[i], ";")
134 | If response <> "" Then oA = oA + cCategorical(response)
135 | Next
136 | End If
137 | End Select
138 | Case 5
139 | If data[i] = "" Then
140 | oA = Null
141 | Else
142 | Dim parts
143 | parts = data[i].Split(".")
144 | oA = cDate(parts[0])
145 | End If
146 | End Select
147 | i = i + 1
148 | Next
149 |
150 | End Event
151 |
152 | Event (OnJobEnd)
153 |
154 | If dmgrGlobal.vars_failed <> "" Then
155 | Debug.Log("**************************************************************************************************")
156 | Debug.Log("Please note: ")
157 | Debug.Log("For one or more cases a value exceeded the limit for Dimensions variable type 'Long'.")
158 | Debug.Log("For those cases setting the variable were skipped.")
159 | Debug.Log("The variables affected are: " + dmgrGlobal.vars_failed)
160 | Debug.Log("If you need those variables then change DataType from 'mr.Long' to 'mr.Double' by editing 'create_mdd [].mrs' for affected variables")
161 | Debug.Log("")
162 | End If
163 |
164 | End Event
165 |
166 |
--------------------------------------------------------------------------------
/quantipy/core/tools/dp/dimensions/dimlabels.py:
--------------------------------------------------------------------------------
1 | #-*- coding: utf-8 -*-
2 |
3 | """
4 | Created on 21 Nov 2017
5 | """
6 |
7 | import json
8 | import pandas as pd
9 | import numpy as np
10 | import quantipy as qp
11 |
12 | qp_dim_languages = {
13 | 'en-GB': 'ENG',
14 | 'sv-SE': 'SVE',
15 | 'da-DK': 'DAN',
16 | 'fi-FI': 'FIN',
17 | 'nb-NO': 'NOR',
18 | 'de-DE': 'DEU',
19 | 'fr-FR': 'FRA',
20 | 'zh-CN': 'CHS',
21 | 'id-ID': 'IND',
22 | 'ms-MY': 'MSL',
23 | 'th-TH': 'THA'
24 | }
25 |
26 |
27 | class DimLabels():
28 | """
29 | """
30 |
31 | def __init__(self, name, text_key='en-GB'):
32 |
33 | self.name = name
34 | self.text_key = text_key
35 | self.text = {}
36 | self.labels = []
37 | self.incl_languages = []
38 | self.incl_labeltypes = []
39 |
40 | def add_text(self, text_object, replace=True):
41 | if isinstance(text_object, (str, unicode)):
42 | text_object = {self.text_key: text_object}
43 | self.text = text_object
44 | self.labels_from_text(replace)
45 | self._lang_ltype_from_label(replace)
46 | return None
47 |
48 | def _lang_ltype_from_label(self, replace=True):
49 | if replace:
50 | self.incl_languages = []
51 | self.incl_labeltypes = []
52 | for lab in self.labels:
53 | if not lab.language in self.incl_languages:
54 | self.incl_languages.append(lab.language)
55 | if lab.labeltype and not lab.labeltype in self.incl_labeltypes:
56 | self.incl_labeltypes.append(lab.labeltype)
57 | return None
58 |
59 | def labels_from_text(self, replace=True):
60 | if replace: self.labels = []
61 | for item in self.text.items():
62 | if isinstance(item[1], dict):
63 | for e_item in item[1].items():
64 | dimlabel = DimLabel(e_item, item[0], self.text_key)
65 | if not self._label_exists(dimlabel):
66 | self.labels.append(dimlabel)
67 | else:
68 | dimlabel = DimLabel(item, None, self.text_key)
69 | if not self._label_exists(dimlabel):
70 | self.labels.append(dimlabel)
71 | return None
72 |
73 | def _label_exists(self, label):
74 | return any(d_l.language == label.language and
75 | d_l.labeltype == label.labeltype
76 | for d_l in self.labels)
77 |
78 |
79 | class DimLabel():
80 | """
81 | """
82 |
83 | def __init__(self, text=None, edit=None, text_key=None):
84 |
85 | self.text = ''
86 | self.language = ''
87 | self.default_lan = qp_dim_languages.get(text_key, 'ENG')
88 | self.labeltype = None
89 | if text:
90 | self.to_dim(text, edit)
91 |
92 | def to_dim(self, text, edit=None):
93 | if isinstance(text, (str, unicode)):
94 | self.language = self.default_lan
95 | self.text = text
96 | else:
97 | self.language = qp_dim_languages.get(text[0], 'ENG')
98 | self.text = text[1]
99 | self.text = self.text.replace('\n', ' ').replace('"', '')
100 | self.labeltype = edit
101 | return None
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/quantipy/core/tools/dp/dimensions/map_dim_qp_languages.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/core/tools/dp/dimensions/map_dim_qp_languages.xlsx
--------------------------------------------------------------------------------
/quantipy/core/tools/dp/spss/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/core/tools/dp/spss/__init__.py
--------------------------------------------------------------------------------
/quantipy/core/tools/view/__init__.py:
--------------------------------------------------------------------------------
1 | import agg
2 | import meta
3 | import struct
4 | import query
--------------------------------------------------------------------------------
/quantipy/core/view_generators/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/core/view_generators/__init__.py
--------------------------------------------------------------------------------
/quantipy/core/weights/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/core/weights/__init__.py
--------------------------------------------------------------------------------
/quantipy/sandbox/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/sandbox/__init__.py
--------------------------------------------------------------------------------
/quantipy/sandbox/pptx/PptxDefaultsClass.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | from pptx.util import (
4 | Emu,
5 | Pt,
6 | Cm,
7 | Inches)
8 |
9 | import pptx_defaults as pptx
10 | import re
11 |
12 | def update_dict_from_dict(update_dict, from_dict):
13 | """
14 | Updates keys in dict with values from other dict
15 | :param
16 | update_dict:
17 | from_dict:
18 | :return: None, update_dict are updated inplace
19 | """
20 | for key, value in from_dict.iteritems():
21 | if isinstance(value, dict):
22 | update_dict_from_dict(update_dict[key], from_dict[key])
23 | else:
24 | update_dict[key] = from_dict[key]
25 |
26 |
27 | class PptxDefaults(object):
28 | """
29 | Handles all defaults for Class PptxPainter
30 | """
31 |
32 | def __init__(self):
33 | self._shapes = pptx.shapes
34 | self._chart = pptx.default_chart
35 | self._charts = pptx.shapes['charts']
36 | self._textbox = pptx.default_textbox
37 | self._textboxes = pptx.shapes['textboxes']
38 | self._table = pptx.default_table
39 | self._side_table = pptx.default_side_table
40 | self._tables = pptx.shapes['tables']
41 | self._chart_bar = pptx.shapes['charts']['bar']
42 | self._chart_bar_stacked100 = pptx.shapes['charts']['bar_stacked100']
43 | self._chart_line = pptx.shapes['charts']['line']
44 | self._chart_column = pptx.shapes['charts']['column']
45 | self._chart_pie = pptx.shapes['charts']['pie']
46 | self._textbox_header = pptx.shapes['textboxes']['header']
47 | self._textbox_footer = pptx.shapes['textboxes']['footer']
48 | self._text_frame = pptx.default_textframe
49 |
50 | @property
51 | def shapes(self):
52 | return self._shapes
53 |
54 | @property
55 | def chart(self):
56 | return self._chart
57 |
58 | @property
59 | def charts(self):
60 | return self._charts
61 |
62 | @property
63 | def table(self):
64 | return self._table
65 |
66 | @property
67 | def side_table(self):
68 | return self._side_table
69 |
70 | @property
71 | def tables(self):
72 | return self._tables
73 |
74 | @property
75 | def textbox(self):
76 | return self._textbox
77 |
78 | @property
79 | def textboxes(self):
80 | return self._textboxes
81 |
82 | @property
83 | def textbox_header(self):
84 | return self._textbox_header
85 |
86 | @property
87 | def textbox_footer(self):
88 | return self._textbox_footer
89 |
90 | @property
91 | def text_frame(self):
92 | return self._text_frame
93 |
94 | def update_shape(self, shape, settings):
95 | """
96 | Updates self._[shape] with settings from matching dict
97 |
98 | Parameters
99 | ----------
100 | shape : str
101 | A string with the shape to update
102 |
103 | settings : dict
104 | A dictionary matching one or more keys in self._[shape]
105 |
106 | Returns
107 | -------
108 | None
109 | self._[shape] is updated
110 | """
111 | parameter_map = {'shapes': self._shapes,
112 | 'charts': self._charts,
113 | 'tables': self._tables,
114 | 'textboxes': self._textboxes,
115 | 'chart_bar': self._chart_bar,
116 | 'chart_bar_stacked100': self._chart_bar_stacked100,
117 | 'chart_line': self._chart_line,
118 | 'chart_column': self._chart_column,
119 | 'chart_pie': self._chart_pie,
120 | 'textbox_header': self._textbox_header,
121 | 'textbox_footer': self._textbox_footer,
122 | 'side_table': self._side_table,
123 | }
124 |
125 | available_shapes = parameter_map.keys()
126 | shape = re.sub(' +', '', shape)
127 | if shape not in available_shapes:
128 | error_text = "Shape: {} is not an available shape. \n Available shapes are {}"
129 | raise ValueError(error_text.format(shape, available_shapes))
130 |
131 | update_dict_from_dict(parameter_map[shape], settings)
--------------------------------------------------------------------------------
/quantipy/sandbox/pptx/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/quantipy/sandbox/pptx/__init__.py
--------------------------------------------------------------------------------
/quantipy/sandbox/pptx/enumerations.py:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | '''
4 | @author: Majeed.sahebzadha
5 | '''
6 |
7 | from pptx.enum.chart import(
8 | XL_CHART_TYPE,
9 | XL_LABEL_POSITION,
10 | XL_LEGEND_POSITION,
11 | XL_TICK_MARK,
12 | XL_TICK_LABEL_POSITION
13 | )
14 | from pptx.enum.dml import(
15 | MSO_THEME_COLOR,
16 | MSO_COLOR_TYPE,
17 | MSO_FILL
18 | )
19 | from pptx.enum.text import(
20 | PP_ALIGN,
21 | MSO_AUTO_SIZE,
22 | MSO_ANCHOR
23 | )
24 |
25 | #------------------------------------------------------------------------------
26 | #-------------------------------------------------------------------------------
27 |
28 | '''
29 | See: http://python-pptx.readthedocs.io/en/latest/api/enum/index.html
30 | TO DO: add individual description for each enum
31 | '''
32 |
33 | # Specifies the type of bitmap used for the fill of a shape
34 | fill_type_dct = {
35 | 'background': MSO_FILL.BACKGROUND,
36 | 'gradient': MSO_FILL.GRADIENT,
37 | 'group': MSO_FILL.GROUP,
38 | 'patterned': MSO_FILL.PATTERNED,
39 | 'picture': MSO_FILL.PICTURE,
40 | 'solid': MSO_FILL.SOLID,
41 | 'textured': MSO_FILL.TEXTURED
42 | }
43 |
44 | # Specifies where the data label is positioned
45 | data_label_pos_dct = {
46 | 'above': XL_LABEL_POSITION.ABOVE,
47 | 'below': XL_LABEL_POSITION.BELOW,
48 | 'best_fit': XL_LABEL_POSITION.BEST_FIT,
49 | 'center': XL_LABEL_POSITION.CENTER,
50 | 'inside_base': XL_LABEL_POSITION.INSIDE_BASE,
51 | 'inside_end': XL_LABEL_POSITION.INSIDE_END,
52 | 'left': XL_LABEL_POSITION.LEFT,
53 | 'mixed': XL_LABEL_POSITION.MIXED,
54 | 'outside_end': XL_LABEL_POSITION.OUTSIDE_END,
55 | 'right': XL_LABEL_POSITION.RIGHT
56 | }
57 |
58 | # Specifies the position of the legend on a chart
59 | legend_pos_dct = {
60 | 'bottom': XL_LEGEND_POSITION.BOTTOM,
61 | 'corner': XL_LEGEND_POSITION.CORNER,
62 | 'custom': XL_LEGEND_POSITION.CUSTOM,
63 | 'left': XL_LEGEND_POSITION.LEFT,
64 | 'right': XL_LEGEND_POSITION.RIGHT,
65 | 'top': XL_LEGEND_POSITION.TOP
66 | }
67 |
68 | # Specifies the position of tick-mark labels on a chart axis
69 | tick_label_pos_dct = {
70 | 'high': XL_TICK_LABEL_POSITION.HIGH,
71 | 'low': XL_TICK_LABEL_POSITION.LOW,
72 | 'next_to_axis': XL_TICK_LABEL_POSITION.NEXT_TO_AXIS,
73 | 'none': XL_TICK_LABEL_POSITION.NONE
74 | }
75 |
76 | # Specifies a type of axis tick for a chart.
77 | tick_mark_pos_dct = {
78 | 'cross': XL_TICK_MARK.CROSS, #Tick mark crosses the axis
79 | 'inside': XL_TICK_MARK.INSIDE, #Tick mark appears inside the axis
80 | 'none': XL_TICK_MARK.NONE, #No tick mark
81 | 'outside': XL_TICK_MARK.OUTSIDE #Tick mark appears outside the axis
82 | }
83 |
84 | # Specifies the vertical alignment of text in a text frame
85 | vertical_alignment_pos_dct = {
86 | 'top': MSO_ANCHOR.TOP,
87 | 'middle': MSO_ANCHOR.MIDDLE,
88 | 'bottom': MSO_ANCHOR.BOTTOM,
89 | 'mixed': MSO_ANCHOR.MIXED
90 | }
91 |
92 | # Specifies the horizontal alignment for one or more paragraphs
93 | paragraph_alignment_pos_dct = {
94 | 'center': PP_ALIGN.CENTER,
95 | 'distribute': PP_ALIGN.DISTRIBUTE,
96 | 'justify': PP_ALIGN.JUSTIFY,
97 | 'justify_low': PP_ALIGN.JUSTIFY_LOW,
98 | 'left': PP_ALIGN.LEFT,
99 | 'right': PP_ALIGN.RIGHT,
100 | 'thai_distribute': PP_ALIGN.THAI_DISTRIBUTE,
101 | 'mixed': PP_ALIGN.MIXED
102 | }
103 |
104 | # Indicates the Office theme color, one of those shown in the color gallery on the formatting ribbon
105 | theme_color_index_dct = {
106 | 'not_theme_color': MSO_THEME_COLOR.NOT_THEME_COLOR,
107 | 'accent_1': MSO_THEME_COLOR.ACCENT_1,
108 | 'accent_2': MSO_THEME_COLOR.ACCENT_2,
109 | 'accent_3': MSO_THEME_COLOR.ACCENT_3,
110 | 'accent_4': MSO_THEME_COLOR.ACCENT_4,
111 | 'accent_5': MSO_THEME_COLOR.ACCENT_5,
112 | 'accent_6': MSO_THEME_COLOR.ACCENT_6,
113 | 'background_1': MSO_THEME_COLOR.BACKGROUND_1,
114 | 'background_2': MSO_THEME_COLOR.BACKGROUND_2,
115 | 'dark_1': MSO_THEME_COLOR.DARK_1,
116 | 'dark_2': MSO_THEME_COLOR.DARK_2,
117 | 'followed_hyperlink': MSO_THEME_COLOR.FOLLOWED_HYPERLINK,
118 | 'hyperlink': MSO_THEME_COLOR.HYPERLINK,
119 | 'light_1': MSO_THEME_COLOR.LIGHT_1,
120 | 'light_2': MSO_THEME_COLOR.LIGHT_2,
121 | 'text_1': MSO_THEME_COLOR.TEXT_1,
122 | 'text_2': MSO_THEME_COLOR.TEXT_2,
123 | 'mixed': MSO_THEME_COLOR.MIXED
124 | }
125 |
126 | # Specifies the type of a chart
127 | chart_type_dct = {
128 | 'area': XL_CHART_TYPE.AREA,
129 | 'area_stacked': XL_CHART_TYPE.AREA_STACKED,
130 | 'area_stacked_100': XL_CHART_TYPE.AREA_STACKED_100,
131 | 'bar_clustered': XL_CHART_TYPE.BAR_CLUSTERED,
132 | 'bar_stacked': XL_CHART_TYPE.BAR_STACKED,
133 | 'bar_stacked_100': XL_CHART_TYPE.BAR_STACKED_100,
134 | 'column_clustered': XL_CHART_TYPE.COLUMN_CLUSTERED,
135 | 'column_stacked': XL_CHART_TYPE.COLUMN_STACKED,
136 | 'column_stacked_100': XL_CHART_TYPE.COLUMN_STACKED_100,
137 | 'doughnut': XL_CHART_TYPE.DOUGHNUT,
138 | 'doughnut_exploded': XL_CHART_TYPE.DOUGHNUT_EXPLODED,
139 | 'line': XL_CHART_TYPE.LINE,
140 | 'line_markers': XL_CHART_TYPE.LINE_MARKERS,
141 | 'line_markers_stacked': XL_CHART_TYPE.LINE_MARKERS_STACKED,
142 | 'line_markers_stacked_100': XL_CHART_TYPE.LINE_MARKERS_STACKED_100,
143 | 'line_stacked': XL_CHART_TYPE.LINE_STACKED,
144 | 'line_stacked_100': XL_CHART_TYPE.LINE_STACKED_100,
145 | 'pie': XL_CHART_TYPE.PIE,
146 | 'pie_exploded': XL_CHART_TYPE.PIE_EXPLODED,
147 | 'radar': XL_CHART_TYPE.RADAR,
148 | 'radar_filled': XL_CHART_TYPE.RADAR_FILLED,
149 | 'radar_markers': XL_CHART_TYPE.RADAR_MARKERS,
150 | 'xy_scatter': XL_CHART_TYPE.XY_SCATTER,
151 | 'xy_scatter_lines': XL_CHART_TYPE.XY_SCATTER_LINES,
152 | 'xy_scatter_lines_no_markers': XL_CHART_TYPE.XY_SCATTER_LINES_NO_MARKERS,
153 | 'xy_scatter_smooth': XL_CHART_TYPE.XY_SCATTER_SMOOTH,
154 | 'xy_scatter_smooth_no_markers': XL_CHART_TYPE.XY_SCATTER_SMOOTH_NO_MARKERS,
155 | 'bubble': XL_CHART_TYPE.BUBBLE,
156 | 'bubble_three_d_effect': XL_CHART_TYPE.BUBBLE_THREE_D_EFFECT
157 | }
158 |
--------------------------------------------------------------------------------
/quantipy/version.py:
--------------------------------------------------------------------------------
1 | version = '0.1.1'
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | .
--------------------------------------------------------------------------------
/requirements_dev.txt:
--------------------------------------------------------------------------------
1 | pytest
2 | pytest-cov
3 | pytest-xdist # allows the use of multiple cores for testing
4 | -e .
--------------------------------------------------------------------------------
/savReaderWriter/VERSION:
--------------------------------------------------------------------------------
1 | 3.3.0
2 |
--------------------------------------------------------------------------------
/savReaderWriter/__init__.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 |
4 | """
5 | savReaderWriter: A cross-platform Python interface to the IBM SPSS
6 | Statistics Input Output Module. Read or Write SPSS system files (.sav, .zsav)
7 |
8 | .. moduleauthor:: Albert-Jan Roskam
9 |
10 | """
11 |
12 | # change this to 'True' in case you experience segmentation
13 | # faults related to freeing memory.
14 | segfaults = False
15 |
16 | import os
17 | import sys
18 |
19 | try:
20 | import psyco
21 | psycoOk = True # reading 66 % faster
22 | except ImportError:
23 | psycoOk = False
24 | try:
25 | import numpy
26 | numpyOk = True
27 | except ImportError:
28 | numpyOk = False
29 |
30 | try:
31 | from cWriterow import cWriterow # writing 66 % faster
32 | cWriterowOK = True
33 | except ImportError:
34 | cWriterowOK = False
35 |
36 | __author__ = "Albert-Jan Roskam" + " " + "@".join(["fomcl", "yahoo.com"])
37 | __version__ = open(os.path.join(os.path.dirname(__file__),
38 | "VERSION")).read().strip()
39 |
40 |
41 | allFormats = {
42 | 1: (b"SPSS_FMT_A", b"Alphanumeric"),
43 | 2: (b"SPSS_FMT_AHEX", b"Alphanumeric hexadecimal"),
44 | 3: (b"SPSS_FMT_COMMA", b"F Format with commas"),
45 | 4: (b"SPSS_FMT_DOLLAR", b"Commas and floating dollar sign"),
46 | 5: (b"SPSS_FMT_F", b"Default Numeric Format"),
47 | 6: (b"SPSS_FMT_IB", b"Integer binary"),
48 | 7: (b"SPSS_FMT_PIBHEX", b"Positive integer binary - hex"),
49 | 8: (b"SPSS_FMT_P", b"Packed decimal"),
50 | 9: (b"SPSS_FMT_PIB", b"Positive integer binary unsigned"),
51 | 10: (b"SPSS_FMT_PK", b"Positive integer binary unsigned"),
52 | 11: (b"SPSS_FMT_RB", b"Floating point binary"),
53 | 12: (b"SPSS_FMT_RBHEX", b"Floating point binary hex"),
54 | 15: (b"SPSS_FMT_Z", b"Zoned decimal"),
55 | 16: (b"SPSS_FMT_N", b"N Format- unsigned with leading 0s"),
56 | 17: (b"SPSS_FMT_E", b"E Format- with explicit power of 10"),
57 | 20: (b"SPSS_FMT_DATE", b"Date format dd-mmm-yyyy"),
58 | 21: (b"SPSS_FMT_TIME", b"Time format hh:mm:ss.s"),
59 | 22: (b"SPSS_FMT_DATETIME", b"Date and Time"),
60 | 23: (b"SPSS_FMT_ADATE", b"Date format dd-mmm-yyyy"),
61 | 24: (b"SPSS_FMT_JDATE", b"Julian date - yyyyddd"),
62 | 25: (b"SPSS_FMT_DTIME", b"Date-time dd hh:mm:ss.s"),
63 | 26: (b"SPSS_FMT_WKDAY", b"Day of the week"),
64 | 27: (b"SPSS_FMT_MONTH", b"Month"),
65 | 28: (b"SPSS_FMT_MOYR", b"mmm yyyy"),
66 | 29: (b"SPSS_FMT_QYR", b"q Q yyyy"),
67 | 30: (b"SPSS_FMT_WKYR", b"ww WK yyyy"),
68 | 31: (b"SPSS_FMT_PCT", b"Percent - F followed by %"),
69 | 32: (b"SPSS_FMT_DOT", b"Like COMMA, switching dot for comma"),
70 | 33: (b"SPSS_FMT_CCA", b"User Programmable currency format"),
71 | 34: (b"SPSS_FMT_CCB", b"User Programmable currency format"),
72 | 35: (b"SPSS_FMT_CCC", b"User Programmable currency format"),
73 | 36: (b"SPSS_FMT_CCD", b"User Programmable currency format"),
74 | 37: (b"SPSS_FMT_CCE", b"User Programmable currency format"),
75 | 38: (b"SPSS_FMT_EDATE", b"Date in dd/mm/yyyy style"),
76 | 39: (b"SPSS_FMT_SDATE", b"Date in yyyy/mm/dd style")}
77 |
78 | MAXLENGTHS = {
79 | "SPSS_MAX_VARNAME": (64, "Variable name"),
80 | "SPSS_MAX_SHORTVARNAME": (8, "Short (compatibility) variable name"),
81 | "SPSS_MAX_SHORTSTRING": (8, "Short string variable"),
82 | "SPSS_MAX_IDSTRING": (64, "File label string"),
83 | "SPSS_MAX_LONGSTRING": (32767, "Long string variable"),
84 | "SPSS_MAX_VALLABEL": (120, "Value label"),
85 | "SPSS_MAX_VARLABEL": (256, "Variable label"),
86 | "SPSS_MAX_7SUBTYPE": (40, "Maximum record 7 subtype"),
87 | "SPSS_MAX_ENCODING": (64, "Maximum encoding text")}
88 |
89 | supportedDates = { # uses ISO dates wherever applicable.
90 | b"DATE": "%Y-%m-%d",
91 | b"JDATE": "%Y-%m-%d",
92 | b"EDATE": "%Y-%m-%d",
93 | b"SDATE": "%Y-%m-%d",
94 | b"DATETIME": "%Y-%m-%d %H:%M:%S",
95 | b"ADATE": "%Y-%m-%d",
96 | b"WKDAY": "%A",
97 | b"MONTH": "%B",
98 | b"MOYR": "%B %Y",
99 | b"WKYR": "%W WK %Y",
100 | b"QYR": "%m Q %Y", # %m (month) is converted to quarter, see next dict.
101 | b"TIME": "%H:%M:%S.%f",
102 | b"DTIME": "%d %H:%M:%S"}
103 |
104 | QUARTERS = {b'01': b'1', b'02': b'1', b'03': b'1',
105 | b'04': b'2', b'05': b'2', b'06': b'2',
106 | b'07': b'3', b'08': b'3', b'09': b'3',
107 | b'10': b'4', b'11': b'4', b'12': b'4'}
108 |
109 | userMissingValues = {
110 | "SPSS_NO_MISSVAL": 0,
111 | "SPSS_ONE_MISSVAL": 1,
112 | "SPSS_TWO_MISSVAL": 2,
113 | "SPSS_THREE_MISSVAL": 3,
114 | "SPSS_MISS_RANGE": -2,
115 | "SPSS_MISS_RANGEANDVAL": -3}
116 |
117 | version = __version__
118 |
119 | sys.path.insert(0, os.path.dirname(__file__))
120 | from py3k import *
121 | from error import *
122 | from generic import *
123 | from header import *
124 | from savReader import *
125 | from savWriter import *
126 | from savHeaderReader import *
127 |
128 | __all__ = ["SavReader", "SavWriter", "SavHeaderReader"]
129 |
--------------------------------------------------------------------------------
/savReaderWriter/cWriterow/__init__.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 |
4 | # stub
5 |
--------------------------------------------------------------------------------
/savReaderWriter/cWriterow/cWriterow.pyx:
--------------------------------------------------------------------------------
1 | def cWriterow(self, record):
2 | cdef int varType
3 | cdef float sysmis
4 | cdef Py_ssize_t i
5 | sysmis = self.sysmis_
6 | for i, varName in enumerate(self.varNames):
7 | varName = self.varNames[i]
8 | varType = self.varTypes[varName]
9 | if varType == 0:
10 | try:
11 | numValue = float(record[i])
12 | except ValueError:
13 | numValue = sysmis
14 | except TypeError:
15 | numValue = sysmis
16 | record[i] = numValue
17 | else:
18 | value = record[i]
19 | if self.ioUtf8_ and isinstance(value, unicode):
20 | valueX = (value).encode("utf-8")
21 | strValue = valueX
22 | else:
23 | strValue = self.pad_8_lookup[varType] % value
24 | record[i] = strValue
25 | self.record = record
26 |
--------------------------------------------------------------------------------
/savReaderWriter/cWriterow/cWriterow.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/cWriterow/cWriterow.so
--------------------------------------------------------------------------------
/savReaderWriter/cWriterow/readme.txt:
--------------------------------------------------------------------------------
1 | # cWriterow is a faster C version of the Python pyWriterow method.
2 | # It requires that Cython + a C compiler be installed (http://docs.cython.org/src/quickstart/install.html)
3 | easy_install cython # requires setuptools
4 | python setup.py build_ext --inplace
5 |
--------------------------------------------------------------------------------
/savReaderWriter/cWriterow/setup.py:
--------------------------------------------------------------------------------
1 | from distutils.core import setup
2 | from distutils.extension import Extension
3 | from Cython.Distutils import build_ext
4 | import Cython.Compiler.Options
5 | Cython.Compiler.Options.annotate = True
6 |
7 | setup(
8 | cmdclass = {'build_ext': build_ext},
9 | ext_modules = [Extension("cWriterow", ["cWriterow.pyx"])]
10 | )
11 |
--------------------------------------------------------------------------------
/savReaderWriter/debug.py:
--------------------------------------------------------------------------------
1 | import sys
2 | path = '/home/albertjan/nfs/Public/savreaderwriter'
3 | sys.path.insert(0, path)
4 | from savReaderWriter import *
5 |
6 | savFileName = '/home/albertjan/nfs/Public/savreaderwriter/savReaderWriter/test_data/Employee data.sav'
7 |
8 | with SavReader(savFileName) as reader:
9 | for line in reader:
10 | print(line)
11 | #pass
--------------------------------------------------------------------------------
/savReaderWriter/documentation/dates.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/documentation/dates.xls
--------------------------------------------------------------------------------
/savReaderWriter/documentation/formats.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/documentation/formats.xls
--------------------------------------------------------------------------------
/savReaderWriter/documentation/make.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 |
3 | REM Command file for Sphinx documentation
4 |
5 | if "%SPHINXBUILD%" == "" (
6 | set SPHINXBUILD=sphinx-build
7 | )
8 | set BUILDDIR=_build
9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
10 | set I18NSPHINXOPTS=%SPHINXOPTS% .
11 | if NOT "%PAPER%" == "" (
12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
14 | )
15 |
16 | if "%1" == "" goto help
17 |
18 | if "%1" == "help" (
19 | :help
20 | echo.Please use `make ^` where ^ is one of
21 | echo. html to make standalone HTML files
22 | echo. dirhtml to make HTML files named index.html in directories
23 | echo. singlehtml to make a single large HTML file
24 | echo. pickle to make pickle files
25 | echo. json to make JSON files
26 | echo. htmlhelp to make HTML files and a HTML help project
27 | echo. qthelp to make HTML files and a qthelp project
28 | echo. devhelp to make HTML files and a Devhelp project
29 | echo. epub to make an epub
30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
31 | echo. text to make text files
32 | echo. man to make manual pages
33 | echo. texinfo to make Texinfo files
34 | echo. gettext to make PO message catalogs
35 | echo. changes to make an overview over all changed/added/deprecated items
36 | echo. linkcheck to check all external links for integrity
37 | echo. doctest to run all doctests embedded in the documentation if enabled
38 | goto end
39 | )
40 |
41 | if "%1" == "clean" (
42 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
43 | del /q /s %BUILDDIR%\*
44 | goto end
45 | )
46 |
47 | if "%1" == "html" (
48 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
49 | if errorlevel 1 exit /b 1
50 | echo.
51 | echo.Build finished. The HTML pages are in %BUILDDIR%/html.
52 | goto end
53 | )
54 |
55 | if "%1" == "dirhtml" (
56 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
57 | if errorlevel 1 exit /b 1
58 | echo.
59 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
60 | goto end
61 | )
62 |
63 | if "%1" == "singlehtml" (
64 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
65 | if errorlevel 1 exit /b 1
66 | echo.
67 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
68 | goto end
69 | )
70 |
71 | if "%1" == "pickle" (
72 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
73 | if errorlevel 1 exit /b 1
74 | echo.
75 | echo.Build finished; now you can process the pickle files.
76 | goto end
77 | )
78 |
79 | if "%1" == "json" (
80 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
81 | if errorlevel 1 exit /b 1
82 | echo.
83 | echo.Build finished; now you can process the JSON files.
84 | goto end
85 | )
86 |
87 | if "%1" == "htmlhelp" (
88 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
89 | if errorlevel 1 exit /b 1
90 | echo.
91 | echo.Build finished; now you can run HTML Help Workshop with the ^
92 | .hhp project file in %BUILDDIR%/htmlhelp.
93 | goto end
94 | )
95 |
96 | if "%1" == "qthelp" (
97 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
98 | if errorlevel 1 exit /b 1
99 | echo.
100 | echo.Build finished; now you can run "qcollectiongenerator" with the ^
101 | .qhcp project file in %BUILDDIR%/qthelp, like this:
102 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\savReaderWriter.qhcp
103 | echo.To view the help file:
104 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\savReaderWriter.ghc
105 | goto end
106 | )
107 |
108 | if "%1" == "devhelp" (
109 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
110 | if errorlevel 1 exit /b 1
111 | echo.
112 | echo.Build finished.
113 | goto end
114 | )
115 |
116 | if "%1" == "epub" (
117 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
118 | if errorlevel 1 exit /b 1
119 | echo.
120 | echo.Build finished. The epub file is in %BUILDDIR%/epub.
121 | goto end
122 | )
123 |
124 | if "%1" == "latex" (
125 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
126 | if errorlevel 1 exit /b 1
127 | echo.
128 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
129 | goto end
130 | )
131 |
132 | if "%1" == "text" (
133 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
134 | if errorlevel 1 exit /b 1
135 | echo.
136 | echo.Build finished. The text files are in %BUILDDIR%/text.
137 | goto end
138 | )
139 |
140 | if "%1" == "man" (
141 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
142 | if errorlevel 1 exit /b 1
143 | echo.
144 | echo.Build finished. The manual pages are in %BUILDDIR%/man.
145 | goto end
146 | )
147 |
148 | if "%1" == "texinfo" (
149 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
150 | if errorlevel 1 exit /b 1
151 | echo.
152 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
153 | goto end
154 | )
155 |
156 | if "%1" == "gettext" (
157 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
158 | if errorlevel 1 exit /b 1
159 | echo.
160 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
161 | goto end
162 | )
163 |
164 | if "%1" == "changes" (
165 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
166 | if errorlevel 1 exit /b 1
167 | echo.
168 | echo.The overview file is in %BUILDDIR%/changes.
169 | goto end
170 | )
171 |
172 | if "%1" == "linkcheck" (
173 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
174 | if errorlevel 1 exit /b 1
175 | echo.
176 | echo.Link check complete; look for any errors in the above output ^
177 | or in %BUILDDIR%/linkcheck/output.txt.
178 | goto end
179 | )
180 |
181 | if "%1" == "doctest" (
182 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
183 | if errorlevel 1 exit /b 1
184 | echo.
185 | echo.Testing of doctests in the sources finished, look at the ^
186 | results in %BUILDDIR%/doctest/output.txt.
187 | goto end
188 | )
189 |
190 | :end
191 |
--------------------------------------------------------------------------------
/savReaderWriter/documentation/platforms.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/documentation/platforms.xls
--------------------------------------------------------------------------------
/savReaderWriter/error.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 |
4 | import os
5 | import warnings
6 |
7 | from savReaderWriter import *
8 |
9 | retcodes = {
10 | 0: "SPSS_OK",
11 | 1: "SPSS_FILE_OERROR",
12 | 2: "SPSS_FILE_WERROR",
13 | 3: "SPSS_FILE_RERROR",
14 | 4: "SPSS_FITAB_FULL",
15 | 5: "SPSS_INVALID_HANDLE",
16 | 6: "SPSS_INVALID_FILE",
17 | 7: "SPSS_NO_MEMORY",
18 | 8: "SPSS_OPEN_RDMODE",
19 | 9: "SPSS_OPEN_WRMODE",
20 | 10: "SPSS_INVALID_VARNAME",
21 | 11: "SPSS_DICT_EMPTY",
22 | 12: "SPSS_VAR_NOTFOUND",
23 | 13: "SPSS_DUP_VAR",
24 | 14: "SPSS_NUME_EXP",
25 | 15: "SPSS_STR_EXP",
26 | 16: "SPSS_SHORTSTR_EXP",
27 | 17: "SPSS_INVALID_VARTYPE",
28 | 18: "SPSS_INVALID_MISSFOR",
29 | 19: "SPSS_INVALID_COMPSW",
30 | 20: "SPSS_INVALID_PRFOR",
31 | 21: "SPSS_INVALID_WRFOR",
32 | 22: "SPSS_INVALID_DATE",
33 | 23: "SPSS_INVALID_TIME",
34 | 24: "SPSS_NO_VARIABLES",
35 | 27: "SPSS_DUP_VALUE",
36 | 28: "SPSS_INVALID_CASEWGT",
37 | 30: "SPSS_DICT_COMMIT",
38 | 31: "SPSS_DICT_NOTCOMMIT",
39 | 33: "SPSS_NO_TYPE2",
40 | 41: "SPSS_NO_TYPE73",
41 | 45: "SPSS_INVALID_DATEINFO",
42 | 46: "SPSS_NO_TYPE999",
43 | 47: "SPSS_EXC_STRVALUE",
44 | 48: "SPSS_CANNOT_FREE",
45 | 49: "SPSS_BUFFER_SHORT",
46 | 50: "SPSS_INVALID_CASE",
47 | 51: "SPSS_INTERNAL_VLABS",
48 | 52: "SPSS_INCOMPAT_APPEND",
49 | 53: "SPSS_INTERNAL_D_A",
50 | 54: "SPSS_FILE_BADTEMP",
51 | 55: "SPSS_DEW_NOFIRST",
52 | 56: "SPSS_INVALID_MEASURELEVEL",
53 | 57: "SPSS_INVALID_7SUBTYPE",
54 | 58: "SPSS_INVALID_VARHANDLE",
55 | 59: "SPSS_INVALID_ENCODING",
56 | 60: "SPSS_FILES_OPEN",
57 | 70: "SPSS_INVALID_MRSETDEF",
58 | 71: "SPSS_INVALID_MRSETNAME",
59 | 72: "SPSS_DUP_MRSETNAME",
60 | 73: "SPSS_BAD_EXTENSION",
61 | 74: "SPSS_INVALID_EXTENDEDSTRING",
62 | 75: "SPSS_INVALID_ATTRNAME",
63 | 76: "SPSS_INVALID_ATTRDEF",
64 | 77: "SPSS_INVALID_MRSETINDEX",
65 | 78: "SPSS_INVALID_VARSETDEF",
66 | 79: "SPSS_INVALID_ROLE",
67 |
68 | -15: "SPSS_EMPTY_DEW",
69 | -14: "SPSS_NO_DEW",
70 | -13: "SPSS_EMPTY_MULTRESP",
71 | -12: "SPSS_NO_MULTRESP",
72 | -11: "SPSS_NO_DATEINFO",
73 | -10: "SPSS_NO_CASEWGT",
74 | -9: "SPSS_NO_LABEL",
75 | -8: "SPSS_NO_LABELS",
76 | -7: "SPSS_EMPTY_VARSETS",
77 | -6: "SPSS_NO_VARSETS",
78 | -5: "SPSS_FILE_END",
79 | -4: "SPSS_EXC_VALLABEL",
80 | -3: "SPSS_EXC_LEN120",
81 | -2: "SPSS_EXC_VARLABEL",
82 | -1: "SPSS_EXC_LEN64"}
83 |
84 | class SPSSIOError(Exception):
85 | """
86 | Error class for the IBM SPSS Statistics Input Output Module
87 | """
88 | def __init__(self, msg="Unknown", retcode=None):
89 | self.retcode = retcode
90 | Exception.__init__(self, msg)
91 |
92 | class SPSSIOWarning(UserWarning):
93 | """
94 | Warning class for the IBM SPSS Statistics Input Output Module
95 |
96 | If the environment variable SAVRW_DISPLAY_WARNS is undefined or 0
97 | (False) warnings are ignored. If it is 1 (True) warnings (non-fatal
98 | exceptions) are displayed once for every location where they occur.
99 | """
100 | pass
101 |
102 | # Warnings are usually harmless!
103 | action = os.environ.get("SAVRW_DISPLAY_WARNS")
104 | action = action.lower() if action else "ignore"
105 | actions = ("error", "ignore", "always", "default", "module", "once")
106 | if action not in actions:
107 | raise ValueError("If set, environment variable SAVRW_DISPLAY_WARNS must be"
108 | " one of the following values:\n" % ", ".join(actions))
109 | warnings.simplefilter(action, SPSSIOWarning)
110 |
111 | def checkErrsWarns(msg, retcode):
112 | """Throws a warning if retcode < 0 (and warnings are not ignored),
113 | and throws an error if retcode > 0. Returns None if retcode == 0"""
114 | if not retcode:
115 | return
116 | msg += " [%s]" % retcodes.get(retcode, retcode)
117 | if retcode > 0:
118 | raise SPSSIOError(msg, retcode)
119 | elif retcode < 0:
120 | warnings.warn(msg, SPSSIOWarning, stacklevel=2)
121 |
--------------------------------------------------------------------------------
/savReaderWriter/py3k.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 | import sys
4 | import functools
5 | from ctypes import c_char_p
6 |
7 | isPy3k = sys.version_info[0] > 2
8 |
9 | try:
10 | unicode
11 | except NameError:
12 | basestring = unicode = str # Python 3
13 |
14 | try:
15 | xrange
16 | except NameError:
17 | xrange = range
18 |
19 | # bytes keyword has a second argument in Python 3
20 | if isPy3k:
21 | bytez = functools.partial(bytes, encoding="utf-8")
22 | else:
23 | bytez = bytes
24 |
25 | def bytify(encoding):
26 | if isPy3k:
27 | def func(value):
28 | return bytes(value, encoding)
29 | else:
30 | def func(value):
31 | return bytes(value)
32 | func.__doc__ = "bytes wrapper for python 2 and 3"
33 | return func
34 |
35 | # ctypes.c_char_p does not take unicode strings
36 | if isPy3k:
37 | def c_char_py3k(s):
38 | s = s.encode("utf-8") if isinstance(s, str) else s
39 | return c_char_p(s)
40 | else:
41 | def c_char_py3k(s):
42 | return c_char_p(s)
43 | c_char_py3k.__doc__ = ("Wrapper for ctypes.c_char_p; in Python 3.x, s is converted to a utf-8 "
44 | "encoded bytestring, in Python 2, it does nothing")
45 |
46 | # Python 3: __unicode__ special method is now called __str__
47 | # and __str__ is now called __bytes__
48 | if isPy3k:
49 | def implements_to_string(cls):
50 | if "__str__" in cls.__dict__:
51 | cls.__dict__["__str__"].__name__ = "__bytes__"
52 | cls.__bytes__ = cls.__dict__["__str__"]
53 | if "__unicode__" in cls.__dict__:
54 | cls.__dict__["__unicode__"].__name__ = "__str__"
55 | cls.__str__ = cls.__dict__["__unicode__"]
56 | return cls
57 | else:
58 | implements_to_string = lambda cls: cls
59 | implements_to_string.__doc__ = ("class decorator that replaces __unicode__ "
60 | "and __str__ methods in Python 2 with __str__"
61 | " and __bytes__ methods, respectively, in "
62 | "Python 3")
63 |
64 | # implement rich comparison operators in Python 3 (SavReader)
65 | if isPy3k:
66 | def rich_comparison(cls):
67 | assert hasattr(cls, "__cmp__")
68 | def __eq__(self, other):
69 | return self.__cmp__(other) == 0
70 | def __ne__(self, other):
71 | return not self.__eq__(other)
72 | def __le__(self, other):
73 | return self.__cmp__(other) in (0, -1)
74 | def __lt__(self, other):
75 | return self.__cmp__(other) == -1
76 | def __ge__(self, other):
77 | return self.__eq__(other) and not self.__lt__(other)
78 | def __gt__(self, other):
79 | return not self.__eq__(other) and not self.__lt__(other)
80 | for op in "__eq__ __ne__ __le__ __lt__ __ge__ __gt__".split():
81 | setattr(cls, op, eval(op))
82 | return cls
83 | else:
84 | rich_comparison = lambda cls: cls
85 | rich_comparison.__doc__ = ("class decorator that implements rich comparison "
86 | "operators as this can not be done with __cmp__ in "
87 | "Python 3. Does nothing in Python 2.")
88 |
89 |
90 |
--------------------------------------------------------------------------------
/savReaderWriter/spssio/documents/Input-Output Module.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/spssio/documents/Input-Output Module.pdf
--------------------------------------------------------------------------------
/savReaderWriter/spssio/lin64/libicudata.so.48.1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/spssio/lin64/libicudata.so.48.1
--------------------------------------------------------------------------------
/savReaderWriter/spssio/lin64/libicui18n.so.48.1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/spssio/lin64/libicui18n.so.48.1
--------------------------------------------------------------------------------
/savReaderWriter/spssio/lin64/libicuuc.so.48.1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/spssio/lin64/libicuuc.so.48.1
--------------------------------------------------------------------------------
/savReaderWriter/spssio/lin64/libspssdio.so.1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/spssio/lin64/libspssdio.so.1
--------------------------------------------------------------------------------
/savReaderWriter/spssio/lin64/libspssjdio.so.1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/spssio/lin64/libspssjdio.so.1
--------------------------------------------------------------------------------
/savReaderWriter/spssio/lin64/libzlib123spss.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/spssio/lin64/libzlib123spss.so
--------------------------------------------------------------------------------
/savReaderWriter/spssio/win64/icudt48.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/spssio/win64/icudt48.dll
--------------------------------------------------------------------------------
/savReaderWriter/spssio/win64/icuin48.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/spssio/win64/icuin48.dll
--------------------------------------------------------------------------------
/savReaderWriter/spssio/win64/icuuc48.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/spssio/win64/icuuc48.dll
--------------------------------------------------------------------------------
/savReaderWriter/spssio/win64/spssio64.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/spssio/win64/spssio64.dll
--------------------------------------------------------------------------------
/savReaderWriter/spssio/win64/spssio64.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/spssio/win64/spssio64.lib
--------------------------------------------------------------------------------
/savReaderWriter/spssio/win64/spssjdio.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/spssio/win64/spssjdio.dll
--------------------------------------------------------------------------------
/savReaderWriter/spssio/win64/zlib123spss.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/spssio/win64/zlib123spss.dll
--------------------------------------------------------------------------------
/savReaderWriter/test_data/spssio_test.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/test_data/spssio_test.pdf
--------------------------------------------------------------------------------
/savReaderWriter/test_data/spssio_test.sps:
--------------------------------------------------------------------------------
1 | ******************************************************************************.
2 | * Title: Spss syntax to create test date for SavReaderWriter.py.
3 | * Author: Albert-Jan Roskam.
4 | * Date: december 2012.
5 | ******************************************************************************.
6 |
7 | FILE HANDLE path /NAME = "%temp%".
8 | OMS /SELECT ALL /DESTINATION FORMAT=PDF OUTFILE='path/spssio_test.pdf'.
9 |
10 | * make some test data.
11 | SET SEED = 4321.
12 |
13 | DATA LIST LIST /ID Age Region Income1 Income2 Income3.
14 | BEGIN DATA
15 | 1 27 1 35500 42700 40250
16 | 2 34 2 72300 75420 81000
17 | 3 50 1 85400 82900 84350
18 | 4 27 1 35500 42700 40250
19 | 5 27 1 35500 42700 40250
20 | 6 34 2 72300 75420 81000
21 | 7 34 2 72300 75420 81000
22 | 8 34 2 72300 75420 81000
23 | 9 50 1 85400 82900 84350
24 | END DATA.
25 |
26 | COMPUTE AvgIncome=MEAN(Income1, Income2, Income3).
27 | COMPUTE MaxIncome=MAX(Income1, Income2, Income3).
28 | COMPUTE AGE2 = AGE.
29 | COMPUTE AGE3 = AGE.
30 | DO REPEAT #X = SEX V1 TO V3.
31 | COMPUTE #X = RND(UNIFORM(1)).
32 | END REPEAT PRINT.
33 | IF ( MOD($casenum, 2) EQ 0 ) income3 = $sysmis.
34 | COMPUTE someDate = DATE.DMY(21, 12, 2012). /* dooms day ;-).
35 |
36 | **********.
37 | * Below are the various Spss dictionary items, in the order in which they
38 | * appear in the Header class and the SavWriter constructor.
39 |
40 | **********.
41 | STRING aShortStringVar (a1) aLongStringVar (A100).
42 | COMPUTE aShortStringVar = "x".
43 | IF ( MOD($casenum, 2) EQ 0 ) aShortStringVar = "y".
44 | COMPUTE aLongStringVar = "qwertyuiopasdfghjklzxcvbnm,./".
45 |
46 | **********.
47 | VALUE LABELS age 27 '27 y.o. ' 34 '34 y.o.' 50 '50 y.o.'
48 | / aShortStringVar 'x' 'someValue label'.
49 |
50 | **********.
51 |
52 | VARIABLE LABEL age 'How old are you?'
53 | / region 'What region do you live'
54 | / aShortStringVar 'Some mysterious short stringVar'
55 | / aLongStringVar 'Some mysterious long stringVar'.
56 |
57 | **********.
58 | FORMATS id (N6) age (F3) someDate (ADATE40).
59 |
60 | **********.
61 | MISSING VALUES income1 (LO THRU -1). /* range (lower, upper).
62 | MISSING VALUES income2 (LO THRU -1, 999). /* range + value.
63 | MISSING VALUES income3 (999, 888, 777). /* thee values.
64 | MISSING VALUES age (0 THRU 18).
65 | MISSING VALUES aShortStringVar ("x", "y").
66 |
67 | **********.
68 | VARIABLE LEVEL sex (NOMINAL) income1 (SCALE).
69 |
70 | **********.
71 | VARIABLE WIDTH ID Age Region (10) Income1 Income2 (14) Income3 (15) someDate (13).
72 |
73 | **********.
74 | VARIABLE ALIGNMENT ID Age Region (left) Income1 Income2 (right) Income3 (center).
75 |
76 | **********.
77 | * Variable Sets are only visible in the user interface dialog boxes and the Data Editor. They cannot be used in syntax .
78 | * I added two sets (1) incomes --> Income1 Income2 Income3 (2) ages --> age, age2.
79 |
80 | **********.
81 | VARIABLE ROLE /INPUT age /TARGET income1 income2 income3 /PARTITION region.
82 |
83 | **********.
84 | VARIABLE ATTRIBUTE
85 | VARIABLES = AvgIncome
86 | ATTRIBUTE = Formula('mean(Income1, Income2, Income3)') /
87 | VARIABLES = MaxIncome
88 | ATTRIBUTE = Formula('max(Income1, Income2, Income3)') /
89 | VARIABLES = AvgIncome MaxIncome
90 | ATTRIBUTE = DerivedFrom[1]('Income1')
91 | DerivedFrom[2]('Income2')
92 | DerivedFrom[3]('Income3') /
93 | VARIABLES = ALL ATTRIBUTE=Notes('').
94 | DISPLAY ATTRIBUTES.
95 |
96 | **********.
97 | DATAFILE ATTRIBUTE ATTRIBUTE=VersionNumber ('1').
98 |
99 | **********.
100 | FILE LABEL "This is a file label".
101 |
102 | COMPUTE weightVar = 1.
103 | WEIGHT BY weightVar.
104 |
105 | **********.
106 | ** Multiple response sets.
107 | * category groups.
108 | MRSETS
109 | /MCGROUP NAME=$incomes
110 | LABEL='three kinds of income'
111 | VARIABLES=Income1 Income2 Income3
112 | /DISPLAY NAME=[$incomes].
113 |
114 | * dichotomy groups.
115 | MRSETS
116 | /MDGROUP NAME=$V CATEGORYLABELS=VARLABELS VARIABLES=v1 v2 v3 VALUE=1
117 | /DISPLAY NAME=[$V].
118 |
119 | CTABLES
120 | /VLABELS VARIABLES=sex $V DISPLAY=DEFAULT
121 | /TABLE $V [COUNT F40.0, COLPCT.COUNT PCT40.1, COLPCT.TOTALN PCT40.1] BY sex
122 | /CATEGORIES VARIABLES=sex ORDER=A KEY=VALUE EMPTY=EXCLUDE
123 | /CATEGORIES VARIABLES=$V EMPTY=INCLUDE TOTAL=YES POSITION=AFTER.
124 |
125 | ** category groups.
126 | MRSETS
127 | /MCGROUP NAME=$incomes LABEL='three kinds of income' VARIABLES=Income1
128 | Income2 Income3 Age AGE2 AGE3
129 | /MCGROUP NAME=$ages LABEL='the ages' VARIABLES=Age AGE2 AGE3
130 | /DISPLAY NAME=[$incomes $ages].
131 |
132 | CTABLES
133 | /VLABELS VARIABLES=SEX $ages DISPLAY=DEFAULT
134 | /TABLE $ages [COUNT F40.0] BY SEX
135 | /CATEGORIES VARIABLES=SEX $ages ORDER=A KEY=VALUE EMPTY=EXCLUDE.
136 |
137 | **********.
138 | DATE YEAR 2012 QUARTER 4 4 MONTH 12 12.
139 |
140 | * The following new variables are being created:.
141 | * Name Label.
142 | * YEAR_ YEAR, not periodic.
143 | * QUARTER_ QUARTER, period 4.
144 | * MONTH_ MONTH, period 12.
145 | * DATE_ Date. Format: "MMM YYYY".
146 |
147 | **********.
148 | * Add document.
149 | ADD DOCUMENT "This is a an'add document' entry".
150 | DISPLAY DOCUMENTS.
151 |
152 | **********.
153 | DISPLAY DICTIONARY.
154 |
155 | SAVE OUTFILE = "path/spssio_test.sav" / COMPRESSED.
156 | OUTPUT SAVE OUTFILE = "path/spssio_test.spv".
157 |
158 | OMSEND.
159 |
--------------------------------------------------------------------------------
/savReaderWriter/test_data/spssio_test.spv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/test_data/spssio_test.spv
--------------------------------------------------------------------------------
/savReaderWriter/test_data/zlib_compressed.zsav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/savReaderWriter/test_data/zlib_compressed.zsav
--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
1 | [aliases]
2 | test=pytest
3 |
4 | [tool:pytest]
5 | norecursedirs=*egg .eggs .idea data debug
6 | #addopts=--cov quantipy
7 | filterwarnings = ignore::DeprecationWarning
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # coding: utf-8
3 |
4 | import sys
5 | from setuptools import setup, find_packages
6 |
7 | versions = dict(numpy='1.11.3',
8 | scipy='0.18.1',
9 | pandas='0.19.2',
10 | ftfy='4.4.3')
11 |
12 | precisions = dict(numpy='==',
13 | scipy='==',
14 | pandas='==',
15 | ftfy='==')
16 |
17 | libs = ['numpy',
18 | 'scipy',
19 | 'pandas',
20 | 'ftfy',
21 | 'xmltodict',
22 | 'lxml',
23 | 'xlsxwriter',
24 | # 'pillow',
25 | 'prettytable',
26 | 'decorator',
27 | 'watchdog',
28 | 'requests',
29 | 'python-pptx',
30 | 'functools32']
31 |
32 | def version_libs(libs, precisions, versions):
33 | return [lib + precisions[lib] + versions[lib]
34 | if lib in versions.keys() else lib
35 | for lib in libs]
36 |
37 | if sys.platform == 'win32':
38 | INSTALL_REQUIRES = version_libs(libs[2:], precisions, versions)
39 | else:
40 | INSTALL_REQUIRES = version_libs(libs, precisions, versions)
41 |
42 | setup(name='quantipy',
43 | version='0.1.1',
44 | # author='',
45 | # author_email='',
46 | packages=find_packages(exclude=['tests']),
47 | include_package_data=True,
48 | install_requires=INSTALL_REQUIRES,
49 | )
50 |
--------------------------------------------------------------------------------
/tests/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | tests
4 |
5 |
6 |
7 |
8 |
9 | org.python.pydev.PyDevBuilder
10 |
11 |
12 |
13 |
14 |
15 | com.aptana.projects.webnature
16 | org.python.pydev.pythonNature
17 |
18 |
19 |
--------------------------------------------------------------------------------
/tests/.pydevproject:
--------------------------------------------------------------------------------
1 |
2 |
3 | Default
4 | python 2.7
5 |
6 |
--------------------------------------------------------------------------------
/tests/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/tests/__init__.py
--------------------------------------------------------------------------------
/tests/basic.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/tests/basic.xlsx
--------------------------------------------------------------------------------
/tests/complex_0.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/tests/complex_0.xlsx
--------------------------------------------------------------------------------
/tests/complex_1.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/tests/complex_1.xlsx
--------------------------------------------------------------------------------
/tests/complex_2.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/tests/complex_2.xlsx
--------------------------------------------------------------------------------
/tests/complex_3.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/tests/complex_3.xlsx
--------------------------------------------------------------------------------
/tests/engine_B_data.csv:
--------------------------------------------------------------------------------
1 | ,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
2 | 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
3 | 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
4 | 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
5 | 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
6 | 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
7 | 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
8 | 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
9 | 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
10 | 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
11 | 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
12 | 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
13 | 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
14 | 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
15 | 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
16 | 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
17 | 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
18 | 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
19 | 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
20 | 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
21 | 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
22 |
--------------------------------------------------------------------------------
/tests/example.csv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Quantipy/quantipy/82ef628d089ea9dbc47c91e842e50dd9e87bb29e/tests/example.csv
--------------------------------------------------------------------------------
/tests/test_a.py:
--------------------------------------------------------------------------------
1 | import pdb;
2 | import unittest
3 | import quantipy as qp
4 | pass
5 |
--------------------------------------------------------------------------------
/tests/test_helper.py:
--------------------------------------------------------------------------------
1 | from collections import defaultdict
2 |
3 | def create_attribute_dict(obj):
4 | """ Takes a dict object and returns a ordereddict with the attributes
5 | from the object stored in the ['__dict__'] location
6 |
7 | Example:
8 | >> ...
9 | >> attr = create_attribute_dict(stack)
10 | >> attr.keys()
11 | ['__dict__', 'Jan']
12 | >> attr['__dict__']
13 | {'name':'The Stack Name',
14 | 'stack_pos':'stack_root',
15 | 'encoding':'UTF-8'
16 | ... ...
17 | }
18 |
19 | """
20 | attributes = defaultdict(dict)
21 | if isinstance(obj, dict):
22 | for key in obj.keys():
23 | attr_dict = defaultdict(dict)
24 | if hasattr(obj[key], '__dict__'):
25 | for attr in obj.__dict__:
26 | if attr not in ['parent', 'view', 'data', 'stack', '_OrderedDict__root', '_OrderedDict__map']:
27 | attr_dict[attr] = obj.__dict__[attr]
28 | attributes['__dict__'] = attr_dict
29 | attributes[key] = create_attribute_dict(obj[key])
30 | return attributes
31 |
--------------------------------------------------------------------------------
/tests/test_io_dimensions.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import os.path
3 | import quantipy as qp
4 | import copy
5 | from quantipy.core.tools.dp.dimensions.dimlabels import (
6 | qp_dim_languages,
7 | DimLabels)
8 |
9 |
10 | def _get_dataset():
11 | path = os.path.dirname(os.path.abspath(__file__)) + '/'
12 | name = 'Example Data (A)'
13 | casedata = '{}.csv'.format(name)
14 | metadata = '{}.json'.format(name)
15 | dataset = qp.DataSet(name, False)
16 | dataset.set_verbose_infomsg(False)
17 | dataset.set_verbose_errmsg(False)
18 | dataset.read_quantipy(path+metadata, path+casedata)
19 | return dataset
20 |
21 | def loop_for_text_objs(obj, func, name=None):
22 | if isinstance(obj, dict):
23 | for k, v in obj.items():
24 | if k == 'text' and isinstance(v, dict):
25 | func(copy.deepcopy(v), name)
26 | else:
27 | loop_for_text_objs(v, func, k)
28 | elif isinstance(obj, list):
29 | for o in obj:
30 | loop_for_text_objs(o, func, name)
31 |
32 | class TestDimLabels(unittest.TestCase):
33 |
34 | def _test_dimlabels(self, x, name):
35 | d_labels = DimLabels(name, 'de-DE')
36 | d_labels.add_text(x)
37 | languages = {v: k for k, v in qp_dim_languages.items()}
38 | for lab in d_labels.labels:
39 | t1 = lab.default_lan == 'DEU'
40 | if lab.labeltype:
41 | t2 = lab.text == x[lab.labeltype].pop(languages[lab.language])
42 | if not x[lab.labeltype]: del x[lab.labeltype]
43 | else:
44 | t2 = lab.text == x.pop(languages[lab.language])
45 | self.assertTrue(t1 and t2)
46 | self.assertEqual({}, x)
47 |
48 | def test_dimlabels(self):
49 | dataset = _get_dataset()
50 | dataset.set_variable_text('q1', 'test label', 'en-GB', 'x')
51 | dataset.set_value_texts('q2b', dict(dataset.values('q2b')), 'sv-SE')
52 | loop_for_text_objs(dataset._meta, self._test_dimlabels)
53 |
54 |
--------------------------------------------------------------------------------
/tests/test_link.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import os.path
3 | import pandas as pd
4 | # import numpy as np
5 | from quantipy.core.link import Link
6 | from quantipy.core.stack import Stack
7 | from quantipy.core.helpers.functions import load_json
8 | from quantipy.core.view_generators.view_maps import QuantipyViews
9 |
10 | class TestLinkObject(unittest.TestCase):
11 |
12 | # stack.add_link(x='q1', y=y, views=mean_views.subset('m1to6'), weights=weight)
13 |
14 | def setUp(self):
15 | self.path = './tests/'
16 | # self.path = ''
17 | project_name = 'Example Data (A)'
18 |
19 | # Load Example Data (A) data and meta into self
20 | name_data = '%s.csv' % (project_name)
21 | path_data = '%s%s' % (self.path, name_data)
22 | self.example_data_A_data = pd.DataFrame.from_csv(path_data)
23 | name_meta = '%s.json' % (project_name)
24 | path_meta = '%s%s' % (self.path, name_meta)
25 | self.example_data_A_meta = load_json(path_meta)
26 |
27 | # The minimum list of variables required to populate a stack with all single*delimited set variations
28 | self.minimum = ['q2b', 'Wave', 'q2', 'q3', 'q5_1']
29 |
30 | self.setup_stack_Example_Data_A()
31 |
32 | def test_link_is_a_subclassed_dict(self):
33 | dk = self.stack.name
34 | fk = 'no_filter'
35 | xk = self.minimum
36 | yk = ['@'] + self.minimum
37 |
38 | for x in xk:
39 | for y in yk:
40 | link = self.stack[dk][fk][x][y]
41 | self.assertIsInstance(link, dict)
42 | self.assertIsInstance(link, Link)
43 |
44 | def test_link_behaves_like_a_dict(self):
45 |
46 | dk = self.stack.name
47 | fk = 'no_filter'
48 | xk = self.minimum
49 | yk = ['@'] + self.minimum
50 |
51 | key = "some_key_name"
52 | value = "some_value"
53 |
54 | for x in xk:
55 | for y in yk:
56 | link = self.stack[dk][fk][x][y]
57 | link[key] = value
58 | self.assertIn(
59 | key,
60 | link.keys(),
61 | msg="Link should have key {data_key}, but has {link_keys}".format(
62 | data_key=key,
63 | link_keys=link.keys()
64 | )
65 | )
66 |
67 | def test_get_meta(self):
68 |
69 | dk = self.stack.name
70 | fk = 'no_filter'
71 | xk = self.minimum
72 | yk = ['@'] + self.minimum
73 |
74 | #test returned meta against stack meta
75 | for x in xk:
76 | for y in yk:
77 | link = self.stack[dk][fk][x][y]
78 | self.assertEqual(link.get_meta(), self.stack[dk].meta)
79 |
80 | def test_get_data(self):
81 |
82 | dk = self.stack.name
83 | fk = 'no_filter'
84 | xk = self.minimum
85 | yk = ['@'] + self.minimum
86 |
87 | stack_data = self.stack[dk][fk].data
88 |
89 | #test returned data against stack data
90 | for x in xk:
91 | for y in yk:
92 | link_data = self.stack[dk][fk][x][y].get_data()
93 | self.assertTrue(link_data is stack_data)
94 |
95 | @classmethod
96 | def tearDownClass(self):
97 | self.stack = Stack("StackName")
98 | filepath ='./tests/'+self.stack.name+'.stack'
99 | if os.path.exists(filepath):
100 | os.remove(filepath)
101 |
102 | def is_empty(self, any_structure):
103 | if any_structure:
104 | #print('Structure is not empty.')
105 | return False
106 | else:
107 | #print('Structure is empty.')
108 | return True
109 |
110 | def create_key_stack(self, branch_pos="data"):
111 | """ Creates a dictionary that has the structure of the keys in the Stack
112 | It is used to loop through the stack without affecting it.
113 | """
114 | key_stack = {}
115 | for data_key in self.stack:
116 | key_stack[data_key] = {}
117 | for the_filter in self.stack[data_key][branch_pos]:
118 | key_stack[data_key][the_filter] = {}
119 | for x in self.stack[data_key][branch_pos][the_filter]:
120 | key_stack[data_key][the_filter][x] = []
121 | for y in self.stack[data_key][branch_pos][the_filter][x]:
122 | link = self.stack[data_key][branch_pos][the_filter][x][y]
123 | if not isinstance(link, Link):
124 | continue
125 | key_stack[data_key][the_filter][x].append(y)
126 | return key_stack
127 |
128 | def setup_stack_Example_Data_A(self, fk=None, xk=None, yk=None, views=None, weights=None):
129 | if fk is None:
130 | fk = [
131 | 'no_filter',
132 | 'Wave == 1'
133 | ]
134 | if xk is None:
135 | xk = self.minimum
136 | if yk is None:
137 | yk = ['@'] + self.minimum
138 | if views is None:
139 | views = ['default']
140 | if not isinstance(weights, list):
141 | weights = [weights]
142 |
143 | self.stack = Stack(name="Example Data (A)")
144 | self.stack.add_data(
145 | data_key=self.stack.name,
146 | meta=self.example_data_A_meta,
147 | data=self.example_data_A_data
148 | )
149 |
150 | for weight in weights:
151 | self.stack.add_link(
152 | data_keys=self.stack.name,
153 | filters=fk,
154 | x=xk,
155 | y=yk,
156 | views=QuantipyViews(views),
157 | weights=weight
158 | )
159 |
160 | if __name__ == '__main__':
161 | unittest.main()
--------------------------------------------------------------------------------
/tests/test_rim.py:
--------------------------------------------------------------------------------
1 | import pdb;
2 | import unittest
3 | import os.path
4 | import numpy
5 | import pandas as pd
6 | from quantipy.core.weights.rim import Rim
7 | from quantipy.core.weights.weight_engine import WeightEngine
8 |
9 |
10 | class TestScheme(unittest.TestCase):
11 |
12 | def setUp(self):
13 | self.analog_scheme = Rim('analog')
14 |
15 | def test_constructor(self):
16 | #Check to see if everything initialised correctly
17 | self.assertIsInstance(self.analog_scheme, Rim)
18 | self.assertEqual(self.analog_scheme.name, 'analog')
19 | self.assertEqual(self.analog_scheme.max_iterations, 1000)
20 | self.assertEqual(self.analog_scheme.convcrit, 0.01)
21 | self.assertEqual(self.analog_scheme.cap, 0)
22 | self.assertTrue(self.analog_scheme.dropna)
23 | self.assertIsInstance(self.analog_scheme._specific_impute, dict)
24 | self.assertIsNone(self.analog_scheme.weight_column_name)
25 | self.assertEqual(self.analog_scheme.total, 0)
26 |
27 | def test_cap(self):
28 | # Test the cap functionality
29 | self.assertEqual(0, self.analog_scheme.cap)
30 | self.assertFalse(self.analog_scheme._use_cap())
31 |
32 | self.analog_scheme.cap = 5
33 | self.assertEqual(5, self.analog_scheme.cap)
34 | self.assertTrue(self.analog_scheme._use_cap())
35 |
36 | #Check to see if it reverts properly to not using cap
37 | self.analog_scheme.cap = 0
38 | self.assertFalse(self.analog_scheme._use_cap())
39 |
40 | def test_groups(self):
41 | scheme = Rim('digital')
42 | self.assertIsInstance(scheme.groups, dict)
43 | self.assertIsNone(scheme.groups['_default_name_']['report'])
44 | self.assertIsNone(scheme.groups['_default_name_']['filters'])
45 |
46 | scheme.lists = ['gender', 'column1c', 'q06', 'sta_wo', 'abschluss', 'q04']
47 |
48 | scheme.add_group(name='Apple', filter_def='ownership==1')
49 | self.assertIn('Apple', scheme.groups)
50 | scheme.add_group(name='Samsung', filter_def='ownership==2')
51 | self.assertIn('Samsung', scheme.groups)
52 |
53 | # Check to see if the available methods to add filter are equal
54 | self.assertEqual(scheme.groups['Samsung']['filters'], 'ownership==2')
55 | self.assertEqual(scheme.groups['Apple']['filters'], 'ownership==1')
56 |
57 | #The targets should be empty lists
58 | for key in scheme.groups['Apple']['targets']:
59 | self.assertEqual(scheme.groups['Apple']['targets'][key], [])
60 |
61 | #Test for incorrect target change
62 | #with self.assertRaises(ValueError):
63 | scheme.set_targets(group_name='Apple', targets=[
64 | {'gender': {1: 1234, 2:200}}
65 | ])
66 |
67 | #Set valid targets
68 | valid_targets=[
69 | {'gender': {code: prop for code, prop
70 | in enumerate([50, 50], start=1)}},
71 | {'column1c': {code: prop for code, prop
72 | in enumerate([20, 18, 25, 21, 16], start=1)}},
73 | {'q04': {code: prop for code, prop
74 | in enumerate([20, 55, 12.5, 12.5], start=1)}},
75 | {'sta_wo': {code: prop for code, prop
76 | in enumerate([50, 50], start=1)}},
77 | {'abschluss': {code: prop for code, prop
78 | in enumerate([60, 40], start=1)}},
79 | {'q06': {code: prop for code, prop
80 | in enumerate([20, 20, 20, 20, 20], start=1)}}
81 | ]
82 |
83 | scheme.set_targets(group_name='Apple', targets=valid_targets)
84 |
85 | #add group_targets
86 | scheme.group_targets(
87 | {
88 | "Apple": 30,
89 | "Samsung": 40,
90 | "Motorola": 30
91 | }
92 | )
93 |
94 | self.assertItemsEqual(scheme._group_targets.keys(), ['Motorola', 'Apple', 'Samsung'])
95 | self.assertItemsEqual(scheme._group_targets.values(), [0.3, 0.3, 0.4])
--------------------------------------------------------------------------------
/tests/test_view.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import pandas as pd
3 | import json
4 | from copy import deepcopy
5 | from quantipy.core.stack import Stack
6 | from quantipy.core.view import View
7 | from quantipy.core.helpers.functions import load_json
8 |
9 | class TestLinkResult(unittest.TestCase):
10 | # The View object has undergone massive changes.
11 | # We will need to add tests for all new View attributes and methods
12 | # that are used make self-inspection possible.
13 | # Also: the constructor is changend completely.
14 | pass
15 |
16 |
17 |
--------------------------------------------------------------------------------