Python Forum
Read excel file to determine the rules
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read excel file to determine the rules
#3
Hi,

I did try to convert the user defined business rule (excel) to an IF condition statement and trying to assign the entire If elif statements to an function. So that I can pass it to below statement to apply the rules.

ouput_df['der_factor'] = input_df.apply(result_func, axis = 1)

When I have the function with manually coding the rules it works (as shown below), I need help on couple of things,
1. Is IF statement the efficient way to handle this scenario?
2. If so, how can I pass the entire dynamically generated IF statement (including elif and returns) in the function.

def result_func(input_df):

if (input_df['ABC'] == 12):
return '1.25'
elif (ip_df['ABC'] == 11):
return '0.25'
else:
return '1'

Any pointers/suggestions would be much helpful.
Thanks.
Reply


Messages In This Thread
RE: Read excel file to determine the rules - by abc12345 - May-12-2020, 01:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Connecting to Remote Server to read contents of a file ChaitanyaSharma 1 404 May-03-2024, 07:23 AM
Last Post: Pedroski55
  Python openyxl not updating Excel file MrBean12 1 503 Mar-03-2024, 12:16 AM
Last Post: MrBean12
  Copy Paste excel files based on the first letters of the file name Viento 2 596 Feb-07-2024, 12:24 PM
Last Post: Viento
  Recommended way to read/create PDF file? Winfried 3 3,101 Nov-26-2023, 07:51 AM
Last Post: Pedroski55
  python Read each xlsx file and write it into csv with pipe delimiter mg24 4 1,815 Nov-09-2023, 10:56 AM
Last Post: mg24
  Search Excel File with a list of values huzzug 4 1,419 Nov-03-2023, 05:35 PM
Last Post: huzzug
  Updating sharepoint excel file odd results cubangt 1 1,013 Nov-03-2023, 05:13 PM
Last Post: noisefloor
  read file txt on my pc to telegram bot api Tupa 0 1,269 Jul-06-2023, 01:52 AM
Last Post: Tupa
  parse/read from file seperated by dots giovanne 5 1,248 Jun-26-2023, 12:26 PM
Last Post: DeaD_EyE
  Formatting a date time string read from a csv file DosAtPython 5 1,613 Jun-19-2023, 02:12 PM
Last Post: DosAtPython

Forum Jump:

User Panel Messages

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