5 python columns, row-wise as input to a function - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: 5 python columns, row-wise as input to a function (/thread-19864.html) |
5 python columns, row-wise as input to a function - dervast - Jul-17-2019 Hi all, I have a data frame that has 5 columns named as '0','1','2','3','4' small_pd Out[53]: 0 1 2 3 4 0 93.0 94.0 93.0 33.0 0.0 1 92.0 94.0 92.0 33.0 0.0 2 92.0 93.0 92.0 33.0 0.0 3 92.0 94.0 20.0 33.0 76.0I want to use row-wise the input above to feed a function that does the following. I give as example for the first and second row firstrow: takeValue[93]-takeValue[94]+takeValue[93]-takeValue[33]+takeValue[0]secondrow: takeValue[92]-takeValue[94]+takeValue[92]-takeValue[33]+takeValue[0]for the third row onwards and then assign all those results as an extra column. I have heard about lambda function that can work row-wise but I am not sure how to implement one. Can you please advice me? Thanks a lot Alex RE: 5 python columns, row-wise as input to a function - Larz60+ - Jul-17-2019 just pass small_pd to the function. |