Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fomightez/21f5414174d36a56c7a96474aeda8253 to your computer and use it in GitHub Desktop.
Save fomightez/21f5414174d36a56c7a96474aeda8253 to your computer and use it in GitHub Desktop.
Step-by-step guide to using Atoti in sessions served via MyBInder.org
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"id": "f50af0d2-7393-4b15-85de-bc008e25b13b",
"metadata": {},
"source": [
"## Atoti Tutorial Working via sessions on MyBinder\n",
"\n",
"Go [here](https://github.com/binder-examples/requirements) and press 'launch binder'.\n",
"\n",
"When the session opens. Start a new notebook in JupyterLab and run the next line as a cell to install atoti and it's extension similar to what is spelled out [here](https://docs.atoti.io/latest/getting_started/installation.html), but using the magic install command of Jupyter that let you run the commands inside Jupyter and insure they are installing to correct environment, see [here](https://stackoverflow.com/questions/28828917/error-importing-seaborn-module-in-python-importerror-cannot-import-name-utils/76347896#comment134631387_41925357)."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "d078b9c7-9b63-41f6-84ed-4a5564b7dc2c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting package metadata (current_repodata.json): done\n",
"Solving environment: done\n",
"\n",
"\n",
"==> WARNING: A newer version of conda exists. <==\n",
" current version: 4.13.0\n",
" latest version: 23.5.2\n",
"\n",
"Please update conda by running\n",
"\n",
" $ conda update -n base conda\n",
"\n",
"\n",
"\n",
"## Package Plan ##\n",
"\n",
" environment location: /srv/conda/envs/notebook\n",
"\n",
" added / updated specs:\n",
" - atoti\n",
" - atoti-jupyterlab3\n",
"\n",
"\n",
"The following packages will be downloaded:\n",
"\n",
" package | build\n",
" ---------------------------|-----------------\n",
" abseil-cpp-20211102.0 | h27087fc_1 1.1 MB conda-forge\n",
" arrow-cpp-11.0.0 | py310h7516544_0 10.2 MB defaults\n",
" atoti-0.8.2 | 80138c9 140.0 MB https://conda.atoti.io\n",
" atoti-core-0.8.2 | 80138c9 45 KB https://conda.atoti.io\n",
" atoti-jupyterlab3-0.8.2 | 80138c9 2.7 MB https://conda.atoti.io\n",
" atoti-query-0.8.2 | 80138c9 38 KB https://conda.atoti.io\n",
" aws-c-common-0.4.57 | he6710b0_1 156 KB defaults\n",
" aws-c-event-stream-0.1.6 | h2531618_5 25 KB defaults\n",
" aws-checksums-0.1.9 | he6710b0_0 49 KB defaults\n",
" aws-sdk-cpp-1.8.185 | hce553d0_0 1.9 MB defaults\n",
" boost-cpp-1.78.0 | h5adbc97_2 15.2 MB conda-forge\n",
" ca-certificates-2023.5.7 | hbcca054_0 145 KB conda-forge\n",
" certifi-2023.5.7 | pyhd8ed1ab_0 149 KB conda-forge\n",
" gflags-2.2.2 | he1b5a44_1004 114 KB conda-forge\n",
" glog-0.5.0 | h48cff8f_0 104 KB conda-forge\n",
" grpc-cpp-1.46.1 | h33aed49_1 4.2 MB defaults\n",
" importlib-metadata-6.8.0 | pyha770c72_0 25 KB conda-forge\n",
" jdk4py-17.0.7.0 | py310_0 34.6 MB https://conda.atoti.io\n",
" jupyterlab-3.5.3 | pyhd8ed1ab_0 5.6 MB conda-forge\n",
" libblas-3.9.0 |17_linux64_openblas 14 KB conda-forge\n",
" libbrotlicommon-1.0.9 | h166bdaf_9 69 KB conda-forge\n",
" libbrotlidec-1.0.9 | h166bdaf_9 32 KB conda-forge\n",
" libbrotlienc-1.0.9 | h166bdaf_9 259 KB conda-forge\n",
" libcblas-3.9.0 |17_linux64_openblas 14 KB conda-forge\n",
" libevent-2.1.10 | h9b69904_4 1.1 MB conda-forge\n",
" libgfortran-ng-13.1.0 | h69a702a_0 23 KB conda-forge\n",
" libgfortran5-13.1.0 | h15d22d2_0 1.4 MB conda-forge\n",
" liblapack-3.9.0 |17_linux64_openblas 14 KB conda-forge\n",
" libopenblas-0.3.23 |pthreads_h80387f5_0 5.2 MB conda-forge\n",
" libprotobuf-3.20.3 | h3eb15da_0 2.2 MB conda-forge\n",
" libthrift-0.15.0 | he6d91bd_1 4.6 MB conda-forge\n",
" libzlib-1.2.13 | hd590300_5 60 KB conda-forge\n",
" lz4-c-1.9.4 | hcb278e6_0 140 KB conda-forge\n",
" numpy-1.25.1 | py310ha4c1d20_0 6.5 MB conda-forge\n",
" openssl-1.1.1u | hd590300_0 1.9 MB conda-forge\n",
" orc-1.7.4 | hb3bc3d3_1 972 KB defaults\n",
" pandas-2.0.3 | py310h7cbd5c2_1 11.7 MB conda-forge\n",
" py4j-0.10.9.7 | pyhd8ed1ab_0 182 KB conda-forge\n",
" pyarrow-11.0.0 | py310h468efa6_0 4.2 MB defaults\n",
" python-tzdata-2023.3 | pyhd8ed1ab_0 140 KB conda-forge\n",
" re2-2022.04.01 | h27087fc_0 212 KB conda-forge\n",
" snappy-1.1.10 | h9fff704_0 38 KB conda-forge\n",
" typeguard-2.13.3 | pyhd8ed1ab_0 19 KB conda-forge\n",
" typing-extensions-4.7.1 | hd8ed1ab_0 10 KB conda-forge\n",
" typing_extensions-4.7.1 | pyha770c72_0 35 KB conda-forge\n",
" utf8proc-2.6.1 | h27cfd23_0 308 KB defaults\n",
" zlib-1.2.13 | hd590300_5 91 KB conda-forge\n",
" zstd-1.5.2 | hfc55251_7 421 KB conda-forge\n",
" ------------------------------------------------------------\n",
" Total: 257.9 MB\n",
"\n",
"The following NEW packages will be INSTALLED:\n",
"\n",
" abseil-cpp conda-forge/linux-64::abseil-cpp-20211102.0-h27087fc_1\n",
" arrow-cpp pkgs/main/linux-64::arrow-cpp-11.0.0-py310h7516544_0\n",
" atoti /noarch::atoti-0.8.2-80138c9\n",
" atoti-core /noarch::atoti-core-0.8.2-80138c9\n",
" atoti-jupyterlab3 /noarch::atoti-jupyterlab3-0.8.2-80138c9\n",
" atoti-query /noarch::atoti-query-0.8.2-80138c9\n",
" aws-c-common pkgs/main/linux-64::aws-c-common-0.4.57-he6710b0_1\n",
" aws-c-event-stream pkgs/main/linux-64::aws-c-event-stream-0.1.6-h2531618_5\n",
" aws-checksums pkgs/main/linux-64::aws-checksums-0.1.9-he6710b0_0\n",
" aws-sdk-cpp pkgs/main/linux-64::aws-sdk-cpp-1.8.185-hce553d0_0\n",
" boost-cpp conda-forge/linux-64::boost-cpp-1.78.0-h5adbc97_2\n",
" gflags conda-forge/linux-64::gflags-2.2.2-he1b5a44_1004\n",
" glog conda-forge/linux-64::glog-0.5.0-h48cff8f_0\n",
" grpc-cpp pkgs/main/linux-64::grpc-cpp-1.46.1-h33aed49_1\n",
" jdk4py /linux-64::jdk4py-17.0.7.0-py310_0\n",
" libblas conda-forge/linux-64::libblas-3.9.0-17_linux64_openblas\n",
" libbrotlicommon conda-forge/linux-64::libbrotlicommon-1.0.9-h166bdaf_9\n",
" libbrotlidec conda-forge/linux-64::libbrotlidec-1.0.9-h166bdaf_9\n",
" libbrotlienc conda-forge/linux-64::libbrotlienc-1.0.9-h166bdaf_9\n",
" libcblas conda-forge/linux-64::libcblas-3.9.0-17_linux64_openblas\n",
" libevent conda-forge/linux-64::libevent-2.1.10-h9b69904_4\n",
" libgfortran-ng conda-forge/linux-64::libgfortran-ng-13.1.0-h69a702a_0\n",
" libgfortran5 conda-forge/linux-64::libgfortran5-13.1.0-h15d22d2_0\n",
" liblapack conda-forge/linux-64::liblapack-3.9.0-17_linux64_openblas\n",
" libopenblas conda-forge/linux-64::libopenblas-0.3.23-pthreads_h80387f5_0\n",
" libprotobuf conda-forge/linux-64::libprotobuf-3.20.3-h3eb15da_0\n",
" libthrift conda-forge/linux-64::libthrift-0.15.0-he6d91bd_1\n",
" lz4-c conda-forge/linux-64::lz4-c-1.9.4-hcb278e6_0\n",
" numpy conda-forge/linux-64::numpy-1.25.1-py310ha4c1d20_0\n",
" orc pkgs/main/linux-64::orc-1.7.4-hb3bc3d3_1\n",
" pandas conda-forge/linux-64::pandas-2.0.3-py310h7cbd5c2_1\n",
" py4j conda-forge/noarch::py4j-0.10.9.7-pyhd8ed1ab_0\n",
" pyarrow pkgs/main/linux-64::pyarrow-11.0.0-py310h468efa6_0\n",
" python-tzdata conda-forge/noarch::python-tzdata-2023.3-pyhd8ed1ab_0\n",
" re2 conda-forge/linux-64::re2-2022.04.01-h27087fc_0\n",
" snappy conda-forge/linux-64::snappy-1.1.10-h9fff704_0\n",
" typeguard conda-forge/noarch::typeguard-2.13.3-pyhd8ed1ab_0\n",
" typing-extensions conda-forge/noarch::typing-extensions-4.7.1-hd8ed1ab_0\n",
" utf8proc pkgs/main/linux-64::utf8proc-2.6.1-h27cfd23_0\n",
" zstd conda-forge/linux-64::zstd-1.5.2-hfc55251_7\n",
"\n",
"The following packages will be UPDATED:\n",
"\n",
" ca-certificates 2022.9.24-ha878542_0 --> 2023.5.7-hbcca054_0\n",
" certifi 2022.9.24-pyhd8ed1ab_0 --> 2023.5.7-pyhd8ed1ab_0\n",
" importlib-metadata conda-forge/linux-64::importlib-metad~ --> conda-forge/noarch::importlib-metadata-6.8.0-pyha770c72_0\n",
" jupyterlab 3.4.8-pyhd8ed1ab_0 --> 3.5.3-pyhd8ed1ab_0\n",
" libzlib 1.2.12-h166bdaf_4 --> 1.2.13-hd590300_5\n",
" openssl 1.1.1q-h166bdaf_0 --> 1.1.1u-hd590300_0\n",
" typing_extensions 4.4.0-pyha770c72_0 --> 4.7.1-pyha770c72_0\n",
" zlib 1.2.12-h166bdaf_4 --> 1.2.13-hd590300_5\n",
"\n",
"\n",
"\n",
"Downloading and Extracting Packages\n",
"abseil-cpp-20211102. | 1.1 MB | ##################################### | 100% \n",
"libopenblas-0.3.23 | 5.2 MB | ##################################### | 100% \n",
"aws-sdk-cpp-1.8.185 | 1.9 MB | ##################################### | 100% \n",
"pyarrow-11.0.0 | 4.2 MB | ##################################### | 100% \n",
"aws-c-event-stream-0 | 25 KB | ##################################### | 100% \n",
"libzlib-1.2.13 | 60 KB | ##################################### | 100% \n",
"libbrotlicommon-1.0. | 69 KB | ##################################### | 100% \n",
"aws-c-common-0.4.57 | 156 KB | ##################################### | 100% \n",
"pandas-2.0.3 | 11.7 MB | ##################################### | 100% \n",
"openssl-1.1.1u | 1.9 MB | ##################################### | 100% \n",
"re2-2022.04.01 | 212 KB | ##################################### | 100% \n",
"lz4-c-1.9.4 | 140 KB | ##################################### | 100% \n",
"jupyterlab-3.5.3 | 5.6 MB | ##################################### | 100% \n",
"libgfortran5-13.1.0 | 1.4 MB | ##################################### | 100% \n",
"libthrift-0.15.0 | 4.6 MB | ##################################### | 100% \n",
"orc-1.7.4 | 972 KB | ##################################### | 100% \n",
"grpc-cpp-1.46.1 | 4.2 MB | ##################################### | 100% \n",
"typeguard-2.13.3 | 19 KB | ##################################### | 100% \n",
"importlib-metadata-6 | 25 KB | ##################################### | 100% \n",
"libprotobuf-3.20.3 | 2.2 MB | ##################################### | 100% \n",
"ca-certificates-2023 | 145 KB | ##################################### | 100% \n",
"numpy-1.25.1 | 6.5 MB | ##################################### | 100% \n",
"arrow-cpp-11.0.0 | 10.2 MB | ##################################### | 100% \n",
"gflags-2.2.2 | 114 KB | ##################################### | 100% \n",
"zstd-1.5.2 | 421 KB | ##################################### | 100% \n",
"zlib-1.2.13 | 91 KB | ##################################### | 100% \n",
"libbrotlienc-1.0.9 | 259 KB | ##################################### | 100% \n",
"glog-0.5.0 | 104 KB | ##################################### | 100% \n",
"libgfortran-ng-13.1. | 23 KB | ##################################### | 100% \n",
"snappy-1.1.10 | 38 KB | ##################################### | 100% \n",
"boost-cpp-1.78.0 | 15.2 MB | ##################################### | 100% \n",
"utf8proc-2.6.1 | 308 KB | ##################################### | 100% \n",
"liblapack-3.9.0 | 14 KB | ##################################### | 100% \n",
"atoti-query-0.8.2 | 38 KB | ##################################### | 100% \n",
"typing_extensions-4. | 35 KB | ##################################### | 100% \n",
"python-tzdata-2023.3 | 140 KB | ##################################### | 100% \n",
"atoti-0.8.2 | 140.0 MB | ##################################### | 100% \n",
"atoti-core-0.8.2 | 45 KB | ##################################### | 100% \n",
"py4j-0.10.9.7 | 182 KB | ##################################### | 100% \n",
"aws-checksums-0.1.9 | 49 KB | ##################################### | 100% \n",
"jdk4py-17.0.7.0 | 34.6 MB | ##################################### | 100% \n",
"libcblas-3.9.0 | 14 KB | ##################################### | 100% \n",
"atoti-jupyterlab3-0. | 2.7 MB | ##################################### | 100% \n",
"libbrotlidec-1.0.9 | 32 KB | ##################################### | 100% \n",
"typing-extensions-4. | 10 KB | ##################################### | 100% \n",
"certifi-2023.5.7 | 149 KB | ##################################### | 100% \n",
"libblas-3.9.0 | 14 KB | ##################################### | 100% \n",
"libevent-2.1.10 | 1.1 MB | ##################################### | 100% \n",
"Preparing transaction: done\n",
"Verifying transaction: done\n",
"Executing transaction: done\n",
"\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"%conda install -c https://conda.atoti.io atoti atoti-jupyterlab3"
]
},
{
"cell_type": "markdown",
"id": "25231e8c-8855-4fdf-affd-2091f39b8fe6",
"metadata": {},
"source": [
"------ \n",
"\n",
"#### Install the tutorial like it says [in the tutoral documentation](https://docs.atoti.io/latest/getting_started/tutorial/tutorial.html#Tutorial)."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "10842ea3-b849-4313-bad8-5f5c92b973b7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Welcome to Atoti 0.8.2!\n",
"\n",
"By using this community edition, you agree with the license available at https://docs.atoti.io/latest/eula.html.\n",
"Browse the official documentation at https://docs.atoti.io.\n",
"Join the community at https://www.atoti.io/register.\n",
"\n",
"Atoti collects telemetry data, which is used to help understand how to improve the product.\n",
"If you don't wish to send usage data, you can request a trial license at https://www.atoti.io/evaluation-license-request.\n",
"\n",
"You can hide this message by setting the `ATOTI_HIDE_EULA_MESSAGE` environment variable to True.\n",
"The tutorial files have been copied to /home/jovyan/tutorial\n"
]
}
],
"source": [
"!python -m atoti.copy_tutorial tutorial"
]
},
{
"cell_type": "markdown",
"id": "ecf72ac0-7ffd-4c3b-8378-c5ea6dbc5a85",
"metadata": {},
"source": [
"--------\n",
"\n",
"#### Step through the 'Getting Started' [here](https://docs.atoti.io/latest/getting_started/tutorial/tutorial.html#Getting-started)."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "8c109032-664e-42b1-aebe-14a12fe24899",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Welcome to Atoti 0.8.2!\n",
"\n",
"By using this community edition, you agree with the license available at https://docs.atoti.io/latest/eula.html.\n",
"Browse the official documentation at https://docs.atoti.io.\n",
"Join the community at https://www.atoti.io/register.\n",
"\n",
"Atoti collects telemetry data, which is used to help understand how to improve the product.\n",
"If you don't wish to send usage data, you can request a trial license at https://www.atoti.io/evaluation-license-request.\n",
"\n",
"You can hide this message by setting the `ATOTI_HIDE_EULA_MESSAGE` environment variable to True.\n"
]
}
],
"source": [
"import atoti as tt"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "b4761fec-5e9b-4317-8451-36f146df74e0",
"metadata": {},
"outputs": [],
"source": [
"session = tt.Session()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "39ee7c69-9a4e-46bc-a1a4-98381d88ba02",
"metadata": {},
"outputs": [],
"source": [
"sales_table = session.read_csv(\"tutorial/data/sales.csv\", keys=[\"Sale ID\"]) # note I changed this path because I am running in root for now."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "f2193a16-5763-47d9-9c2a-d114265aa085",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Date</th>\n",
" <th>Shop</th>\n",
" <th>Product</th>\n",
" <th>Quantity</th>\n",
" <th>Unit price</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Sale ID</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>S000001427</th>\n",
" <td>2021-01-18</td>\n",
" <td>shop_27</td>\n",
" <td>BED_24</td>\n",
" <td>1.0</td>\n",
" <td>150.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>S000000000</th>\n",
" <td>2021-02-04</td>\n",
" <td>shop_0</td>\n",
" <td>TAB_0</td>\n",
" <td>1.0</td>\n",
" <td>210.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>S000001428</th>\n",
" <td>2021-01-17</td>\n",
" <td>shop_28</td>\n",
" <td>BED_25</td>\n",
" <td>4.0</td>\n",
" <td>300.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>S000000001</th>\n",
" <td>2021-02-03</td>\n",
" <td>shop_1</td>\n",
" <td>TAB_1</td>\n",
" <td>1.0</td>\n",
" <td>300.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>S000001429</th>\n",
" <td>2021-01-16</td>\n",
" <td>shop_29</td>\n",
" <td>BED_26</td>\n",
" <td>1.0</td>\n",
" <td>395.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Date Shop Product Quantity Unit price\n",
"Sale ID \n",
"S000001427 2021-01-18 shop_27 BED_24 1.0 150.0\n",
"S000000000 2021-02-04 shop_0 TAB_0 1.0 210.0\n",
"S000001428 2021-01-17 shop_28 BED_25 4.0 300.0\n",
"S000000001 2021-02-03 shop_1 TAB_1 1.0 300.0\n",
"S000001429 2021-01-16 shop_29 BED_26 1.0 395.0"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sales_table.head()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "9270da7a-8d98-40b6-b885-29d3b154762c",
"metadata": {},
"outputs": [],
"source": [
"cube = session.create_cube(sales_table)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "0802427d-ea72-4c05-9816-633a4d69fddf",
"metadata": {},
"outputs": [
{
"data": {
"application/json": {
"Sales": {
"Date": [
"Date"
],
"Product": [
"Product"
],
"Sale ID": [
"Sale ID"
],
"Shop": [
"Shop"
]
}
},
"text/html": [
"<ul>\n",
"<li>Dimensions\n",
" <ul>\n",
" <li>Sales\n",
" <ul>\n",
" <li>Date\n",
" <ol>\n",
" <li>Date</li>\n",
" </ol> </li>\n",
" <li>Product\n",
" <ol>\n",
" <li>Product</li>\n",
" </ol> </li>\n",
" <li>Sale ID\n",
" <ol>\n",
" <li>Sale ID</li>\n",
" </ol> </li>\n",
" <li>Shop\n",
" <ol>\n",
" <li>Shop</li>\n",
" </ol> </li>\n",
" </ul>\n",
" </li>\n",
" </ul>\n",
"</li>\n",
"</ul>\n"
],
"text/plain": [
"{('Sales', 'Sale ID'): <atoti.hierarchy.Hierarchy object at 0x7fd2d0174250>, ('Sales', 'Product'): <atoti.hierarchy.Hierarchy object at 0x7fd2d01742e0>, ('Sales', 'Date'): <atoti.hierarchy.Hierarchy object at 0x7fd2d146f820>, ('Sales', 'Shop'): <atoti.hierarchy.Hierarchy object at 0x7fd2d14572e0>}"
]
},
"execution_count": 7,
"metadata": {
"application/json": {
"expanded": true,
"root": "Dimensions"
}
},
"output_type": "execute_result"
}
],
"source": [
"# Aliasing the hierarchies property to a shorter variable name because we will use it a lot.\n",
"h = cube.hierarchies\n",
"h"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "dfa94411-ada1-48ed-9bfa-70c6ff902d2c",
"metadata": {},
"outputs": [],
"source": [
"l = cube.levels"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "e5ac887e-c3b1-4706-aa47-cfabb0706d8e",
"metadata": {},
"outputs": [
{
"data": {
"application/json": {
"Quantity.MEAN": {
"formatter": "DOUBLE[#,###.00]"
},
"Quantity.SUM": {
"formatter": "DOUBLE[#,###.00]"
},
"Unit price.MEAN": {
"formatter": "DOUBLE[#,###.00]"
},
"Unit price.SUM": {
"formatter": "DOUBLE[#,###.00]"
},
"contributors.COUNT": {
"formatter": "INT[#,###]"
}
},
"text/html": [
"<ul>\n",
"<li>Measures\n",
" <ul>\n",
" <li>Quantity.MEAN\n",
" <ul>\n",
" <li>formatter: DOUBLE[#,###.00]</li>\n",
" </ul>\n",
" </li>\n",
" <li>Quantity.SUM\n",
" <ul>\n",
" <li>formatter: DOUBLE[#,###.00]</li>\n",
" </ul>\n",
" </li>\n",
" <li>Unit price.MEAN\n",
" <ul>\n",
" <li>formatter: DOUBLE[#,###.00]</li>\n",
" </ul>\n",
" </li>\n",
" <li>Unit price.SUM\n",
" <ul>\n",
" <li>formatter: DOUBLE[#,###.00]</li>\n",
" </ul>\n",
" </li>\n",
" <li>contributors.COUNT\n",
" <ul>\n",
" <li>formatter: INT[#,###]</li>\n",
" </ul>\n",
" </li>\n",
" </ul>\n",
"</li>\n",
"</ul>\n"
],
"text/plain": [
"{'contributors.COUNT': <atoti.measure.Measure object at 0x7fd2d1503be0>, 'update.TIMESTAMP': <atoti.measure.Measure object at 0x7fd2d1502da0>, 'Unit price.SUM': <atoti.measure.Measure object at 0x7fd2d1503a00>, 'Unit price.MEAN': <atoti.measure.Measure object at 0x7fd2d1503850>, 'Quantity.SUM': <atoti.measure.Measure object at 0x7fd2d1503d30>, 'Quantity.MEAN': <atoti.measure.Measure object at 0x7fd2d1503ac0>}"
]
},
"execution_count": 9,
"metadata": {
"application/json": {
"expanded": false,
"root": "Measures"
}
},
"output_type": "execute_result"
}
],
"source": [
"m = cube.measures\n",
"m"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "ab7ef004-40ba-410e-957b-fb7f35ff0d8b",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Quantity.SUM</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>8,077.00</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Quantity.SUM\n",
"0 8,077.00"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cube.query(m[\"Quantity.SUM\"])"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "510187bf-eec8-43de-aecc-700e338fcfe1",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Quantity.SUM</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Shop</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>shop_0</th>\n",
" <td>202.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_1</th>\n",
" <td>202.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_10</th>\n",
" <td>203.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_11</th>\n",
" <td>203.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_12</th>\n",
" <td>201.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_13</th>\n",
" <td>202.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_14</th>\n",
" <td>202.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_15</th>\n",
" <td>202.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_16</th>\n",
" <td>201.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_17</th>\n",
" <td>204.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_18</th>\n",
" <td>202.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_19</th>\n",
" <td>202.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_2</th>\n",
" <td>202.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_20</th>\n",
" <td>201.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_21</th>\n",
" <td>201.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_22</th>\n",
" <td>201.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_23</th>\n",
" <td>203.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_24</th>\n",
" <td>203.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_25</th>\n",
" <td>201.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_26</th>\n",
" <td>202.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_27</th>\n",
" <td>202.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_28</th>\n",
" <td>202.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_29</th>\n",
" <td>201.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_3</th>\n",
" <td>201.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_30</th>\n",
" <td>204.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_31</th>\n",
" <td>202.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_32</th>\n",
" <td>202.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_33</th>\n",
" <td>201.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_34</th>\n",
" <td>201.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_35</th>\n",
" <td>201.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_36</th>\n",
" <td>203.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_37</th>\n",
" <td>203.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_38</th>\n",
" <td>201.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_39</th>\n",
" <td>202.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_4</th>\n",
" <td>204.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_5</th>\n",
" <td>202.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_6</th>\n",
" <td>202.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_7</th>\n",
" <td>201.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_8</th>\n",
" <td>201.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>shop_9</th>\n",
" <td>201.00</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Quantity.SUM\n",
"Shop \n",
"shop_0 202.00\n",
"shop_1 202.00\n",
"shop_10 203.00\n",
"shop_11 203.00\n",
"shop_12 201.00\n",
"shop_13 202.00\n",
"shop_14 202.00\n",
"shop_15 202.00\n",
"shop_16 201.00\n",
"shop_17 204.00\n",
"shop_18 202.00\n",
"shop_19 202.00\n",
"shop_2 202.00\n",
"shop_20 201.00\n",
"shop_21 201.00\n",
"shop_22 201.00\n",
"shop_23 203.00\n",
"shop_24 203.00\n",
"shop_25 201.00\n",
"shop_26 202.00\n",
"shop_27 202.00\n",
"shop_28 202.00\n",
"shop_29 201.00\n",
"shop_3 201.00\n",
"shop_30 204.00\n",
"shop_31 202.00\n",
"shop_32 202.00\n",
"shop_33 201.00\n",
"shop_34 201.00\n",
"shop_35 201.00\n",
"shop_36 203.00\n",
"shop_37 203.00\n",
"shop_38 201.00\n",
"shop_39 202.00\n",
"shop_4 204.00\n",
"shop_5 202.00\n",
"shop_6 202.00\n",
"shop_7 201.00\n",
"shop_8 201.00\n",
"shop_9 201.00"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cube.query(m[\"Quantity.SUM\"], levels=[l[\"Shop\"]])"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "06eedddd-f82e-4933-934d-be4554509bab",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Quantity.SUM</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>202.00</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Quantity.SUM\n",
"0 202.00"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cube.query(\n",
" m[\"Quantity.SUM\"],\n",
" filter=l[\"Shop\"] == \"shop_0\",\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "41779360-8876-4b5c-89c1-4c0a698df4b2",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>Quantity.SUM</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Date</th>\n",
" <th>Product</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th rowspan=\"5\" valign=\"top\">2021-01-06</th>\n",
" <th>BED_24</th>\n",
" <td>8.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BED_25</th>\n",
" <td>4.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BED_26</th>\n",
" <td>6.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BED_27</th>\n",
" <td>4.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BED_3</th>\n",
" <td>2.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"5\" valign=\"top\">2021-02-04</th>\n",
" <th>TSH_52</th>\n",
" <td>6.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>TSH_53</th>\n",
" <td>4.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>TSH_7</th>\n",
" <td>3.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>TSH_8</th>\n",
" <td>5.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>TSH_9</th>\n",
" <td>3.00</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>1830 rows × 1 columns</p>\n",
"</div>"
],
"text/plain": [
" Quantity.SUM\n",
"Date Product \n",
"2021-01-06 BED_24 8.00\n",
" BED_25 4.00\n",
" BED_26 6.00\n",
" BED_27 4.00\n",
" BED_3 2.00\n",
"... ...\n",
"2021-02-04 TSH_52 6.00\n",
" TSH_53 4.00\n",
" TSH_7 3.00\n",
" TSH_8 5.00\n",
" TSH_9 3.00\n",
"\n",
"[1830 rows x 1 columns]"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cube.query(m[\"Quantity.SUM\"], levels=[l[\"Date\"], l[\"Product\"]])"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "290b3c71-9162-48de-9dac-839edabbffa3",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>Quantity.SUM</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Date</th>\n",
" <th>Product</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th rowspan=\"5\" valign=\"top\">2021-01-15</th>\n",
" <th>BED_24</th>\n",
" <td>1.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BED_26</th>\n",
" <td>1.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BED_3</th>\n",
" <td>1.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BED_4</th>\n",
" <td>1.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>BED_46</th>\n",
" <td>1.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"5\" valign=\"top\">2021-02-04</th>\n",
" <th>TSH_51</th>\n",
" <td>2.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>TSH_52</th>\n",
" <td>1.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>TSH_53</th>\n",
" <td>1.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>TSH_7</th>\n",
" <td>1.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>TSH_9</th>\n",
" <td>1.00</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>125 rows × 1 columns</p>\n",
"</div>"
],
"text/plain": [
" Quantity.SUM\n",
"Date Product \n",
"2021-01-15 BED_24 1.00\n",
" BED_26 1.00\n",
" BED_3 1.00\n",
" BED_4 1.00\n",
" BED_46 1.00\n",
"... ...\n",
"2021-02-04 TSH_51 2.00\n",
" TSH_52 1.00\n",
" TSH_53 1.00\n",
" TSH_7 1.00\n",
" TSH_9 1.00\n",
"\n",
"[125 rows x 1 columns]"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cube.query(\n",
" m[\"Quantity.SUM\"],\n",
" levels=[l[\"Date\"], l[\"Product\"]],\n",
" filter=l[\"Shop\"] == \"shop_0\",\n",
")"
]
},
{
"cell_type": "markdown",
"id": "b41bd1b7-a537-46dc-ba07-fa346d043d6a",
"metadata": {},
"source": [
"That should illustrate enough. Continue working through tutorial."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment