In this Internet era, the amount of data being generated from various sources with detailed granularity is humongous. Data being the new gold, it has become inevitable to use data for advanced analytics purposes to understand useful business insights for the betterment of one’s organization. Python and Tableau are among the best technologies addressing analytics challenges. This blog briefs about both the tools and walks us through the steps to connect to Python from Tableau. Before discussing Tableau and Python integration let us discuss Tableau and Python.
Python is an object-oriented, open-source, high-level programming language with dynamic semantics. Though Python has many high-level data structures it is very user-friendly and simple to learn. Python also supports packages, modules which are useful to increase program modularity and allows code to be integrated and reused with other technologies.
Tableau is a self-service data visualization tool that helps customers to view and present data in the form of interactive dashboards and charts to showcase insights and perform real-time data analytics. Tableau is very user-friendly as it provides a drag-drop user interface to visualize the available data with minimal scripting required only for calculated fields.
Connecting Python to Tableau requires us to install Python IDE(Anaconda Navigator) which is also an open-source tool.
How to integrate Python with Tableau?
TabPy is the API that enables the working of Python code from within a Tableau workbook.
Steps to integrate Python with Tableau:
1. After downloading Anaconda Navigator, the next step would be to download the Tabpy server. TabPy server can be downloaded by typing conda install -c anaconda TabPy-server in the anaconda prompt.
After all the packages are installed it will ask for yes or no to proceed, press y to install the server.
2. After the TabPy server is installed, the server should be started in order to connect with Tableau. To start the TabPy-server we should change the directory from the root directory to the folder where TabPy-server is installed. This can be done by typing cd C:\Users\*your username*\Anaconda3\pkgs\tabpy-server-0.2-py37_1\Lib\site-packages\tabpy_server command in anaconda prompt. This command changes directory to the folder where tabpy_server is installed.
3. The next command startup.bat can be typed to start the server.
4. After the command startup.bat, the prompt displays port number 9004 on which TabPy-server is initialized. After initializing the server, the next part is to connect the server with Tableau. Open Tableau desktop.
5. In Tableau go to:
- Open Help menu.
- In that choose settings and performance
- From settings and performance choose to manage the external connection.
- Select TabPy/External API
- Select localhost
- Make sure the port number is 9004
Click on test connection to cross-check the connectivity.
Once the connection is successful then click on the OK button to approve the external connection.
When Tabpy is used with Tableau, calculated fields can be defined in Python which enables us to use the power of many machine-learning libraries right from Tableau visualizations. It enables many new features like Machine learning predictions, sentimental analysis, and time series forecasting using various models by customizing calculated fields.
Limitations of integrating Python with Tableau
Though there are many advantages of enabling Tabpy there are also certain limitations.
- When a large dataset is used then waiting time will be more while the script runs each time you make a change to the view.
- The Python generated calculated fields will not be extracted if you create a Tableau extract.
- The Python script will run only when you put it into the view.
- You cannot use the Tabpy calculations to create values and base additional calculations on those values unless you can use both calculated fields in the view.
When deployed together, Python integrated with Tableau can help in delivering scalable, flexible and advanced analytics platform.
To learn more about Visual BI’s Tableau Consulting & End User Training Programs, contact us here.