Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
multiple conditions
#1
Hi There,

I am trying to replicate one of the SAS functions in Python, not sure how to do it. It would be great if you guys can assist me with this.

Below is the requirement.

I want to perform 2 different functions here.
If name in (“spiderman”,”antman”) and salary between (1000,2000) and city not in ("boston","dubai") then
    new_column=age+salary
else:
    new_column=age*salary 
Below is the dummy data set.

Output:
name age salary city spiderman 20 100 boston he-man 21 200 london superman 22 300 newyork thor 23 400 cairns ironman 24 500 sydney aquaman 25 600 california antman 26 700 spain optimus prime 27 100 sydney bumble bee 28 170 newyork what man 29 290 london spiderman 30 1000 auckland spiderman 31 1800 beijing spiderman 32 3000 delhi antman 33 100 tokyo antman 34 5000 moscow antman 34 1200 dubai antman 35 1800 malaysia
Kind regards,
CK
Reply


Messages In This Thread
multiple conditions - by Chandan - Jan-30-2020, 12:55 AM
RE: multiple conditions - by metulburr - Jan-30-2020, 03:42 AM
RE: multiple conditions - by Chandan - Jan-30-2020, 10:31 AM
RE: multiple conditions - by metulburr - Jan-30-2020, 12:14 PM
RE: multiple conditions - by Chandan - Jan-30-2020, 12:48 PM
RE: multiple conditions - by metulburr - Jan-30-2020, 01:07 PM
RE: multiple conditions - by snippsat - Jan-30-2020, 01:32 PM
RE: multiple conditions - by Chandan - Jan-31-2020, 12:53 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How do you format Update statement with multiple conditions hammer 4 2,110 Dec-16-2021, 10:49 PM
Last Post: hammer
  Multiple conditions when indexing an array with or without np.where noob2305 1 2,683 Oct-25-2020, 02:06 PM
Last Post: jefsummers
  Multiple conditions, one is null moralear27 1 2,204 Sep-13-2020, 06:11 AM
Last Post: scidam
  Help with multiple conditions on ATM program jakegold98 6 9,228 Dec-06-2017, 05:18 PM
Last Post: jakegold98
  Simplifying multiple "or" conditions in if statement. rhubarbpieguy 8 102,176 Jul-22-2017, 12:19 PM
Last Post: rhubarbpieguy

Forum Jump:

User Panel Messages

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