Get all categories for each categorical columns from training data.
509555
def _get_unique_categories(self, df):
        """"""

        categories = []
        for col in self._categorical_columns:
            categocial = pd.Categorical(df[col])
            col_categories = list(map(str, categocial.categories))
            col_categories.append('_UNKNOWN')
            categories.append(col_categories)
        return categories
527292
def train(self, category, text):
        
        try:
            bayes_category = self.categories.get_category(category)
        except KeyError:
            bayes_category = self.categories.add_category(category)

        tokens = self.tokenizer(str(text))
        occurrence_counts = self.count_token_occurrences(tokens)

        for word, count in occurrence_counts.items():
            bayes_category.train_token(word, count)

        # Updating our per-category overall probabilities
        self.calculate_category_probability()
914353
def unique_categories(categories):
    """"""
    categories = np.unique(categories)
    categories = np.setdiff1d(categories, np.array(settings.categories_to_ignore))
    categories = np.array(natsorted(categories, key=lambda v: v.upper()))
    return categories
65674
def get_column_definition_all(self, table):
        """"""
        # Get complete table definition
        col_defs = self.get_table_definition(table).split('\n')

        # Return only column definitions
        return [i[0:-1].strip().replace(',', ', ') for i in col_defs if i.strip().startswith('`')]
116305
def train_df(self, df, drop=False):
        
        if (len(df) == 0) or (len(self) == 0):
            return df

        # Each scale trains the columns it understands
        for sc in self:
            sc.train_df(df)
        return df
407166
public function all(array $categories = array())
	{
		$handlers = array();

		foreach ($this->handlers as $handler)
		{
			$handlerCategories = $this->handlers->getInfo();
			if (array() === $categories || array() !== array_intersect($handlerCategories, $categories))
			{
				$handlers[] = $handler;
			}
		}

		return $handlers;
	}
1367585
def get_data(self, df):
        """"""
        chart_data = []
        if len(self.groupby) > 0:
            groups = df.groupby(self.groupby)
        else:
            groups = [((), df)]
        for keys, data in groups:
            chart_data.extend([{
                'key': self.labelify(keys, column),
                'values': data[column].tolist()}
                for column in self.columns])
        return chart_data
79970
def _data_from_df(df):
        ''' 

        '''
        _df = df.copy()

        # Flatten columns
        if isinstance(df.columns, pd.MultiIndex):
            try:
                _df.columns = ['_'.join(col) for col in _df.columns.values]
            except TypeError:
                raise TypeError('Could not flatten MultiIndex columns. '
                                'use string column names or flatten manually')
        # Transform columns CategoricalIndex in list
        if isinstance(df.columns, pd.CategoricalIndex):
            _df.columns = df.columns.tolist()
        # Flatten index
        index_name = ColumnDataSource._df_index_name(df)
        if index_name == 'index':
            _df.index = pd.Index(_df.index.values)
        else:
            _df.index = pd.Index(_df.index.values, name=index_name)
        _df.reset_index(inplace=True)

        tmp_data = {c: v.values for c, v in _df.iteritems()}

        new_data = {}
        for k, v in tmp_data.items():
            new_data[k] = v

        return new_data
1002561
public List<CategoricalColumn<?>> categoricalColumns(String... columnNames) {
        List<CategoricalColumn<?>> columns = new ArrayList<>();
        for (String columnName : columnNames) {
            columns.add(categoricalColumn(columnName));
        }
        return columns;
    }
79179
def prune_unspecified_categories(modules, categories):
    
    res = {}
    for mod_name, mod_info in modules.items():
        mod_categories = mod_info.get("categories", all_categories)
        for category in categories:
            if category in mod_categories:
                break
        else:
            continue
        for input_name, input_info in mod_info["inputs"].items():
            for c in input_info["categories"]:
                if c in categories:
                    break
            else:
                del mod_info["inputs"][input_name]
        for output_name, output_info in mod_info["outputs"].items():
            for c in output_info["categories"]:
                if c in categories:
                    break
            else:
                del mod_info["outputs"][output_name]
        res[mod_name] = mod_info
    return res
899999
def get_category_metrics(self, category):
        """"""
        slug_list = self._category_slugs(category)
        return self.get_metrics(slug_list)
1018324
def get_category(self, id, **data):
        
        
        return self.get("/categories/{0}/".format(id), data=data)
996239
def setup_columns(self):
        """"""
        tv = self.view['tv_categories']

        # sets the model
        tv.set_model(self.model)
        
        # creates the columns
        cell = gtk.CellRendererText()
        tvcol = gtk.TreeViewColumn('Name', cell)

        def cell_data_func(col, cell, mod, it):
            if mod[it][0]: cell.set_property('text', mod[it][0].name)
            return
        tvcol.set_cell_data_func(cell, cell_data_func)
        
        tv.append_column(tvcol)                
        return
254257
protected function get_categories() {
        global $DB;
        $fields = 'c.*, ' . context_helper::get_preload_record_columns_sql('ctx');
        $coursecats = $DB->get_records_sql('SELECT ' . $fields . ' FROM {course_categories} c
                LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)
                WHERE c.parent = :parent ORDER BY c.sortorder',
            array('parent' => $this->category->id, 'contextlevel' => CONTEXT_COURSECAT));

        $hiddencats = [];

        foreach ($coursecats as $id => &$category) {
            context_helper::preload_from_record($category);
            if (!core_course_category::can_view_category($category)) {
                $hiddencats[$id] = $coursecats[$id];
                unset($coursecats[$id]);
            }
        }
        return [$coursecats, $hiddencats];
    }
1318483
def categories(self):
        
        r = [ch for ch in self._channels.values() if isinstance(ch, CategoryChannel)]
        r.sort(key=lambda c: (c.position, c.id))
        return r
832377
def reverse_transform(self, col):
        

        output = pd.DataFrame()
        output[self.col_name] = self.get_category(col[self.col_name])

        return output
98622
def __parseColumns(self):
        """"""
        columns = []
        if self.__dataItem.has_key('columnModel'):
            for column in self.__dataItem['columnModel']:
                columns.append(Column(column))
        return columns