I am trying to create a new column in a pandas dataframe using a function that takes two columns as arguments
def ipf_cat(var, con):
    if var == "Idiopathic pulmonary fibrosis":
       if con in range(95,100):
          result = 4
       if con in range(70,95):
          result = 3
       if con in range(50,70):
          result = 2
       if con in range(0,50):
          result = 1
    return result
And then
   df['ipf_category'] = ipf_cat(df['dx1'], df['dxcon1'])
Where df['dx1'] is one column and a string and df['dxcon1'] is another column and an integer from 0-100. The function works fine in python but I keep getting this error
 ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
I have seen previous answers such as
Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
but I can't implement these solutions to my particular function.
 
     
    