 <p>It is usually a bad idea to use a <code>python</code> <code>for</code> loop to iterate over a large <code>pandas.DataFrame</code> or a <code>numpy.ndarray</code>. You should rather use the available build in functions on them as they are optimized and in many cases actually not written in python but in a compiled language. In your case you should use the methods <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.max.html" rel="nofollow">pandas.DataFrame.max</a> and <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.min.html" rel="nofollow">pandas.DataFrame.min</a> that both give you an option <code>skipna</code> to skip <code>nan</code> values in your <code>DataFrame</code> without the need to actually drop them manually. Furthermore, you can choose a <code>axis</code> to minimize along. So you can specifiy <code>axis=1</code> to get the minimum along columns.</p> <p>This will add up to something similar as what @EdChum just mentioned in the comments:</p> <pre><code>data.max(axis=1, skipna=True) - data.min(axis=1, skipna=True) </code></pre>