I have a list of tuples where each tuple has following structure:
(domain, field_1, field_2, field_3,..., field_n)
each field_x
has some value (string or integer) of is None. The domain
field has a limited amount of unique values. I would like to end up with a dataframe where each column represents unique value of the domain
and each column represents percentage of None
values in field_x
per domain.
Example:
[(domain1, None, str, str, None),
(domain2, int , str, None, str),
(domain1, int , None, str, str)]
becomes:
domain1 domain2
field_1 0.5 0
field_2 0.5 0
field_3 0 1
field_4 0.5 0
Thanks for any help!
question from:
https://stackoverflow.com/questions/65841853/df-from-list-of-tuples-encoded-by-first-value-of-tuple 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…