title: Pandas: Using .isin() returns the error: "AttributeError: float' object has no attribute 'isin'"
body: <p>I am using Pandas and Python to import a CSV, and the data in the imported dataframe is manipulated so that a new column is made.</p>
  
  <p>Each row in the new column is made based on the values in each corresponding row of both column A and column B.
  There are more columns with data in the dataframe, however these are irrelevant for code below.</p>
  
  <p>The imported dataframe have several thousand rows.</p>
  
  <p>Both column A and column B contain numerical values between and including 0 and 99.</p>
  
  <p>import pandas as pd</p>
  
  <pre><code>import csv
  
  df = pd.read_csv("import.csv", names=["Id", "Month", "Name", "ColA", "ColB" ])
  
  def f(row):
      if row['colA'].isin([10, 11, 12, 13, 14, 15, 20, 21, 22, 23, 24, 48]) and  row['colB'].isin([30, 31, 32, 33, 34, 35, 57, 58]):
          val = row['ColA']
      elif row['ColB'].isin([10, 11, 12, 13, 14, 15, 20, 21, 22, 23, 24, 48]) and  row['ColA'].isin([30, 31, 32, 33, 34, 35, 57, 58]):
          val = row['ColB']
      elif row['ColA'] &gt; row['ColB']:
          val = row['ColA']
      elif row['ColA'] &lt; row['ColB']:
          val = row['ColB']
      else: 
          val = row['ColA']
      return val            
  
  df['NewColumnName'] = df.apply(f, axis=1)   
  
  df.to_csv("export.csv", encoding='utf-8')
  </code></pre>
  
  <p>Running the above code returns the error:</p>
  
  <pre><code>AttributeError: ("'float' object has no attribute 'isin'", 'occurred at index 0')
  </code></pre>
  
  <p>So obviously .isin() can't be used in that manner. Any suggestions to how this could be solved?</p>
  
  <p><strong>EDIT</strong>
  Adding a column where the same conditions apply using Jezrael's approach the code would look as follows I guess:</p>
  
  <pre><code>m1 = (df['colA'].isin(L1) &amp; df['colB'].isin(L2)) | (df['ColA'] &gt; df['ColB'])
  m2 = (df['colB'].isin(L1) &amp; df['colA'].isin(L2)) | (df['ColA'] &lt; df['ColB'])
  m3 = (df['colC'].isin(L1) &amp; df['colB'].isin(L2)) | (df['ColC'] &gt; df['ColB'])
  m4 = (df['colB'].isin(L1) &amp; df['colC'].isin(L2)) | (df['ColC'] &lt; df['ColB'])
  m5 = (df['colC'].isin(L1) &amp; df['colA'].isin(L2)) | (df['ColC'] &gt; df['ColA'])
  m6 = (df['colA'].isin(L1) &amp; df['colC'].isin(L2)) | (df['ColC'] &lt; df['ColA'])
  
  
  
  df['NewColumnName'] = np.select([m1, m2, m3, m4, m5, m6], [df['ColA'], df['ColB'], df['ColC'], df['ColA'], df['ColB'], df['ColC'],], default=df['ColA'])
  </code></pre>