Python Script Node error unsupported operand type(s)

Hi all,

I have an error with Python Script Node


I get this error when i try to run this code in the Python Script Node, can someone help me to fix this error.

Here are the types of my columns
image

But when i’m trying to run the same code in Series, it’s working.

The same code where I had the problem knime works on Jupyter

Hi @dsyouness,

Could you please share your workflow or the data you are working on? I am not really sure what the problem could be, so reproducing it locally would probably be fastest to see what is going on. Thanks!

Marcel

Hi @MarcelW thank you for reply, i just create a node KNIME_interpolate.knwf (8.4 KB)

Hi @dsyouness,

The 'nearest' interpolation method you are using requires the DataFrame’s index to be numerical in order to tell which row is nearest to the one being interpolated at a time. In KNIME, however, the index of the DataFrame is of the form Row0, Row1, Row2, etc. (so, string-valued). If you expect the index to be equally spaced, you could simply use the 'linear' interpolation method instead of 'nearest'. If you do require a notion of distance between your rows (for example, because rows in the input have been skipped like so: Row0, Row2, Row3; then Row2 would be closer to Row3), you must first convert the index into a numerical form.

More information about pandas’s interpolate function can also be found here.

Marcel

3 Likes

Thank you very much @MarcelW , it’s work i just add a line of code :slight_smile:

output_table = output_table.reset_index(drop=True)

5 Likes