It is not possible to type your Python code directly into Tableau Prep like you can in Tableau Desktop. Now, we should be connected to the TabPy Server: In my case, the server runs on localhost port 9004, and no credentials are required. Enter your server details here and click Sign In. Then click on Connect to Tableau Python (TabPy) Server in the configuration window:Ī connection configuration window will pop up like in the image below. Select the newly added Script step, and select Tableau Python (TabPy) Server as Connection type. To make use of Python in Tableau Prep, we need to add a Script step to our workflow: Connecting to TabPy Server from Tableau Prep Now we can begin our work in Tableau Prep. Optionally, to make sure the server is running, we can try accessing the port 9004 on our browser, which should look like this when the server is running: The default settings can be adjusted according to your needs, but that is outside the scope of this post. What we are really interested in is the last line where we see that the server is running on port 9004, which is the default setting. To run the TabPy Server, we merely have to type tabpy in the Anaconda prompt:įrom the log, we can see that the TabPy Server has launched. It is not required to have TabPy Server on the same machine that you are running Tableau Prep on, but it must be accessible for your Tableau Prep. This will also install the necessary dependencies. I am using the Anaconda distribution of Python, so I will just go ahead and install TabPy Server by typing pip install tabpy in my Anaconda prompt: You also need to have TabPy Server library installed. To use Python with Tableau Prep or Desktop, you, of course, need to have a distribution of Python installed. Fortunately for our demo, we can do a fuzzy match using Python. Unfortunately, fuzzy matching is not supported by default in Tableau Prep at the moment. One way to go about this problem would be to use fuzzy matching, which is a technique of finding strings that match the pattern in a target string approximately rather than exactly. We can go ahead and match each account manually in Prep, but this could take hours if we have hundreds of accounts. These are typical errors when entering company names manually. Inc, Ltd, SA) as the prefix or suffix, and/or some contain typos in the company name. Some account names have company types (e.g. The others have not been joined because the names do not match correctly. However, when attempting to join on account, we only join about 10% of accounts successfully. We have two datasets: one with sales per account for last year and the other with the sales representatives assigned to each of our accounts:Ībove: Sales representatives responsible for each accountĪt first glance, the solution is straightforward: we simply have to join the two datasets on the account field, and we would have the amount of sales generated by each sales representative. For this demo, we will attempt to find out how much each of the 15 sales representatives in an imaginary company sold last year. I will explain how to use Python in Tableau Prep using the demo use case below, but before proceeding to the Python part, let me give you some background on what I am trying to achieve with Python in this particular case. A blog on how to use Python in Tableau Desktop will be coming soon. Please note that using Python in Tableau Prep is different than using Python on Tableau Desktop. With Python, you can do all of this and so much more, extending the power of Tableau Prep whilst staying within the boundaries of a Tableau Prep workflow. But sometimes, you need to apply a function that has no equivalent in Prep, want to extract some data using an API interface or even apply some machine learning or natural language processing algorithms. It offers a lot of tools to pre-process and transform your data. Tableau Prep has improved considerably since it was launched.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |