Before I go crazy due to the lack of my Python skills I would first like to ask here if there is a difference when using Python within Knime vs plain Python?
Example: I have a Python script using with pandas, specifically working with the index. This index is integer (in python (3.7.9)). Even if it were string you could cast it to int (at least what I found on the net).
In Knime this index of the dataframe suddenly is string. But attempting to cast it to int gives errors.
All good/bad pandas practices aside (e.g. use of index the way I do), this does make me wonder what I might be missing?
(If this isn’t an easy answer I will try to post some code)
Using Knime 4.2.3 (Ubuntu); same Python environment.
While converting Knime table’s index to int it will raise error as the conversion is Rowxx → int(“Rowxx”)
Instead try this input_table.index = range(input_table.shape).
There are a few differences and they can be tackled in similar fashion.
Did it help?
can you share an example?
Thanks, that was indeed the issue and this solved it.
Now there are some others issue (indentations and such), but that might be due to the fact that it’s late. I’ll get back to you tomorrow.
When it comes to the range, that could also be solved by changing the RowID with Knime nodes Counter Generation and RowID, then a index range isn’t necessary.
E.g.: my script contains a regex search example:
regex1 = re.compile("$xyz.+")
regex2 = re.compile("$[^x]")
This will require \\ or something? If anyone knows, be my guest, otherwise I keep fiddling with it.
Yes the count and rowid node would work.
Can you give an example for the regex? Like what is required from what.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.