Working with data using python

Hello guys.
I have created node Excrl reader, then node column filter widget and it is connected to the node Python script. But i don’t know how i can extract that data for calculations

1 Like

Hello @Alex_025
You can learn in the node by looking at the examples in ‘Templates’ tab.

Besides that, take a look in the following code as starting point:

import knime.scripting.io as knio
import pandas as pd

# data in
df = knio.input_tables[0].to_pandas()

# things happen
print(df)

# output as pd.DataFrame
knio.output_tables[0] = knio.Table.from_pandas(df.to_frame())

BR

3 Likes

OK, thank you. I tried this code, but I don’t quite understand the error I keep getting: return object.getattribute(self, name)
AttributeError: ‘DataFrame’ object has no attribute ‘to_frame’

@Alex_025 you might try without the .to_frame() part. Take a look at these examples:

2 Likes

Hello
@mlauber71 is right… i mixed up two different scripts, and didn’t check afterwards. Sorry for that

import knime.scripting.io as knio
import pandas as pd

# data in
df = knio.input_tables[0].to_pandas()

# things happen
print(df)

# output as pd.DataFrame
knio.output_tables[0] = knio.Table.from_pandas(df)

BR

2 Likes