Utility that detects and returns the columns that are forward returns
2077
def get_forward_returns_columns(columns):
    
    pattern = re.compile(r"^(\d+([Dhms]|ms|us|ns))+$", re.IGNORECASE)
    valid_columns = [(pattern.match(col) is not None) for col in columns]
    return columns[valid_columns]
1213445
def get_column(self, col):
        
        # catch corner case with an empty file (group with no datasets)
        if not len(self.group.keys()):
            return np.array([])
        vals = self.group[col]
        if self.filter_func:
            return vals[self.mask]
        else:
            return vals[:]
238016
def _find_in_columncollection(columns, name):
    
    for col in columns:
        if col.name == name or getattr(col, '_label', None) == name:
            return col
    return None
319525
def _default_return_columns(self):
        
        return_columns = []
        parsed_expr = []

        for key, value in self.components._namespace.items():
            if hasattr(self.components, value):
                sig = signature(getattr(self.components, value))
                # The `*args` reference handles the py2.7 decorator.
                if len(set(sig.parameters) - {'args'}) == 0:
                    expr = self.components._namespace[key]
                    if not expr in parsed_expr:
                        return_columns.append(key)
                        parsed_expr.append(expr)

        return return_columns
940305
def _iterateDocumentCharsBackward(self, block, startColumnIndex):
        
        # Chars in the start line
        endTime = time.time() + self._MAX_SEARCH_TIME_SEC
        for columnIndex, char in reversed(list(enumerate(block.text()[:startColumnIndex]))):
            yield block, columnIndex, char
        block = block.previous()

        # Next lines
        while block.isValid():
            for columnIndex, char in reversed(list(enumerate(block.text()))):
                yield block, columnIndex, char

            if time.time() > endTime:
                raise _TimeoutException('Time is over')

            block = block.previous()
410405
def _iterateDocumentCharsBackward(self, block, startColumnIndex):
        
        # Chars in the start line
        for columnIndex, char in reversed(list(enumerate(block.text()[:startColumnIndex]))):
            yield block, columnIndex, char
        block = block.previous()

        # Next lines
        while block.isValid():
            for columnIndex, char in reversed(list(enumerate(block.text()))):
                yield block, columnIndex, char

            block = block.previous()
548665
private <C> Iterator<Column<C>> columnScan(final ByteBuffer rowKey,
                                               final DeltaPlacement placement,
                                               final ColumnFamily<ByteBuffer, C> columnFamily,
                                               final C start,
                                               final C end,
                                               final boolean reversed,
                                               final ColumnInc<C> columnInc,
                                               final long limit,
                                               final long page,
                                               final ReadConsistency consistency) {
        return Iterators.concat(new AbstractIterator<Iterator<Column<C>>>() {
            private C _from = start;
            private long _remaining = limit;
            private long _page = page;

            @Override
            protected Iterator<Column<C>> computeNext() {
                if (_remaining <= 0) {
                    return endOfData();
                }

                // For page N+1, treat "_from" as exclusive.  Since Cassandra doesn't support exclusive column ranges
                // bump the from value up to the next possible time UUID (assumes from != null when page != 0).
                if (_page > 0) {
                    if (_from.equals(end)) {
                        return endOfData();
                    }
                    _from = reversed ? columnInc.previous(_from) : columnInc.next(_from);
                    if (_from == null) {
                        return endOfData();
                    }
                }

                // Execute the query
                int batchSize = (int) Math.min(_remaining, MAX_COLUMN_SCAN_BATCH);
                ColumnList<C> columns = execute(placement.getKeyspace()
                                .prepareQuery(columnFamily, SorConsistencies.toAstyanax(consistency))
                                .getKey(rowKey)
                                .withColumnRange(_from, end, reversed, batchSize),
                        "scan columns in placement %s, column family %s, row %s, from %s to %s",
                        placement.getName(), columnFamily.getName(), rowKey, start, end);

                // Update state for the next iteration.
                if (columns.size() >= batchSize) {
                    // Save the last column key so we can use it as the start (exclusive) if we must query to get more data.
                    _from = columns.getColumnByIndex(columns.size() - 1).getName();
                    _remaining = _remaining - columns.size();
                    _page++;
                } else {
                    // If we got fewer columns than we asked for, another query won't find more columns.
                    _remaining = 0;
                }

                // Track metrics.  For rows w/more than 50 columns, count subsequent reads w/_largeRowReadMeter.
                (_page == 0 ? _randomReadMeter : _largeRowReadMeter).mark();

                return columns.iterator();
            }
        });
    }
476458
def forwards(self, orm):
        ""
        orm['avocado.DataField'].objects.get_or_create(app_name='samples', model_name='batch', field_name='id',
                defaults=dict(published=True, name='Batch', name_plural='Batches'))
261061
def filter_cols(model, *filtered_columns):
    
    m = sa.orm.class_mapper(model)
    return list(
        {p.key for p in m.iterate_properties if hasattr(p, "columns")}.difference(
            filtered_columns
        )
    )
338197
function guessColumn(data, c) {
      var numeric = true;
      var vs = [];
      for(var i=0,n=data.length;i<n;i++) {
        var v = data[i][c];
        vs.push(v);
        if(isNaN(v)) numeric = false;
      }
      var u = vs.unique();
      if(!numeric) {
        // if we have a non-numeric we will map it through uniques to an index
        return {numeric:numeric, num:u.length, uniques:u};
      } else {
        return {numeric:numeric, num:u.length};
      }
    }
839270
def database_forwards(self, app_label, schema_editor, from_state, to_state):
        """"""
        from resolwe.flow.models.data import DataQuerySet
        # pylint: disable=protected-access

        Data = from_state.apps.get_model('flow', 'Data')  # pylint: disable=invalid-name
        DataQuerySet._delete_chunked(Data.objects.filter(process__slug=self.process))

        Process = from_state.apps.get_model('flow', 'Process')  # pylint: disable=invalid-name
        Process.objects.filter(slug=self.process).delete()
1121940
def getcol(self, startrow=0, nrow=-1, rowincr=1):
        """"""
        return self._table.getcol(self._column, startrow, nrow, rowincr)
658994
def values(self, column_major=False):
        
        if column_major:
            return list(map(list, zip(*self._values)))
        return [row[:] for row in self._values]
131761
def dumps(columns):
    '''
    
    '''
    fp = BytesIO()
    dump(columns, fp)
    fp.seek(0)
    return fp.read()
1127432
def select_if(df, fun):
    

    def _filter_f(col):
        try:
            return fun(df[col])
        except:
            return False

    cols = list(filter(_filter_f, df.columns))
    return df[cols]
919261
def _retrieve_indices(cols):
        '''
        
        '''
        if isinstance(cols, int):
            return [cols]
        elif isinstance(cols, slice):
            start = cols.start if cols.start else 0
            stop = cols.stop
            step = cols.step if cols.step else 1
            return list(range(start, stop, step))
        elif isinstance(cols, list) and cols:
            if isinstance(cols[0], bool):
                return np.flatnonzero(np.asarray(cols))
            elif isinstance(cols[0], int):
                return cols
        else:
            raise TypeError('No valid column specifier. Only a scalar, list or slice of all'
                            'integers or a boolean mask are allowed.')
117095
def column_stack_2d(data):
    """"""
    return list(list(itt.chain.from_iterable(_)) for _ in zip(*data))