Skip to content

Instantly share code, notes, and snippets.

@twidi
Created October 20, 2015 13:50
Show Gist options
  • Save twidi/fe0541273481899dbdfa to your computer and use it in GitHub Desktop.
Save twidi/fe0541273481899dbdfa to your computer and use it in GitHub Desktop.
percentage of true values
In [1]: from itertools import chain
In [2]: from collections import Counter
In [3]: x = [[True, False, True], [True]]
In [4]: y = list(chain.from_iterable(x))
In [5]: c = Counter(y)
In [6]: c[True] / len(y) * 100
Out[6]: 75.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment