get_true_false_counts

def get_true_false_counts(responses)

Returns the number of true and false for each item.

Takes in a responses array and returns counts associated with true / false. True is a value in the dataset which equals '1' and false is a value which equals '0'. All other values are ignored

Args

responses
[n_items x n_participants] array of response values

Returns

n_false
(1d array) "false" counts per item
n_true
(1d array) "true" counts per item
Expand source code
def get_true_false_counts(responses):
    """ Returns the number of true and false for each item.

    Takes in a responses array and returns counts associated with
    true / false.  True is a value in the dataset which equals '1'
    and false is a value which equals '0'.  All other values are
    ignored

    Args:
        responses: [n_items x n_participants] array of response values

    Returns:
        n_false: (1d array) "false" counts per item
        n_true: (1d array) "true" counts per item
    """
    n_false = np.count_nonzero(responses == 0, axis=1)
    n_true = np.count_nonzero(responses == 1, axis=1)

    return n_false, n_true