Operators allow us to make more complex queries by adding, subtracting, or filtering data.
Q uses the following operators:
!=: Not Equal
%: pattern matching a wildcard
<=: Greater and Less than
We use these operators to build more and more complex Q statements before sending our query to
The CDA provides a custom python tool for searching CDA data.
Q (short for Query) offers several ways to search and filter data, and several input modes:
- Q.() builds a query that can be used by
- Q.run() returns data for the specified search
- Q.count() returns summary information (counts) data that fit the specified search
- columns() returns entity field names
- unique_terms() returns entity field contents
Before we do any work, we need to import several functions from cdapython:
querywhich power the search
columnswhich lets us view entity field names
unique_termswhich lets view entity field contents
We're also importing functions from several other packages to make viewing and manipulating tables easier. The
opt. settings are pre-configuring how itables should display our tables, with scrolling and paging enabled.
Finally, we're telling cdapython to report it's version so we can be sure we're using the one we mean to:
from cdapython import Q, columns, unique_terms, query import numpy as np import pandas as pd from itables import init_notebook_mode, show init_notebook_mode(all_interactive=True) import itables.options as opt opt.maxBytes=0 opt.scrollX="200px" opt.scrollCollapse=True opt.paging=True opt.maxColumns=0 print(Q.get_version())