Create an index from the columns of a dataframe
509355
def _make_index(df, cols=META_IDX):
    """"""
    return pd.MultiIndex.from_tuples(
        pd.unique(list(zip(*[df[col] for col in cols]))), names=tuple(cols))
551598
def _by_columns(self, columns):
        
        return columns if self.isstr(columns) else self._backtick_columns(columns)
1231592
def from_pandas(cls, index):
        
        from pandas import MultiIndex as PandasMultiIndex
        check_type(index, PandasMultiIndex)

        baloo_level_values = [Index.from_pandas(index.get_level_values(level))
                              for level in range(len(index.levels))]

        return MultiIndex(baloo_level_values, list(index.names))
496303
def _indices(self, indices):
    """"""
    if isinstance(indices, tuple):
      out = []
      dim = 0
      for i, index in enumerate(indices):
        if index is Ellipsis:
          out.append(index)
          dim = len(self.shape) - len(indices) + i
        else:
          out.append(self._get_index(dim, index))
        dim += 1
      return tuple(out)
    else:
      return self._get_index(0, indices)
820957
def _axis(self, axis):
        
        return self.df.columns if axis == 0 else self.df.index
538583
def index_column(self, index_name, table, column):
        """"""
        cursor = self.get_cursor()
        try:
            cursor.execute(
                'CREATE INDEX {0} on {1}({2})'.format(index_name, table, column))
        except sqlite3.OperationalError as error:
            print(error)
            print('Skipping index creation and assuming it exists already')
        else:
            self.conn.commit()
1129673
def from_df(cls, df:DataFrame, path:PathOrStr='.', cols:IntsOrStrs=0, processor:PreProcessors=None, **kwargs)->'ItemList':
        ""
        inputs = df.iloc[:,df_names_to_idx(cols, df)]
        assert inputs.isna().sum().sum() == 0, f"You have NaN values in column(s) {cols} of your dataframe, please fix it."
        res = cls(items=_maybe_squeeze(inputs.values), path=path, inner_df=df, processor=processor, **kwargs)
        return res
405588
def getInstNamesByIndex(self, *indices):
        """"""
        instNames = []
        for columnName in self._vars.keys():
            instNames.append(
                self.getInstNameByIndex(*(columnName[-1],) + indices)
            )

        return tuple(instNames)
712567
def columns(self):
        
        return Index(np.array(self._gather_column_names(), dtype=np.bytes_), np.dtype(np.bytes_))
999631
def create_index(group, chunk_size, compression=None, compression_opts=None):
    """"""
    dtype = np.int64
    if chunk_size == 'auto':
        chunks = True
    else:
        chunks = (nb_per_chunk(np.dtype(dtype).itemsize, 1, chunk_size),)

    group.create_dataset(
        'index', (0,), dtype=dtype,
        chunks=chunks, maxshape=(None,),
        compression=compression, compression_opts=compression_opts)
223468
def transform_dataframe(self, dataframe):
        
        dataframe.columns.name = ""

        for i in range(len(self.get_header_fields())):
            dataframe = dataframe.unstack()

        # Remove blank rows / columns
        dataframe = dataframe.dropna(
            axis=0, how='all'
        ).dropna(
            axis=1, how='all'
        )
        return dataframe
1185877
def pivot(self, index, **kwargs):
        
        try:
            df = self._pivot(index, **kwargs)
            return pd.pivot_table(self.df, index=kwargs["index"],  **kwargs)
            """if df is None:
                self.err("Can not pivot table")
                return
            self.df = df"""
        except Exception as e:
            self.err(e, "Can not pivot dataframe")
1034313
def column(index)
      index = parse_index(index)
      columns = []
      @data.each do |row|
        columns << row_to_array(row)[index].value
      end
      columns
    end
828861
def dataframe_from_list(values):
    """"""
    if(isinstance(values, six.string_types)):
        return DataFrame(filename=values)
    elif(isinstance(values, fits.HDUList)):
        return DataFrame(frame=values)
    else:
        return None
1098602
def transform_dataframe(self, dataframe):
        
        coord_fields = self.get_coord_fields()
        header_fields = self.get_header_fields()

        # Remove any pairs that don't have data for both x & y
        for i in range(len(coord_fields)):
            dataframe = dataframe.unstack()
        dataframe = dataframe.dropna(axis=1, how='all')
        dataframe = dataframe.dropna(axis=0, how='any')

        # Unstack series header
        for i in range(len(header_fields)):
            dataframe = dataframe.unstack()

        # Compute new column headers
        columns = []
        for i in range(len(header_fields) + 1):
            columns.append([])

        for col in dataframe.columns:
            value_name = col[0]
            coord_names = list(col[1:len(coord_fields) + 1])
            header_names = list(col[len(coord_fields) + 1:])
            coord_name = ''
            for name in coord_names:
                if name != self.index_none_value:
                    coord_name += name + '-'
            coord_name += value_name
            columns[0].append(coord_name)
            for i, header_name in enumerate(header_names):
                columns[1 + i].append(header_name)

        dataframe.columns = columns
        dataframe.columns.names = [''] + header_fields

        return dataframe
1113284
function columnIndexing(selector, colNames, dtypes) {
  if (isUndefined(selector) || selector === null) {
    return null;
  }

  // Handle boolean case if applicable
  var maxLen = colNames.size();
  var boolIdxResult = attemptBoolIndexing(selector, maxLen);
  if (!isUndefined(boolIdxResult)) {
    return boolIdxResult;
  }

  // Handle integer index / col name lookup hybrid
  var opts = resolverOpts(RESOLVE_MODE.COL, maxLen,
    colNames._getIndex(), dtypes);
  return resolveSelector(selector, opts);
}
1334285
def index(self, row, col, parent=QtCore.QModelIndex()):
         
        if row < self._stim.rowCount() and col < self._stim.columnCountForRow(row):
            component = self._stim.component(row, col)
            return self.createIndex(row, col, component)
        else:
            return QtCore.QModelIndex()