Jump to content
We've recently updated our Privacy Statement, available here. ×

Python data function error in transformation


John Frame 3

Recommended Posts

I have a python data function I'm trying to use as a transformation in Data Canvas. When I try to execute it, I get this error:

spotfire.sbdf.SBDFError: types in column 'Value' do not match

Value is a column in my result table, and I tried the following to force the data type of the column to string:

df['Value'] = df['Value'].astype(str)

I still get this error. Any suggestions?

Thanks

Link to comment
Share on other sites

I'm now getting this error:

AttributeError: module 'spotfire' has no attribute 'set_spotfire_types'

My organization currently uses spotfire 10.10. Is this something that would have been implemented in a newer version? Is there a way to update the package?

Link to comment
Share on other sites

  • 4 months later...

Hi Gaia,

Working on Spotfire 10.10 I get the same error as John while I was trying to run a python script. I tried your approach, so I imported the same script on spotfire 12 and added the following lines to the script:

  • import spotfire
  • spotfire.set_spotfire_types(df, {'Qty':int})

I replaced string with int since the column Qty is actually a column of integers.

However, I get this error: AttributeError: module 'spotfire' has no attribute 'set_spotfire_types'.

What can I do?

I' d also like to better understand the nature of the problem, so to try to adjust the script to make it more Spotfire friendly. Can you help me?

Thank you,

Giacomo

Link to comment
Share on other sites

It works for me, so I am not sure what happened.

I noticed that in your script you should use 'Integer' not 'int' as that should be a Spotfire type; and enclosed in quotes as the input parameter should be a string. So:

spotfire.set_spotfire_types(df, {'Qty':'Integer'})

But this should not affect your error. In fact, your original script should throw a different error, because it would complain about the input parameter being the wrong data type.

Can you try this:

first look in the list of installed packages: (menu > Tools > Python tools > Package management)

you should see 'spotfire' listed:

image.png.469621ff7561283cd5e5d0b67fdd431a.pngthen, if you did see it installed:

add these lines to your script:

functions = dir(spotfire)functions = 'n'.join(functions)

then set 'functions' as output parameter of type Value and connect it to a new document property. It should display the list of spotfire functions, each one in a new line. I see this, when I display the document property as a label in a text area:

image.png.d5d9cbf99899e19d6da6470e3a911f64.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...