John Frame 3 Posted May 16, 2023 Share Posted May 16, 2023 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 matchValue 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 More sharing options...
Gaia Paolini Posted May 17, 2023 Share Posted May 17, 2023 There is a Python package called spotfire that might help you. It is automatically available.Can you try:import spotfirespotfire.set_spotfire_types(df, {'Value':'String'})If this does not work, can you please post an anonymized Spotfire dxp? Link to comment Share on other sites More sharing options...
John Frame 3 Posted May 17, 2023 Author Share Posted May 17, 2023 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 More sharing options...
Gaia Paolini Posted May 18, 2023 Share Posted May 18, 2023 It seems this library was introduced with Spotfire 12. Are you able to send a dxp so I can see if the problem can be solved in another way? Link to comment Share on other sites More sharing options...
giacomo baccolo Posted October 4, 2023 Share Posted October 4, 2023 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 spotfirespotfire.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 More sharing options...
Gaia Paolini Posted October 4, 2023 Share Posted October 4, 2023 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:then, 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: Link to comment Share on other sites More sharing options...
giacomo baccolo Posted October 4, 2023 Share Posted October 4, 2023 Thank you for your reply!What if I can't see spotfire among the installed packages? How can I add it to the list? Thank you Giacomo Link to comment Share on other sites More sharing options...
Gaia Paolini Posted October 4, 2023 Share Posted October 4, 2023 Can you type 'spotfire' into the Available Packages box then press Search? You should be able to select it and install it Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now