' | ' operator between python set objects
<p>Recently while making changes to a python module someone else wrote which does some processing on Pandas dataframe I came across a line of code which looks like this :</p>

<p><code>
indices_invalid_entries = \
list(set(indices_invalid_entries) | set(list(df[pd.isnull(df[i])].index)))
</code></p>

<p>where indices_invalid_enteries is initially an empty list.
So basically what we are doing here is checking for Dataframe indexes in certain columns where there is <strong>NULL</strong> values.</p>

<p>Now I know what <strong>set, list, pd.isnull</strong> functions do.</p>

<p>But what can't seem to get is what purpose is the <em>BITWISE</em> <strong>OR</strong> operator <strong>|</strong> here. How will Bitwise OR(ing) of objects gonna store Indices of Invalid Enteries?</p>

<p>Can someone explain?
Thanks</p>

<p>As explained in the <a href="https://docs.python.org/2/library/sets.html" rel="nofollow">documentation</a>, the | operator is the <strong>union operator</strong>.</p>

<p>So as you mentioned in you answer, </p>

<pre><code>indices_invalid_entries &lt;-- union(indices_invalid_entries,df[pd.isnull(df[i])].index)
</code></pre>

<p>And the general case:</p>

<pre><code>Union = A | B      # where A,b,Union are sets
</code></pre>

python pandas numpy