How do I deal with Pandas Series data type that has NaN?
<p>What happens when using max() and min() on pandas.core.series.Series type that has NaN in it? Is this a bug? See below,</p>

<hr>

<pre><code>%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

mydata = pd.DataFrame(np.random.standard_normal((100,1)), columns=['No NaN'])
mydata['Has NaN'] = mydata['No NaN'] / mydata['No NaN'].shift(1)

# Both return NaN!
print(min(mydata['Has NaN']), max(mydata['Has NaN']))
# Still why False? Isn't float('nan') a singleton like None?
print(min(mydata['Has NaN']) == max(mydata['Has NaN']))
# But this time works well!
print(min([1, 2, 3, float('nan')]))

print('\n')

# When Series data type that has NaN bumps into min() and max(), what should 
#  I do? E.g.,
try: 
    n, bins, patches = plt.hist(mydata['Has NaN'], 10)
except ValueError as e:
    print(e, '\nSeems "range" argument in hist() has problem!')
</code></pre>

<p>you should use Pandas or NumPy functions instead of vanilla Python ones:</p>

<pre><code>In [7]: mydata['Has NaN'].min(), mydata['Has NaN'].max()
Out[7]: (-46.00309057827485, 62.430829637766671)

In [8]: min(mydata['Has NaN']), max(mydata['Has NaN'])
Out[8]: (nan, nan)

In [125]: mydata.plot.hist(alpha=0.5)
Out[125]: &lt;matplotlib.axes._subplots.AxesSubplot at 0x1a784588&gt;
</code></pre>

<p><a href="http://i.stack.imgur.com/4XDwJ.png" rel="nofollow"><img src="http://i.stack.imgur.com/4XDwJ.png" alt="enter image description here"></a></p>

python pandas matplotlib dataframe