Have you seen this line of code before? What is Python_Data_Function?
from Python_data_function import *
It appears after clicking the Register New button in the data functions dialog. You won’t see it if you have selected the TERR or R engine. It only appears when the script type is Python Script Executor. Now, you might be wondering what “Python_Data_Function” is and whether it’s necessary.
What Is It?
Python_Data_Function is a custom extension. TIBCO’s Professional Services Group developed it to employ the Python language in data functions. Customers and partners may use it for free under the TIBCO Component Exchange License.
Like other custom extensions, it must be deployed on the Spotfire Server. If you have admin rights, the extension will be visible in the deployment area as shown here.
How Important Is It?
Hint, it’s really important. It enables Python data functions. They will fail without it. You can read up on the finer details on the extension in this TIBCO Community article.
Spotfire Version
Content created with Spotfire 10.2.
If You Are Just Getting Started…
Check out the other articles I’ve written on how to set up your machine to run Python data functions. I’ve also explanations on how to install Python packages to really take advantage of this great functionality.
Thank you Julie. This is very helpful. Have you run into an error message when calling the Python data function that says the type ‘System.Single’ of the property does not match the expected ‘System.Double’ type when using a real variable? I am inputting and outputting to a document property. The code works for an integer value.
Unfortunately, I haven’t run into that problem.
Hi Julie,
You recently helped me understand TERR Data Functions better and now I’m diving into some Python ones as I know slightly more Python than R. My key goal for R and Python scripts these days is simplifying the creation of calculated columns (right now I do it as a series of 16 calculated columns…too much)
I did a ultra simple test and my Python script was: x3 = x2*2 That’s it. I set up the input and outputs and ran, and then adjusted the input and output parameters and the script ran fine however the new column keeps coming out as x2(2) rather than x3…..I noticed a few Dr. Spotfire videos had the same issue when he showed a simple script just like that….have you noticed this / have idea what would need to be done? I want to make sure I understand the issue before moving on to more complex things.
I’m not quite following what you’re doing in the expression. Do you mean [column value]3 = [column value]2*2? Think we can get it worked out if I can understand what you’re doing. I know it’s simple. There’s just something that’s not translating.