top of page

How To Connect A Jupyter Notebook To Tableau Using Jupytab

Updated: Mar 15

Author: Mayank Tiwari


Introduction

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.


Prerequisites

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.


Implementation:

Step 1:


You need to have the Jupyter Notebook on your machine installed first.


Install Jupyter Notebook


Step 2:


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

path= \jupyter-server-env\Scripts\activate




For conda env - Conda activate jupyter-notebook-env


Once your Virtual environment is activated


then run


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.


Step 3:


Do Write the Notebook step by referring to the documentation


Jupytab Documentation


Here is a demo:



Note:


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:


Step 4:


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


paste this


[main]

listen_port = 8123

notebooks = JupytabSimulator

[JupytabSimulator]

path =/Programs/Python/Python310/Scripts/<jupytab-simulation-notebook>.ipynb


the path to your ipynb file in step 3


Step 5:


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


http://DESKTOP-RVE247D:8123


Note this


Step 6:


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.


Conclusion

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.


References

1)Jupytab Documentation

2) Simulation with Tableau and Jupytab




183 views0 comments

Recent Posts

See All
bottom of page