Hi I am new to knime. I wanted the python snippet to give output as dictionary instead of dataframe. But when I return output_table as dictionary I get error as :
ERROR Python Script (2⇒1) 0:7 Execute failed: Expected pandas.DataFrame, got: <class ‘dict’>
Please make sure your output_table is a pandas.DataFrame.
Is there any way I can return a dictionary or does any node exists which is applicable in my scenario.
Unfortunately, that’s not possible using the KNIME Python integration. Input and output tables are always represented as pandas DataFrames within Python.
May I ask why you prefer dictionaries over data frames? Constructing a data frame from a dictionary should be as easy as pandas.DataFrame(my_dict).
Well you could always store a dictionary (or other Python object) as a pickle file and later reload it. Not sure if this is of any help.
The Python dictionary could be converted into a proper KNIME table. And later back to a Python dictionary. The exact settings and structure are a little tricky - you might have to toy around with it.