Hello everybody,
I’m trying to add an integer column to the output of my Python Script node along with some input columns, but am having trouble with the output type.
My script contains a function that takes the input_table as a pandas data frame, and add some new columns from lists of integers as output_table. Finally the output_table is passed back to KNIME.
Unfortunately the output KNIME table contains the new columns as long datatype instead of integer.
Why this happens? Am I missing something? I’ve tried several methods to try to assure that the content of the list that is converted to the column are integers but the result it’s always the same: new columns of ‘long’ values data type.
Any help and suggestion is very welcome.
Here is a test snippet.
import knime.scripting.io as knio
import pandas as pd
input_table = knio.input_tables[0].to_pandas()
def myFunction(df):
integer_list = list(range(len(df)))
df['my_new_column'] = integer_list
return df
output_table = myFunction(input_table)
knio.output_tables[0] = knio.Table.from_pandas(output_table)