Reputation: 27
Is there a way to make this ELIF statement simplier, by the way this code doesnt work. The variable that change is APPOINTMENT
elif (rut == '80010900-0' and agental_launch != "" and 'TAL' in appointment) or
(rut == '80010900-0' and agental_launch != "" and 'IQQ' in appointment) or
(rut == '80010900-0' and agental_launch != "" and 'ANF' in appointment) or
(rut == '80010900-0' and agental_launch != "" and 'MJS' in appointment) or
(rut == '80010900-0' and agental_launch != "" and 'QTV' in appointment) or
(rut == '80010900-0' and agental_launch != "" and 'SVE' in appointment) or
(rut == '80010900-0' and agental_launch != "" and 'PMC' in appointment) or
(rut == '80010900-0' and agental_launch != "" and 'CHB' in appointment):
df.at[idx,'REBATE'] = round(int(monto_neto)*0.35)
Upvotes: 0
Views: 55
Reputation: 7844
You can do it this way:
elif rut == '80010900-0' and agental_launch != "" and any(elem in appointment for elem in ['TAL','IQQ','ANF','MJS','QTV','SVE','PMC','CHB']):
df.at[idx,'REBATE'] = round(int(monto_neto)*0.35)
Upvotes: 1
Reputation: 140188
use any
for the last condition which becomes a one-liner:
elif rut == '80010900-0' and agental_launch != "" and any(x in appointment for x in ['TAL','IQQ','rest of strings to match...']):
Upvotes: 1