1truths = pd.Series([True, False, False, True, True])
2
3# With only booleans, use that True => 1 and False => 0
4percent_true = truths.mean() #==> 0.6
5percent_false = 1 - percent_true #==> 0.4
6
7# Generalising to all values, but slower with just booleans
8percent_series = truths.value_counts(normalize=True)
9 #==> pd.Series (
10 # True 0.6
11 # False 0.4
12 # dtype: float64
13 # )
14
15# First: https://stackoverflow.com/a/52438477/
16# Second: https://stackoverflow.com/a/52229939/