def bootstrap_indexes ( data , n_samples = 10000 ) : for _ in xrange ( n_samples ) : yield randint ( data . shape [ 0 ] , size = ( data . shape [ 0 ] , ) )
bootstrap sampling with variable subsets in python
Given data points data where axis 0 is considered to delineate points return an generator for sets of bootstrap indexes . This can be used as a list of bootstrap indexes ( with list ( bootstrap_indexes ( data ))) as well .
def bootstrap_indexes(data, n_samples=10000):
    """
Given data points data, where axis 0 is considered to delineate points, return
an generator for sets of bootstrap indexes. This can be used as a list
of bootstrap indexes (with list(bootstrap_indexes(data))) as well.
    """
    for _ in xrange(n_samples):
        yield randint(data.shape[0], size=(data.shape[0],))