Creates mapping df based on ann_label_table and self.custom_labels.

        Table composed of entire WFDB standard annotation table, overwritten/appended
        with custom_labels if any. Sets __label_map__ attribute, or returns value.
11743
def create_label_map(self, inplace=True):
        

        label_map =  ann_label_table.copy()

        if self.custom_labels is not None:
            self.standardize_custom_labels()
            for i in self.custom_labels.index:
                label_map.loc[i] = self.custom_labels.loc[i]

        if inplace:
            self.__label_map__ = label_map
        else:
            return label_map
993261
def add_col(self, label):
        
        self.table.dataframe[label] = ''
        self.AppendCols(1, updateLabels=False)
        last_col = self.table.GetNumberCols() - 1
        self.SetColLabelValue(last_col, label)
        self.col_labels.append(label)
        self.size_grid()
        return last_col
1133115
def _make_tabular_predict_fn(self, labels, instance, categories):
        

        def _predict_fn(np_instance):

            df = pd.DataFrame(
                np_instance,
                columns=(self._categorical_columns + self._numeric_columns))

            # Convert categorical indices back to categories.
            for col_name, col_categories in zip(self._categorical_columns, categories):
                df[col_name] = df[col_name].apply(lambda x: col_categories[int(x)])

            # Add columns that do not exist in the perturbed data,
            # such as key, text, and image data.
            for col_name in self._headers:
                if col_name not in (self._categorical_columns + self._numeric_columns):
                    df[col_name] = instance[col_name]

            r = _local_predict.get_prediction_results(
                self._model_dir, df, self._headers, with_source=False)
            probs = _local_predict.get_probs_for_labels(labels, r)
            probs = np.asarray(probs)
            return probs

        return _predict_fn
291115
def table(self, datatype=None, **kwargs):
        
        if config.future_deprecations:
            self.param.warning("The table method is deprecated and should no "
                               "longer be used. If using a HoloMap use "
                               "HoloMap.collapse() instead to return a Dataset.")

        from .data.interface import Interface
        from ..element.tabular import Table
        new_data = [(key, value.table(datatype=datatype, **kwargs))
                    for key, value in self.data.items()]
        tables = self.clone(new_data)
        return Interface.concatenate(tables, new_type=Table)
1019813
def label_triplets_to_df(triplets):
    

    label_df = pd.DataFrame({'label_store':np.array([t[0] for t in triplets],
                                                    dtype='int'),
                             'symbol':[t[1] for t in triplets],
                             'description':[t[2] for t in triplets]})

    label_df.set_index(label_df['label_store'].values, inplace=True)
    label_df = label_df[list(ann_label_fields)]

    return label_df
555315
@Override
    public KeyComponent createClusteringColumnReferenceComponent(Facet referenceFacet, PojoBinding<?> pojoBinding, NamingStrategy namingStrategy) {
        Facet facet = new SubFacet(referenceFacet, getFacet(), false);
        String tableName = namingStrategy.getReferenceTableName(referenceFacet);
        String columnName = namingStrategy.getColumnName(facet);
        return new SimpleClusteringColumnReferenceComponent(referenceFacet, facet, columnName, getConverter(), pojoBinding, tableName);
    }
141398
public static function buildTableMap()
    {
      $dbMap = Propel::getServiceContainer()->getDatabaseMap(AttributeAttributeTypeTableMap::DATABASE_NAME);
      if (!$dbMap->hasTable(AttributeAttributeTypeTableMap::TABLE_NAME)) {
        $dbMap->addTableObject(new AttributeAttributeTypeTableMap());
      }
    }
1310136
def df(objs, labels=None):
    
    import pandas as pd
    from .objects import Object, DynamicObject
    if objs:
        objs = list(objs)
        obj = objs[0]
        if isinstance(obj, Object):
            df = pd.DataFrame.from_records(o.tuple() for o in objs)
            df.columns = obj.__class__.defaults
        elif isinstance(obj, DynamicObject):
            df = pd.DataFrame.from_records(o.__dict__ for o in objs)
        else:
            df = pd.DataFrame.from_records(objs)
        if isinstance(obj, tuple) and hasattr(obj, '_fields'):
            # assume it's a namedtuple
            df.columns = obj.__class__._fields
    else:
        df = None
    if labels:
        exclude = [label for label in df if label not in labels]
        df = df.drop(exclude, axis=1)
    return df
124288
def _create_table(self):
        
        self.StrTable = ""
        self.AttributesLength = []
        self.Lines_num = 0
        # Prepare some values..
        for col in self.Table:
            # Updates the table line count if necessary
            values = list(col.values())[0]
            self.Lines_num = max(self.Lines_num, len(values))
            # find the length of longest value in current column
            key_length = max([self._disp_width(v) for v in values] or [0])
            # and also the table header
            key_length = max(key_length, self._disp_width(list(col.keys())[0]))
            self.AttributesLength.append(key_length)
        # Do the real thing.
        self._print_head()
        self._print_value()
1223000
def from_labels(cls, labels, inputCol, outputCol=None, handleInvalid=None):
        
        sc = SparkContext._active_spark_context
        java_class = sc._gateway.jvm.java.lang.String
        jlabels = StringIndexerModel._new_java_array(labels, java_class)
        model = StringIndexerModel._create_from_java_class(
            "org.apache.spark.ml.feature.StringIndexerModel", jlabels)
        model.setInputCol(inputCol)
        if outputCol is not None:
            model.setOutputCol(outputCol)
        if handleInvalid is not None:
            model.setHandleInvalid(handleInvalid)
        return model
242272
public static Map<String, String> getOrCreateLabels(HasMetadata entity) {
    ObjectMeta metadata = getOrCreateMetadata(entity);
    Map<String, String> answer = metadata.getLabels();
    if (answer == null) {
      // use linked so the annotations can be in the FIFO order
      answer = new LinkedHashMap<>();
      metadata.setLabels(answer);
    }
    return answer;
  }
335437
def store(self, df, attribute_columns):
        

        # ID start values depend on currently stored entities/attributes!
        entity_id_start = models.Entity.get_max_id(self.session) + 1
        attribute_id_start = models.Attribute.get_max_id(self.session) + 1

        # append ID and type columns
        df['id'] = range(entity_id_start, entity_id_start + len(df))
        df['type'] = self.type

        # store entities
        df[['id', 'type']].to_sql(name=models.Entity.__tablename__,
                                  con=self.client.engine,
                                  if_exists='append',
                                  index=False)

        # store attributes
        for col in attribute_columns:
            # ID column of df is the entity ID of the attribute
            attr_df = df[[col, 'id']].rename(columns={'id': 'entity_id',
                                                      col: 'value'})
            attr_df['name'] = col

            # add entity ID column, need to respect already existing entities
            attr_df['id'] = range(attribute_id_start, attribute_id_start + len(df))
            attribute_id_start += len(df)

            # store
            attr_df.to_sql(name=models.Attribute.__tablename__,
                           con=self.client.engine,
                           if_exists='append',
                           index=False)
518928
def fillna(self, **kwargs):
        
        axis = kwargs.get("axis", 0)
        value = kwargs.get("value")
        if isinstance(value, dict):
            value = kwargs.pop("value")

            if axis == 0:
                index = self.columns
            else:
                index = self.index
            value = {
                idx: value[key] for key in value for idx in index.get_indexer_for([key])
            }

            def fillna_dict_builder(df, func_dict={}):
                # We do this to ensure that no matter the state of the columns we get
                # the correct ones.
                func_dict = {df.columns[idx]: func_dict[idx] for idx in func_dict}
                return df.fillna(value=func_dict, **kwargs)

            new_data = self.data.apply_func_to_select_indices(
                axis, fillna_dict_builder, value, keep_remaining=True
            )
            return self.__constructor__(new_data, self.index, self.columns)
        else:
            func = self._prepare_method(pandas.DataFrame.fillna, **kwargs)
            new_data = self._map_across_full_axis(axis, func)
            return self.__constructor__(new_data, self.index, self.columns)
654932
def create_label(self, label, doc=None, callback=dummy_progress_cb):
        
        if doc:
            clone = doc.clone()  # make sure it's serializable
        r = self.index.create_label(label, doc=clone)
        return r
75551
def create_tablefn_map(fns, pqdb, poolnames):
    """"""
    poolmap = {name: pid for (name, pid) in pqdb.get_all_poolnames()}
    pqdb.store_table_files([(poolmap[pool], os.path.basename(fn))
                            for fn, pool in zip(fns, poolnames)])
    return pqdb.get_tablefn_map()
496229
def _transform(self, df):
        
        output_col = self.getOutputCol()
        label_col = self.getLabelCol()
        new_schema = copy.deepcopy(df.schema)
        new_schema.add(StructField(output_col, StringType(), True))

        rdd = df.rdd.coalesce(1)
        features = np.asarray(
            rdd.map(lambda x: from_vector(x.features)).collect())
        # Note that we collect, since executing this on the rdd would require model serialization once again
        model = model_from_yaml(self.get_keras_model_config())
        model.set_weights(self.weights.value)
        predictions = rdd.ctx.parallelize(
            model.predict_classes(features)).coalesce(1)
        predictions = predictions.map(lambda x: tuple(str(x)))

        results_rdd = rdd.zip(predictions).map(lambda x: x[0] + x[1])
        results_df = df.sql_ctx.createDataFrame(results_rdd, new_schema)
        results_df = results_df.withColumn(
            output_col, results_df[output_col].cast(DoubleType()))
        results_df = results_df.withColumn(
            label_col, results_df[label_col].cast(DoubleType()))

        return results_df
704900
def get_column_labels(obj):
    
    if not isinstance(obj, (list, tuple, pd.np.ndarray)):
        try:
            labels = [f.name for f in obj.model._meta.fields]
        except:
            try:
                labels = obj.keys()
            except:
                try:
                    labels = dir(obj)
                except:
                    labels = None
    elif all(isinstance(heading, basestring) for heading in obj[0]):
        labels = list(obj[0])
        # if obj isn't a reference to a mutable (dict, DataFrame, list, etc), this won't work
        del obj[0]
    return labels