title: Calculating percentile on pandas dataframe and assigning binary value to new column
body: <p>Take a dataframe with one column of imagined 'temperature' data:</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  
  dates = pd.date_range('20070101',periods=3200)
  df = pd.DataFrame(data=np.random.randint(0,100,(3200,1)), columns =list('A'))
  df['date'] = dates
  df = df[['date','A']]
  </code></pre>
  
  <p>I want to assign all rows with values below the 10th percentile and above the 90th percentile with -1 and 1 respectively (with all else being 0). </p>
  
  <p>Here's a function to try and do that:</p>
  
  <pre><code>temp = []
  def quantilecalc(x):
      for season in df:
          if season &gt; df.quantile(.9):
              temp.append(1)
          if season &lt; df.quantile(.1):
              temp.append(-1)
          else:
              temp.append(0)
  </code></pre>
  
  <p>When I apply this <code>quantilecalc(df)</code> I get the following error:</p>
  
  <pre><code>File "C:\\\\lib\site-packages\pandas\core\ops.py", line 682, in na_op
  raise TypeError("invalid type comparison")
  
  TypeError: invalid type comparison
  </code></pre>
  
  <p>I've tried applying it to the specific column of the dataframe <code>quantilecalc(df['A'])</code> but this gives the same error. Would really appreciate some expertise...</p>