python node - 5 columns expected but only 2 written to csv. . .

Hi all,

I’m struggling with the Python-node . . .

My script expects 5 columns but in practice only 2 are viewed and written to a csv-file.
If I run the script in Anaconda everything is OK.

I can imaging that the Python-node summarizes if there are to much columns (see screenshot) but what is the correct code to write all columns?

I enclosed the basic flow my script (I included 2 ways to write to a csv but the output is basically the same)

Hopefully someone can help.

Many THNX in advance

KNIME_python.knwf (7.5 KB)

you have various dataframes in a list so when you write the data you write the list objects not the dataframe columns.
dfs[0] returns you a dataframe
What do you expect? br


@sanderlenselink you create a list of data frames. You could append them in you loop or add these lines afterwards. You will have to reset the index because KNIME does not allow duplicate indexes when bringing the data back from Python.

# create an initial data frame to export
df_export = dfs[0]

# add the other data frames below
for i in range(1, len(dfs)):
    df_export = pd.concat([df_export, dfs[i]], axis=0)

# reset the index
df_export.reset_index(drop=True, inplace=True)

output_table_1 = df_export.copy()

Just for fun you could also export the data frames as single parquet files and bring them back later into KNIME in one step. You would have to clean the column names (the one with the date time names) since Parquet would not like that.

1 Like

@mlauber71 . . . thnx for you feedback. A very interesting solution (fun :grinning: :grinning:).
Now I understand also much better @Daniel_Weikert his remark.

However . . . I try to execute your script/example (import some finance data with Python etc 47320).

I didn’t know the Conda Environment Propagation node and not fully understand it but I get it running.

In the Python Script (Labs) you import Skimpy but that produces an error. I searched at but there’s only a link for Linux and OSX-64. In your configuration I see you use the channel “pypi”.
I use u Windows system

My question . . . what is the command to implement Skimpy in Conda? See the 2nd screenshot the command I used . . neither “conda install -c weilandtd skimpy” or.“conda install -c pypi skimpy” works.

If I delete (comment out) the Skimpy lines in Python Labs including "clean columns"etc your script runs smoothly

Hope you can help

I don’t know that package but conda is (in my opinion) a terrible install option.
I would go with pip

pip install skimpy==0.0.2

(make sure that pip path is either in your windows env variables or that you run the command inside a terminal pointing to your scripts folder in your python installation path)


@sanderlenselink the environment propagation is from a Mac system. You can try to use the included yaml file under /data/ and create your own environment from scratch on Windows.

Or indeed you could use your existing python environment and just add the package like @Daniel_Weikert has suggested. Also there might be other ways to clean the headers.

And then there is the other python node which does not use partquet at all.