title: "TypeError: bad operand type for unary ~: 'float'" not down to NA (not available)?
body: <p>I'm trying to filter a pandas data frame. Following @jezrael's answer <a href="https://stackoverflow.com/a/54439631/575530">here</a> I can use the following to count up the rows I will be removing:</p>
  
  <pre class="lang-python prettyprint-override"><code>mask= ((analytic_events['section']==2) &amp; 
         ~(analytic_events['identifier'].str[0].str.isdigit()))
  print (mask.sum())
  </code></pre>
  
  <p>However when I run this on my data I get the following error:</p>
  
  <blockquote>
    <p>TypeError                                 Traceback (most recent call last) 
     in <br>
          1 mask= ((analytic_events['section']==2) &amp;<br>
    ----> 2        ~(analytic_events['identifier'].str[0].str.isdigit()))<br>
          3<br>
          4 print (mask.sum())  </p>
    
    <p>c:\program files\python37\lib\site-packages\pandas\core\generic.py in <strong>invert</strong>(self)<br>
       1454     def <strong>invert</strong>(self):    1455         try:
    -> 1456             arr = operator.inv(com.values_from_object(self))<br>
       1457             return self.<strong>array_wrap</strong>(arr)<br>
       1458             except Exception:</p>
    
    <p>TypeError: bad operand type for unary ~: 'float'</p>
  </blockquote>
  
  <p>The accepted wisdom for that error, <code>bad operand type for unary ~: 'float'</code>, is that the unary operator encountered a NA value (for example, see <a href="https://stackoverflow.com/a/52297788/575530">this answer</a>)</p>
  
  <p>The problem is that I do not have any such missing data. Here's my analysis. Running</p>
  
  <pre class="lang-python prettyprint-override"><code>analytic_events[analytic_events['section']==2]['identifier'].str[0].value_counts(dropna=False)
  </code></pre>
  
  <p>gives the results:</p>
  
  <blockquote>
    <p>2    1207791<br>
    3      39289<br>
    1        533<br>
    .         56  </p>
  </blockquote>
  
  <p>Or running </p>
  
  <pre class="lang-python prettyprint-override"><code>analytic_events[analytic_events['section']==2]['identifier'].str[0].str.isdigit().value_counts(dropna=False)
  </code></pre>
  
  <p>gives the results</p>
  
  <blockquote>
    <p>True     1247613<br>
    False         56  </p>
  </blockquote>
  
  <p>(Note that the amounts above sum to the total number of rows, i.e. there are none missing.)</p>
  
  <p>Using the more direct method suggested in @jezrael's answer <a href="https://stackoverflow.com/a/54443038/575530">below</a></p>
  
  <pre class="lang-python prettyprint-override"><code>analytic_events[analytic_events['section']==2]['identifier'].isnull().sum()
  analytic_events[analytic_events['section']==2]['identifier'].str[0].isnull().sum()
  </code></pre>
  
  <p>both produce the output zero. So there are no NA (not available) values. </p>
  
  <p>Why am I getting the error</p>
  
  <blockquote>
    <p>TypeError: bad operand type for unary ~: 'float'</p>
  </blockquote>
  
  <p>from the code at the start of this post?</p>