1 Reply Latest reply on Dec 2, 2019 9:46 AM by Nathan Mannheimer

    How to export the outcome of TabPy calculation as one list

    philip.hamoui

      I am still beginner in using TabPy external connection with Tableau, so I am not quite sure if what I am asking for is doable or not.

      I have this excel table, which I am using TabPy to do some external calculations on it.

      The outcome in this case is correct and as I expected, however, there are these issues:

      1. Apparently, TabPy calculations are being done over all the table for each row
      2. Looking at the anaconda terminal, it prints out the script itself for each row (I don’t need that actually).

      For the excel spreadsheet attached here, it’s somehow acceptable, however, for my real calculations, I have these issues:

      1. I need to do even more complicated computation over thousands of rows.
      2. I need to import the external sheet

       

      My questions is:

      How can I do the required calculation only once, and assign the resulting list to the outcome of the calculated filed?

       

      I appreciate any hint, reference, or explanation.

      Thanks!

       

      Update: I added a new sheet python_calculation_import to my workbook, to clarify the point that the calculation is showing only the first result of the calculation.

        • 1. Re: How to export the outcome of TabPy calculation as one list
          Nathan Mannheimer

          Hi Philip,

           

          This video should provide more information on how TabPy works in Tableau. TabPy can run on every row, but you can also run the computation across the whole table by changing the table calculation to address all values instead of partitioning: Data science applications with TabPy/R - YouTube. Doing this will allow you to return all values from the operation as a single list.

           

          In your code, it's usually best to read in the data from Tableau, though you can import external data in Python. Each column is brought in from Tableau as a Python list, and it's pretty easy to then construct a dataframe and do table operations on it. The result you return to Tableau must either be a constant or a list.