def hist_from_values_list(values_list, fillers=(None,), normalize=False,<EOL>cumulative=False, to_str=False, sep='<STR_LIT:U+002C>', min_bin=None, max_bin=None):
value_types = tuple([int, float] + [type(filler) for filler in fillers])<EOL>if all(isinstance(value, value_types) for value in values_list):<EOL><INDENT>counters = [Counter(int(value) for value in values_list if isinstance(value, (int, float)))]<EOL><DEDENT>elif all(len(row) == <NUM_LIT:1> for row in values_list) and all(isinstance(row[<NUM_LIT:0>], value_types) for row in values_list):<EOL><INDENT>return hist_from_values_list([values[<NUM_LIT:0>] for values in values_list], fillers=fillers,<EOL>normalize=normalize, cumulative=cumulative,<EOL>to_str=to_str, sep=sep, min_bin=min_bin, max_bin=max_bin)<EOL><DEDENT>else:  <EOL><INDENT>return [<EOL>hist_from_values_list(col, fillers=fillers, normalize=normalize, cumulative=cumulative, to_str=to_str, sep=sep,<EOL>min_bin=min_bin, max_bin=max_bin)<EOL>for col in transposed_matrix(values_list)<EOL>]<EOL><DEDENT>if not values_list:<EOL><INDENT>return []<EOL><DEDENT>intkeys_list = [[c for c in counts if (isinstance(c, int) or (isinstance(c, float) and int(c) == c))]<EOL>for counts in counters]<EOL>try:<EOL><INDENT>min_bin = int(min_bin)<EOL><DEDENT>except (IndexError, ValueError, AttributeError, TypeError):<EOL><INDENT>min_bin = min(min(intkeys) for intkeys in intkeys_list)<EOL><DEDENT>try:<EOL><INDENT>max_bin = int(max_bin)<EOL><DEDENT>except (IndexError, ValueError, AttributeError, TypeError):<EOL><INDENT>max_bin = max(max(intkeys) for intkeys in intkeys_list)<EOL><DEDENT>min_bin = max(min_bin, min((min(intkeys) if intkeys else <NUM_LIT:0>) for intkeys in intkeys_list))<EOL>max_bin = min(max_bin, max((max(intkeys) if intkeys else <NUM_LIT:0>) for intkeys in intkeys_list))<EOL>histograms = []<EOL>for intkeys, counts in zip(intkeys_list, counters):<EOL><INDENT>histograms += [OrderedDict()]<EOL>if not intkeys:<EOL><INDENT>continue<EOL><DEDENT>if normalize:<EOL><INDENT>N = sum(counts[c] for c in intkeys)<EOL>for c in intkeys:<EOL><INDENT>counts[c] = float(counts[c]) / N<EOL><DEDENT><DEDENT>if cumulative:<EOL><INDENT>for i in range(min_bin, max_bin + <NUM_LIT:1>):<EOL><INDENT>histograms[-<NUM_LIT:1>][i] = counts.get(i, <NUM_LIT:0>) + histograms[-<NUM_LIT:1>].get(i - <NUM_LIT:1>, <NUM_LIT:0>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for i in range(min_bin, max_bin + <NUM_LIT:1>):<EOL><INDENT>histograms[-<NUM_LIT:1>][i] = counts.get(i, <NUM_LIT:0>)<EOL><DEDENT><DEDENT><DEDENT>if not histograms:<EOL><INDENT>histograms = [OrderedDict()]<EOL><DEDENT>aligned_histograms = []<EOL>for i in range(min_bin, max_bin + <NUM_LIT:1>):<EOL><INDENT>aligned_histograms += [tuple([i] + [hist.get(i, <NUM_LIT:0>) for hist in histograms])]<EOL><DEDENT>if to_str:<EOL><INDENT>return str_from_table(aligned_histograms, sep=sep, max_rows=<NUM_LIT> * <NUM_LIT:2> + <NUM_LIT:1>)<EOL><DEDENT>return aligned_histograms<EOL>
Compute an emprical histogram, PMF or CDF in a list of lists or a csv string

    Only works for discrete (integer) values (doesn't bin real values).
    `fillers`: list or tuple of values to ignore in computing the histogram

    >>> hist_from_values_list([1,1,2,1,1,1,2,3,2,4,4,5,7,7,9])  # doctest: +NORMALIZE_WHITESPACE
    [(1, 5), (2, 3), (3, 1), (4, 2), (5, 1), (6, 0), (7, 2), (8, 0), (9, 1)]
    >>> hist_from_values_list([(1,9),(1,8),(2,),(1,),(1,4),(2,5),(3,3),(5,0),(2,2)])  # doctest: +NORMALIZE_WHITESPACE
    [[(1, 4), (2, 3), (3, 1), (4, 0), (5, 1)], [(0, 1), (1, 0), ... (6, 0), (7, 0), (8, 1), (9, 1)]]
    >>> hist_from_values_list(transposed_matrix([(8,),(1,3,5),(2,),(3,4,5,8)]))  # doctest: +NORMALIZE_WHITESPACE
    [[(8, 1)], [(1, 1), (2, 0), (3, 1), (4, 0), (5, 1)], [(2, 1)], [(3, 1), (4, 1), (5, 1), (6, 0), (7, 0), (8, 1)]]