Mark Dickinson added the comment: > perhaps collections.Counter should handle nans as a special case
I don't think that would be a good idea: I'd rather that collections.Counter didn't special case NaNs in any way, but instead treated NaNs following the same (admittedly somewhat awkward) rules that all the other Python collections do---namely, for NaNs, containment effectively works by object identity. > I'm really using a pandas Series Okay, that makes sense. It's a bit unfortunate that NumPy creates a new NaN object every time you read a NaN value out of an array, so that you get e.g., >>> from numpy import array, nan, isnan >>> import numpy as np >>> my_list = [1.2, 2.3, np.nan, np.nan] >>> my_list[2] is my_list[3] True >>> my_array = np.array(my_list) >>> my_array[2] is my_array[3] False Or even: >>> my_array[2] is my_array[2] False I guess you're stuck with using Pandas functionality like `dropna` and `isnull` to deal with missing and non-missing values separately. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19161> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com