I have a Knime Table Reader node connected to a Python Script node.
My python script is:
import knime.scripting.io as knio
dataset = knio
print('Shape of the dataset: ’ + str(dataset.shape))
print(dataset.head())
The system complains that there are no attributes for shape or head.
It appears that I am not specifying knio properly for Knime to pass the data set.
What am I doing wrong?
@Bob_Nisbet the in and out syntax would look like this for pandas dataframes.
import knime.scripting.io as knio
import numpy as np
import pandas as pd
# data from KNIME to Python (pandas)
df = knio.input_tables[0].to_pandas()
# data from python (pandas) to KNIME
knio.output_tables[0] = knio.Table.from_pandas(df)
mlaubers link to the documentation should answer these questions. It also shows the template section in the node from where you can get ready-to-use code snippets. Furthermore, please have a look at the description of the node.