Icon

kn_​example_​python_​index_​rowid

KNIME and Python - handle index columns and row_id

KNIME and Python - handle index columns and row_id
Python script would convert the KNIME RowID to pandas data frame index

import knime.scripting.io as knioimport pandas as pddf = knio.input_tables[0].to_pandas()# store the transfered indexdf['python_index'] = df.index# set the index to an existing columndf.set_index('original_row_id',inplace=True)knio.output_tables[0] = knio.Table.from_pandas(df) KNIME and Python - handle index columns and row_idPython script would convert the KNIME RowID to pandas data frame index test_data_all_typesfilter typesnew_id$new_id$ >= 10 => TRUETRUE => FALSEremove the first 10 linesCounteroriginal_row_idtest_from_python.tabletest_from_python.table Test Data Generator Column Filter Java Snippet(simple) Rule-basedRow Filter Column Rename Counter Generation RowID Python Script Table Writer Table Reader import knime.scripting.io as knioimport pandas as pddf = knio.input_tables[0].to_pandas()# store the transfered indexdf['python_index'] = df.index# set the index to an existing columndf.set_index('original_row_id',inplace=True)knio.output_tables[0] = knio.Table.from_pandas(df) KNIME and Python - handle index columns and row_idPython script would convert the KNIME RowID to pandas data frame index test_data_all_typesfilter typesnew_id$new_id$ >= 10 => TRUETRUE => FALSEremove the first 10 linesCounteroriginal_row_idtest_from_python.tabletest_from_python.table Test Data Generator Column Filter Java Snippet(simple) Rule-basedRow Filter Column Rename Counter Generation RowID Python Script Table Writer Table Reader

Nodes

Extensions

Links