Python Forum
Applying Function With If
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Applying Function With If
#1
I created a function with if statement to know which table to query and return a value to my dataframe, but I am getting truth value of series is ambiguous error.

Function if statement is as follows:
if s == "A":
   table = "mytable"
elseif s == "Z":
   table = "othertable"
I am creating new column and applying like:
df['newcol'] = df.apply(myfunc(df[col1],df[col2]), axis=1)
I have also tried axis = 0.

Any help is appreciated.
Reply


Messages In This Thread
Applying Function With If - by ab0217 - Jul-01-2019, 09:07 PM
RE: Applying Function With If - by perfringo - Jul-01-2019, 09:27 PM
RE: Applying Function With If - by ichabod801 - Jul-01-2019, 09:53 PM
RE: Applying Function With If - by ab0217 - Jul-02-2019, 01:18 AM
RE: Applying Function With If - by ichabod801 - Jul-02-2019, 02:17 AM
RE: Applying Function With If - by ab0217 - Jul-02-2019, 11:34 AM
RE: Applying Function With If - by ichabod801 - Jul-02-2019, 12:21 PM
RE: Applying Function With If - by ab0217 - Jul-02-2019, 12:27 PM
RE: Applying Function With If - by ichabod801 - Jul-02-2019, 12:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  matplotlib.pyplot functions create new figures instead of applying to the current one karkas 2 2,963 Jul-09-2020, 08:32 AM
Last Post: karkas
  huge and weird values after applying some calculations karlito 2 2,875 Dec-13-2019, 08:32 AM
Last Post: karlito
  Applying operation to a pandas multi index dataframe subgroup Nuovoq 1 3,388 Sep-04-2019, 10:04 PM
Last Post: Nuovoq

Forum Jump:

User Panel Messages

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