With the release of TabPy (Tableau Python Server) , you can include python code within Tableau’s calculated fields. This code will get evaluated by python and the results will be sent back to Tableau.
Python is a widely used general-purpose programming language, and a large number of Python libraries are available to perform statistical analysis, predictive models or machine learning algorithms. Using TabPy, you can leverage these capabilities within Tableau as well.
Let’s get started !!!
Every day we come across numerous posts, blogs and even video tutorials on how to create brilliant but complex charts, that might not be quite useful at your own organization. Some require data densification while others don't end up well with huge data sets.
Design with Ease
We @thevizduo.com will be coming up with handy yet useful tips that can be used with ease on a daily basis to attain better productivity at your workplace
Step 1: Installing Anaconda Navigator
Anaconda is the leading open data science platform powered by Python, whose open source version is a high performance distribution of Python and R, and includes over 100 of the most popular Python, R and Scala packages for data science.
Install Anaconda Navigator with the default options in the installation set-up.
We need to install few libraries before we move ahead. If you are using command line for the same for the same below are the commands
pip install tabpy-client
pip install tabpy-server
The below one will be required for sentiment analysis
pip install twython
pip install vaderSentiment
Otherwise you can install the same from the interactive console as well, once you launch Anaconda Navigator:
1) Goto Environments
2) Select All using the dropdown, before you start searching for the libraries you want to install
3) Select the library that you want to install (for example – alembic over here)
4) Hit Apply
5)Anaconda will download and install the libraries
6) install the below mentioned libraries before proceeding further
tabpy-client
tabpy-server
The below one will be required for sentiment analysis
twython
vaderSentiment
Step 2: Start TabPy as a background process
Start Tabpy "Startup" - Batch File, in order to run the same as a background process.
This will be available at the location where you have installed Anaconda Navigator
C:\ProgramData\Anaconda3\Lib\site-packages\tabpy_server
This path may be different in your case.
Once you hit the "Startup" - Batch File, The below window will popup.
You are good to move ahead.
Step 3: Connecting Tableau with TabPy
In Tableau, Goto:
Help > Settings and Performance > Manage External Service Connection
Test the connection and you should get a “successfully connected” prompt.
Now you can create calculated fields with embedded python code like the below one for tweet- Sentiment Analysis
Step 4: Unleashing Python's capabilities in Calculated fields
Now we’re going to embed python code to the new calculated fields. The code embedded to the calculated field “Sentiment Score” will return the Sentiment Scores generated by SentimentIntensityAnalyzer Object, from Python's vaderSentiment Library.
You can copy this code down below:
The result will look something like this, once you include this calculation as a part of your workbook.
Avdhesh Gaur has 5+ years of work experience with Tableau desktop, taking down various business requirements by building Data-driven Business Intelligence models using SQL, Hive, Tableau, and other Statistical data analysis Techniques.
In a nutshell, He transforms data into visualizations to help organizations understand their business operations more visually.
Avdhesh got one of his submissions to Tableau accepted & placed in their permanent public knowledge database known as "Tableau Gallery" on 7th January 2019, which in a more cooler way we call Viz of the day
He is a featured author at O'Reilly's - Safari Books Online. "Data Visualization with Tableau in Practice" is the recent video course that he had worked on in collaboration with Packt Publishing. The same was released by the End of April 2019.
What you will find in this course ?
Comments