NameError: name 'input_table' is not defined

Hi, i want to run the following script in a Knime workflow, I used the Python Scripting Node:

import as knio

import pandas as pd

knime_output_tables[“python_tabelle.table”] = input_table

def calculate_profit(excel_daten_p):
excel_daten_p[“Gewinn”] = excel_daten_p[“Preis”] - excel_daten_p[“Kosten”]
knime.push(excel_daten_p, ‘python_tabelle.table’)

How should i define the input table right? Thx

import as knio

# tables will come in as Arrow tables and can be converted to pandas data frame
input_table = knio.input_tables[0].to_pandas()

# you can manipulate or create a new pandas data frame
output_table = input_table.copy()

# to get the whole thing back you bring the pandas data frame back to Arrow
knio.output_tables[0] = knio.Table.from_pandas(output_table)

As suggested you might want to consult the Python guide and check out these examples:


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