how to subtract first row from last row

Hi,

is there an easy way to do math on first and last row of a column? for example add first row with last row.

thanks

Hi @jalilsh

I was thinking of something like this select_first_last_row.knwf (24.8 KB)
Screenshot from 2020-06-07 20-48-19
gr. Hans

5 Likes

HI @HansS,

thanks for your reply. it seems quite simple and efficient to me. in fact, i used sort ascending and then partition to separate the first row and then again resort descending and partition the first row (actually the last row). but my way needs two times sorting and your solution is much more efficient.

thanks

3 Likes

I am a big fan of integrating python and knime. I know this isn’t preferred for everyone. But just in case you want to learn, I uploaded an example with some documentation in the python node to get started. You’ll need python set up for KNIME and the pandas library.

But my workflow does the operation in just one node :sunglasses:

python_first_law_row.knwf (13.0 KB)

1 Like

@scapuzzi, @HansS

thanks for your reply and help.

I wonder if this task should be performed in a loop for for example 100000 different tables, then which solution is faster or more efficient?

I appreciate any comment

BR

Hi @jalilsh

In this case the KNIME flow will isfaster. . I don’t know what the impact on performance is when you have larger files. Just try it yourself. But I assume KNIME will still be faster … :thinking:
gr. Hans

Hello!

@jalilsh With Python there is serialization penalty so think KNIME should be faster. Especially if you use KNIME streaming functionality :wink:

@scapuzzi you can use KNIME Hub to share one node solutions with Python :wink:

Br,
Ivan

1 Like

Yes, it is better to do in KNIME, probably with a parallel chunk looping too.

Hi Ivan: Not new to KNIME by any means, but I am new-ish to answering questions and the forum. Can you point me to any documentation about best practices for the KNIME hub viz-a-viz how putting a solution there is better than putting a solution here? Thanks!

Hi @scapuzzi,

not really. There’s no such documentation. Having workflow on Hub makes it accessible for more users from my point of view.

Br,
Ivan

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.