def select_indices(ctx, only_strings=False):
    """Returns the column indices that should be categorically encoded."""

    def should_be_encoded(col):
        if col.role != 'categorical':
            return False
        elif only_strings:
            return any(isinstance(i, str) for i in col.values)
        else:
            return True

    return ctx.matrix.column_indices_where(should_be_encoded)