def _idx_col2rowm ( d ) : if 0 == len ( d ) : return 1 if 1 == len ( d ) : return np . arange ( d [ 0 ] ) # order='F' indicates column-major ordering idx = np . array ( np . arange ( np . prod ( d ) ) ) . reshape ( d , order = 'F' ) . T return idx . flatten ( order = 'F' )
change order of columns with index python
Generate indexes to change from col - major to row - major ordering
def _idx_col2rowm(d):
    """Generate indexes to change from col-major to row-major ordering"""
    if 0 == len(d):
        return 1
    if 1 == len(d):
        return np.arange(d[0])
    # order='F' indicates column-major ordering
    idx = np.array(np.arange(np.prod(d))).reshape(d, order='F').T
    return idx.flatten(order='F')