As mentioned in the subject,
{Series,DataFrame,..}.astype(bool) converts
NaN values to
True. I realize that
bool(NaN) is
True, so there's obvious consistency there. However my intuition, especially when using a container of bools as a mask, would be that
NaN values would convert to
False. Perhaps this is one of those cases where the Pandas treatment of
NaN should differ from numpy's?
Here are some related discussions, though none seem to address explicitly what the desired treatment of
NaNs (or
Nones) by
.astype(bool):
https://groups.google.com/d/msg/pydata/pOz9LCx3JF0/selM28IIbCsJhttps://github.com/pydata/pandas/issues/6528https://github.com/pydata/pandas/pull/8151Apologies if there have been other discussions on the topic that I've missed.