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
I wanted to expose my workflow as a Rest endpoint and the output will contain various other outputs which are stored in dictionary for quick access
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.
Bring back the dictionary from the Dataframe and from the pickle file and compare them (links to some relevant Stackoverflow entries in the file)
kn_example_python_pickle_dictionary.knwf (22.5 KB)
Thanks, but using flow variables i was able to solve my problem