Import summary, ensemble, or distribution data.

    :param list tables: Metadata
    :return dict _tables: Metadata
333667
def _idx_table_by_name(tables, crumbs):
    
    _tables = OrderedDict()
    try:
        for _idx, _table in enumerate(tables):
            # Use "name" as tableName
            _name = "{}{}".format(crumbs, _idx)
            # Call idx_table_by_name
            _tmp = _idx_col_by_name(_table)
            if _name in _tables:
                _name = "{}_{}".format(_name, _idx)
            _tmp["tableName"] = _name
            _tables[_name] = _tmp
    except Exception as e:
        logger_jsons.error("idx_table_by_name: {}".format(e))
        print("Error: idx_table_by_name: {}".format(e))

    return _tables
874328
def feature_importances_table(self):
        
        from . import table

        return table.feature_importances(self.estimator,
                                         feature_names=self.feature_names)
1077764
def dict_to_table(dictionary, list_of_keys=None):
    

    # assert len(dictionary.values()) > 0, "Dictionary cannot be empty"

    # Create an empty table

    table = Table()

    # If the dictionary is not empty, fill the table

    if len(dictionary) > 0:

        # Add the names as first column

        table['name'] = dictionary.keys()

        # Now add all other properties

        # Use the first parameter as prototype

        prototype = dictionary.values()[0]

        column_names = prototype.keys()

        # If we have a white list for the columns, use it

        if list_of_keys is not None:

            column_names = filter(lambda key: key in list_of_keys, column_names)

        # Fill the table

        for column_name in column_names:

            table[column_name] = map(lambda x: x[column_name], dictionary.values())

    return table
1320578
def get_table(ports):
    
    table = PrettyTable(["Name", "Port", "Protocol", "Description"])
    table.align["Name"] = "l"
    table.align["Description"] = "l"
    table.padding_width = 1

    for port in ports:
        table.add_row(port)

    return table
261815
def table(self, datatype=None):
        ""
        if config.future_deprecations:
            self.param.warning(
                "The table method is deprecated and should no "
                "longer be used. Instead cast the %s to a "
                "a Table directly." % type(self).__name__)

        if datatype and not isinstance(datatype, list):
            datatype = [datatype]
        from ..element import Table
        return Table(self, **(dict(datatype=datatype) if datatype else {}))
1217782
def import_from_dicts(data, samples=None, *args, **kwargs):
    

    data = iter(data)

    cached_rows, headers = [], []
    for index, row in enumerate(data, start=1):
        cached_rows.append(row)

        for key in row.keys():
            if key not in headers:
                headers.append(key)

        if samples and index == samples:
            break

    data_rows = (
        [row.get(header, None) for header in headers]
        for row in chain(cached_rows, data)
    )

    kwargs["samples"] = samples
    meta = {"imported_from": "dicts"}
    return create_table(chain([headers], data_rows), meta=meta, *args, **kwargs)
712818
def _to_dataframe_tabledata_list(self, dtypes, progress_bar=None):
        """"""
        column_names = [field.name for field in self.schema]
        frames = []

        for page in iter(self.pages):
            current_frame = self._to_dataframe_dtypes(page, column_names, dtypes)
            frames.append(current_frame)

            if progress_bar is not None:
                # In some cases, the number of total rows is not populated
                # until the first page of rows is fetched. Update the
                # progress bar's total to keep an accurate count.
                progress_bar.total = progress_bar.total or self.total_rows
                progress_bar.update(len(current_frame))

        if progress_bar is not None:
            # Indicate that the download has finished.
            progress_bar.close()

        return pandas.concat(frames)
342790
def summary_table(pairs, key_header, descr_header="Description", width=78):
  
  from .lazy_text import rst_table, small_doc
  max_width = width - max(len(k) for k, v in pairs)
  table = [(k, small_doc(v, max_width=max_width)) for k, v in pairs]
  return rst_table(table, (key_header, descr_header))
1269738
def load_data_table(table_name, meta_file, meta):
    
    for table in meta['tables']:
        if table['name'] == table_name:
            prefix = os.path.dirname(meta_file)
            relative_path = os.path.join(prefix, meta['path'], table['path'])
            return pd.read_csv(relative_path), table
1044293
def list_tables(refresh=False, cache_file=None):
    
    # default cache listing all objects available is
    # ~/.bcdata
    if not cache_file:
        cache_file = os.path.join(str(Path.home()), ".bcdata")

    # regenerate the cache if:
    # - the cache file doesn't exist
    # - we force a refresh
    # - the cache is older than 1 month
    if refresh or check_cache(cache_file):
        wfs = WebFeatureService(url=bcdata.OWS_URL, version="2.0.0")
        bcdata_objects = [i.strip("pub:") for i in list(wfs.contents)]
        with open(cache_file, "w") as outfile:
            json.dump(sorted(bcdata_objects), outfile)
    else:
        with open(cache_file, "r") as infile:
            bcdata_objects = json.load(infile)

    return bcdata_objects
345005
def _pack_data(X, Y, metadata):
    
    if not any(metadata):
        # legacy list of list format is acceptable
        return list(zip(X, Y))

    else:
        # newer dictionary-based format is required in order to save metadata
            return [
                {
                    'data': x,
                    'target': y,
                    'metadata': meta
                }
                for x, y, meta in zip(X, Y, metadata)
            ]
1009495
def import_tables(self, only_tables=None, exclude_tables=None):
        
        for table in self.tables:
            if only_tables is not None and table.name not in only_tables:
                continue

            if exclude_tables is not None and table.name in exclude_tables:
                continue
            self.import_table(table)
169028
def listTables(self, dbName=None):
        
        if dbName is None:
            dbName = self.currentDatabase()
        iter = self._jcatalog.listTables(dbName).toLocalIterator()
        tables = []
        while iter.hasNext():
            jtable = iter.next()
            tables.append(Table(
                name=jtable.name(),
                database=jtable.database(),
                description=jtable.description(),
                tableType=jtable.tableType(),
                isTemporary=jtable.isTemporary()))
        return tables
46340
def _use_tables(objs):
    ''' 

    '''
    from ..models.widgets import TableWidget
    return _any(objs, lambda obj: isinstance(obj, TableWidget))
792756
def metadata(self, key=None, database=None, table=None, fallback=True):
        
        assert not (database is None and table is not None), \
            "Cannot call metadata() with table= specified but not database="
        databases = self._metadata.get("databases") or {}
        search_list = []
        if database is not None:
            search_list.append(databases.get(database) or {})
        if table is not None:
            table_metadata = (
                (databases.get(database) or {}).get("tables") or {}
            ).get(table) or {}
            search_list.insert(0, table_metadata)
        search_list.append(self._metadata)
        if not fallback:
            # No fallback allowed, so just use the first one in the list
            search_list = search_list[:1]
        if key is not None:
            for item in search_list:
                if key in item:
                    return item[key]
            return None
        else:
            # Return the merged list
            m = {}
            for item in search_list:
                m.update(item)
            return m
307450
def tables(self):
        """"""
        tables = []
        self.cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
        for table_info in self.cursor.fetchall():
            if table_info[0] != 'sqlite_sequence':
                tables.append(table_info[0])
        return tables
573907
def import_metadata(module_paths):
    """"""
    cwd = os.getcwd()
    if cwd not in sys.path:
        sys.path.insert(0, cwd)
    modules = []
    try:
        for path in module_paths:
            modules.append(import_module(path))
    except ImportError as e:
        err = RuntimeError('Could not import {}: {}'.format(path, str(e)))
        raise_from(err, e)
    return modules