Q:

How to filter dataframe from multiple condition and replacing differnt value in Dataframe Column in python?

I have a Dataframe
PROD   TYPE  QUANTI CONFI avail  req
 wood   i     20     100   1000  800
 tv     u     30     100   500   600
 tabl   i     50     100   300   200
 rmt    z     40     100   50    100
 zet    y     60     100   200   400
 rm     t     60     100   300   500
 rt     f     80     100   500   200
 dud    i     40     100   900   800

I want to keep Column "CONFI" to 100 if avail- req >80
"CONFI" to 10 if column "TYPE" is "i" (if it satisfy the condition ) and "CONFI" to 0 if it does not.
( Means"TYPE"== "i" could either be 10 or 0)
And rest to zero if it doesn't meet any condition
PROD   TYPE  QUANTI CONFI avail  req
 wood   i     20     10   1000   800
 tv     u     30     100   700   600
 tabl   i     50     0     300   250
 rmt    z     40     0     50    100
 zet    y     60     100   200   400
 rm     t     60     0     300   500
 rt     f     80     100   500   200
 dud    i     40     10    900   800

A:

IIUC use:
m1 = (df.avail - df.req) > 80
m2 = df.TYPE == 'i'

df['CONFI'] = np.where(m2, 10, np.where(m1, 100, 0))
print (df)
   PROD TYPE  QUANTI  CONFI  avail  req
0  wood    i      20     10   1000  800
1    tv    u      30    100    700  600
2  tabl    i      50     10    300  200
3   rmt    z      40      0     50  100
4   zet    y      60      0    200  400
5    rm    t      60      0    300  500
6    rt    f      80    100    500  200
7   dud    i      40     10    900  800

Solution with numpy.select:
df['CONFI1'] = np.select([m2,m1], [10,100], 0)

