Bool and missing values in pandas
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 2
--
Chapters
00:00 Bool And Missing Values In Pandas
01:26 Accepted Answer Score 3
01:55 Answer 2 Score 0
02:05 Thank you
--
Full question
https://stackoverflow.com/questions/5769...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pandas #dataframe
#avk47
    Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 2
--
Chapters
00:00 Bool And Missing Values In Pandas
01:26 Accepted Answer Score 3
01:55 Answer 2 Score 0
02:05 Thank you
--
Full question
https://stackoverflow.com/questions/5769...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pandas #dataframe
#avk47
ACCEPTED ANSWER
Score 3
Q1: I would start with combining
np.any(pd.isna(boolean))
to identify if there are any None Values in a column, and with
set(boolean)
You can identify, if there are only True, False and Nones inside. Combining with filtering (and if you prefer to also typcasting) you should be done.
Q2: see comment of @WeNYoBen
ANSWER 2
Score 0
I've hit the same problem. I came up with the following solution:
from pandas import Series
def is_boolean_series(col: Series):
    val = col[~col.isna()].iloc[0]
    return type(val) == bool