Python output_table not passed on correctly

Hi All, I have a simple workflow with a Python script. The node gets input from a table, adds a new column with double-type scores (between -1 and 1) to it as the output_table. If I run the script in the console, all is fine, the values are correct in the output_table. However if I execute the node, all values are simply 0 in the new column. I tried adding 1 to these, to see, if it's a simple conversion from double to int, but no, the values are still all 0. Has anyone experienced this before? What am I missing?

(Knime v 3.4.1, Python 3.6.1, and using it locally.)

OK, I think I have it: 

  • If I create the output_table dataframe with missing values or only string-type  values first, then change it afterwards to numeric, the values get lost for Knime, even if the output_table has the correct values at the end in the console

  • If I add numeric values to the dataframe when I first define it, the values are submitted to Knime correctly, (even those, that are changed to strings later).

  • When I put all values into the table right at the definition, the correct values are submitted too.

So the theory is: always generate the output_table with the correct variable types, regardless of Python's unsensitivity to this, because Knime remembers it. (At least it can't handle string to numeric, only the other way around.) One general solution to this is to use a temporary dataframe for manipulations and only pass this dataframe to the output_table at the end of the script.


I am facing similar problem now. I am doing a dimentionality reduction using t-sne algorithm and passing the results to output_table. I am pasing the output data only after all the processing and and in the end of the script. I am creating a dataFrame with the resultant data and assigning it to output_table in the last line of the script. When checking the values of output_table using print command or in the View:Standared output, it is showing values as expected. But when check the node output table using right click on node --> table, it is showing some random values; the upperbound is 2190e230 and lower bound is -782233032.

Sample code:
df1 = input_table.copy()
tsne1 = TSNE(n_components=2, verbose=1).fit_transform(df1)
output_table = pd.DataFrame(data=tsne1)

Could anyone help me fix this problem? I already tried converting ‘tsne1’ array to float explicitly before assigning it to output_table. I am trying to fix this for days now. Any help would be really great.

Hi all,

Finally it is working. I changed the last line to this:
output_table = pd.DataFrame(data=np.array(tsne1, dtype=‘float’), columns = [‘X’, ‘Y’])

1 Like