Author: Mayank Tiwari
This implementation of connecting Jupyter notebook to Tableau helps us in applications like when we want to display real-time data on our dashboards or if you want dynamic predictions based on your ML model; you will be able to do that without any hassle.
For this implementation, all you need is knowledge about the Virtual environment in python; even though I have listed all steps to activate new environments, a basic understanding of them will surely help you.
You need to have the Jupyter Notebook on your machine installed first.
Create a virtual environment jupyter-notebook-env
You can use Conda Virtual Environment or Venv, whatever suits your need.
1) Create Environment
For Venv – python -m venv jupyter-notebook-env
2) Activate Virtual environment
For venv -
by going into the folder Scripts of the virtual environment
For conda env - Conda activate jupyter-notebook-env
Once your Virtual environment is activated
pip install jupytab
pip install ipykernel
then create a kernel
python -m ipykernel install --user --name jupytab-simulation-demo
After installing the kernel select this kernel in the Jupyter notebook.
Do Write the Notebook step by referring to the documentation
Here is a demo:
When Tableau needs to retrieve the schema of all the available tables, Jupytab executes the (mandatory) cell that starts with # GET /schema:
When Tableau needs to retrieve the data from the tables, Jupytab executes the (mandatory) cell that starts with # GET /data:
Now you have to create another virtual environment named jupytab-server-env
1) Install jupytab-server
For Venv – pip install jupytab-server
For Conda – conda install jupytab-server=0.9.11
2) Create a config.ini file in the directory where this environment exists
listen_port = 8123
notebooks = JupytabSimulator
the path to your ipynb file in step 3
Run jupytab --config=<path of config file> or locate into that folder
If you face any error like
Locate to init.py file -> Edit with Notepad++ ->
Include this at the top of the file.
From collections.abc import Mapping, MutableMapping
Then again run error will be resolved, and you will get
Now go to Tableau and in the data source
1) Go to Data->New Data Source
2) And then the web data connector
3) And type the above location and your connection will establish, and you will see the Jupytab simulator as one of the data sources.
The URL you see above is all we need to type in web data connector URL.
Click on Explore in Tableau. You will see the dataset in Tableau, then.
Now you create a dashboard directly using this dataset.
This was all about how to connect these two, and there is no limit to what you can achieve using this. You can do all computations required on the data on the Jupyter Notebook side, and you can create dashboards from it.
2) Simulation with Tableau and Jupytab