Python script error running node, but executing the script in configure dialog works


I have a problem when I run a python script (1->1). I get the following error message:

ERROR Python Script (1⇒1) 2:229 Execute failed: ‘float’ object has no attribute ‘isoformat’

The strange thing is that when I run the same script in the configure dialog (“execute script”) there is no error and the output is what I expect.

Do you have any idea why this difference?

Hi Marcello,

The error occurs during transfer of the data (“output_table”) from Python to KNIME. This transfer does not happen when you execute the script in the configuration dialogue, that’s why it does not show any error there. In your case, the problem occurs because KNIME does not know how to translate the data in Python into its own data format.

isoformat sounds like you would work with date and time data, do you? If not, KNIME probably somehow confuses the type of your data and erroneously interprets it as date and time. You may be able to avoid that by giving it a hint on the actual data type. You can do it like that:

output_table.your_column = output_table.your_column.astype("float64").

where “your_column” is the name of the column that contains the data that gets misinterpreted.

Please let me know if that is the case and if my suggestion helped :slight_smile: . If your problem persists, please also consider uploading your knime.log file to give us some more information on the problem. Uploading your workflow and data would also be a possibility if you are allowed to do that.



Thank you @MarcelW for your hint.

The problem was a column with mixed data types:

None, np.nan and

I had to convert np.nan -> None:
df_dataset[‘DATES_COLUMN’].replace(np.nan, None, inplace=True)



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.