1-Tableau With Python
1-Tableau With Python
With
Python
Integration
Akriti Lal
Tableau with Python
• Click on the Clone or download button in the upper right corner ( see
below ) of the TabPy repository page, downloading the zip file and
extracting it.
Extract TabPy-master.zip
• Within the TabPy-master directory, execute setup.bat (or setup. sh if you are on
Mac).
• This script downloads and installs Python, TabPy and all necessary
dependencies.
• After completion, TabPy starts up and listens on port 9004.
Key Points During Installation
TabPy installation takes a while and many time
you're not successful on your first try.
Key Points that needs to be taken care :
• You have Python 3.0 and not the required Python
2.7.
• You might have both versions, but your primary is
the 3.0 version.
Key Points During Installation Cont.…
• When you run the python tableau server set up file for the first time
, it go on installing Anaconda ( even if Anaconda is there ) ,my
experience says actually it is not installing but setting up something.
• It takes more than hour and multiple attempts sometime to get the
server running. You can close and run the set up file multiple times
Or Keep Patience till finally you get the final confirmation message
You may also get the below even if you have python
installed . Have patience , let it keep running. ( can take
hours. If it get closed run it again, till you get success
message) . You can get error , but run the setup file
again and again , till finally it gets installed .
Key Points During Installation Cont.…
• When you get the below message it means the python server is
successfully installed and running fine .
• Also Note the path ( highlighted in red below ) for starting
python server next time or else you will keep doing the same
process again and again
Key Points During Installation Cont.…
Specify a port. Port 9004 is the default port for TabPy servers.
Click OK.
Pass Expressions to Python
• In order to let tableau know that the calculations
need to go to Python, it must be passed through
one of the 4 functions.
• These 4 functions are : SCRIPT_BOOL , SCRIPT_INT ,
SCRIPT_REAL , SCRIPT_STR
• Python Functions are computed as Table
calculations in Tableau.
• Since these are table calculations, all the Fields
being passed to Python must be aggregated like
Sum(PROFIT), MIN(Profit), Max (Profit), ATTR(
Category) etc.
Python Functions in Tableau
Run an Python script on Tableau
SCRIPT_BOOL
Returns a Boolean result from the specified expression. The
expression is passed directly to a running external service
instance. In Python expressions, use _argn (with a leading
underscore ) to reference parameters ( _arg1, _arg2, etc.).