Tableau Prep Python integration was added in 2019.3 and this post shows how to install and setup TabPy for Tableau Prep. Tableau recommends to run TabPy in a virtual environment and we will use Anaconda to manage our virtual environment.1. Downloading and Installing AnacondaYou can download Anaconda for free from this link. Please remember to choose the correct distribution and architecture. Below image shows Windows 64 bit Python 3.7 download link and minimum version required by Tabpy is Python 3.6. Downloading Anaconda For WindowsOnce the installer is downloaded, double click on it to start the installation. Default options are fine and the installation process will take about 10 minutes. Installing Anaconda2. Creating Virtual EnvironmentFrom start menu, Search for Anaconda Prompt and open it. Execute following commands in order to create a virtual environment called ‘tpy’ and then to activate it.conda create -n tpy python=3.7 activate tpy Anaconda Prompt3. Installing TabPyFrom the activated ‘tpy’ environment, execute following commands:pip install tabpy pip install pandas tabpyThe first two lines will install TabPy and pandas (required for Prep) and the third line will start the tabpy server at port 9004.Installing and Running Tabpy4. Tableau Prep Python IntegrationIn Order to use Python code in the flow, we need to use ‘Add Script’ step. We will use a simple function to sort the output data in descending order of sales. Save the below lines of code in a file with .py extension.def sort_descending(df): """Sorts the dataframe in descending order of sales.""" return df.sort_values(by=['Sales'], ascending=False)Below screen grab shows the entire process. You can download the packaged flow file here.Tableau Prep Python Integration5. TabPy Additional ConfigurationsTabPy is highly configurable and the configurations can be controlled using a configuration file. Common configuration settings include Changing port number, enabling HTTPS, Enabling Authentication, Change Logging Levels, etc.Download this sample configuration file (use right click and save link as) and you can start TabPy server using the configuration using below command:tabpy --config=path_to_the_downloaded_fileDescribing all configuration settings are beyond the scope of this post, but you can find details at this link.Running Tabpy with Configuration FileIf you have any questions, please feel free to ask in the comments and I will try my best to answer. Post navigationTableau Prep – Aggregating Strings
So after installing TabPy and being able to connect Desktop to it, I applied SSL. I can successfully connect via Desktop , but I’m unable to connect to the same server via Prep. Have you ever come across this?Reply