Python Forum
5 python columns, row-wise as input to a function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
5 python columns, row-wise as input to a function
#1
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.0   
I 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
Reply
#2
just pass small_pd to the function.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  difference between forms of input a list to function akbarza 6 928 Feb-21-2024, 08:02 PM
Last Post: bterwijn
Information How to take url in telegram bot user input and put it as an argument in a function? askfriends 0 1,033 Dec-25-2022, 03:00 PM
Last Post: askfriends
  Showing an empty chart, then input data via function kgall89 0 943 Jun-02-2022, 01:53 AM
Last Post: kgall89
  Element wise computation divon 2 1,504 Jun-01-2022, 02:36 AM
Last Post: divon
  input function question barryjo 12 2,636 Jan-18-2022, 12:11 AM
Last Post: barryjo
  function with 'self' input parameter errors out with and without 'self' called dford 12 3,009 Jan-15-2022, 06:07 PM
Last Post: deanhystad
  Problem with input after function luilong 10 4,020 Dec-04-2021, 12:16 AM
Last Post: luilong
  Exit function from nested function based on user input Turtle 5 2,858 Oct-10-2021, 12:55 AM
Last Post: Turtle
Star I'm getting syntax error while using input function in def. yecktmpmbyrv 1 1,932 Oct-06-2021, 09:39 AM
Last Post: menator01
  Input function cutting off commands at spaces. throwaway34 3 2,154 May-12-2021, 06:40 AM
Last Post: throwaway34

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020