Convert a multi-dim to a pandas dataframe.
554545
def to_dataframe(self, columns=None):
    """"""
    if not isinstance(self.measured_value, DimensionedMeasuredValue):
      raise TypeError(
        'Only a dimensioned measurement can be converted to a DataFrame')

    if columns is None:
      columns = [d.name for d in self.dimensions]
      columns += [self.units.name if self.units else 'value']

    dataframe = self.measured_value.to_dataframe(columns)

    return dataframe
1353248
def clean_dataframe(df):
    """"""
    df = df.fillna(method='ffill')
    df = df.fillna(0.0)
    return df
830438
def to_df(self):
    '''
    '''
    total, first, (idx, second) = Si_to_pandas_dict(self)
    names = self.problem['names']
    ret = [pd.DataFrame(total, index=names),
           pd.DataFrame(first, index=names)]

    if second:
        ret += [pd.DataFrame(second, index=idx)]

    return ret
30649
def to_df(figure):
    
    dfs=[]
    for trace in figure['data']:
        if 'scatter' in trace['type']:
            try:
                if type(trace['x'][0])==float:
                    index=trace['x']
                else:
                    index=pd.to_datetime(trace['x'])
            except:
                index=trace['x']
            if 'marker' in trace:
                d={}
                if 'size' in trace['marker']:
                    size=trace['marker']['size']
                    if type(size)!=list:
                        size=[size]*len(index)
                    d['size']=size
                if 'text' in trace:
                    d['text']=trace['text']
                if 'name' in trace:
                    name=trace['name']
                    if type(name)!=list:
                        name=[name]*len(index)
                    d['categories']=name
                d['y']=trace['y']
                d['x']=trace['x']
                if 'z' in trace:
                    d['z']=trace['z']
                df=pd.DataFrame(d)
            else:
                df=pd.Series(trace['y'],index=index,name=trace['name'])
            dfs.append(df)
        elif trace['type'] in ('heatmap','surface'):
            df=pd.DataFrame(trace['z'].transpose(),index=trace['x'],columns=trace['y'])
            dfs.append(df)
        elif trace['type'] in ('box','histogram'):
            vals=trace['x'] if 'x' in trace else trace['y']
            df=pd.DataFrame({trace['name']:vals})
            dfs.append(df)
    if max(list(map(len,dfs)))==min(list(map(len,dfs))):
        if len(dfs)==1:
            return dfs[0]
        else:
            if type(dfs[0])==pd.core.series.Series:
                return pd.concat(dfs,axis=1)                
            if all(dfs[0].columns==dfs[1].columns):
                    return pd.concat(dfs,axis=0)
            else:
                return pd.concat(dfs,axis=1)
    else:
        try:
            return pd.concat(dfs)
        except:
            return dfs
873606
def opt_weights(self):
        """"""
        return pd.DataFrame(self._xs, index=self.newidx, columns=self.cols)
228426
def pandas(self):
        """"""
        if self._pandas is None:
            self._pandas = pd.DataFrame().from_records(self.list_of_dicts)
        return self._pandas
1298374
def var(self, ddof=1):
        
        self._prep_pandas_groupby()
        return DataFrame.fromDataFrameRDD(
            self._regroup_mergedRDD().values().map(
                lambda x: x.var(ddof=ddof)), self.sql_ctx)
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))
577683
def as_dataframe(self, fillna=True, subjects=None):
        
        entries = []
        selected_subjects = self.subjects
        if subjects is not None:
            selected_subjects = subjects
            
        for s in selected_subjects:
            vmap = {}
            for c in self.inferred_types(s):
                vmap[c] = 1
            entries.append(vmap)
        logging.debug("Creating DataFrame")
        df = pd.DataFrame(entries, index=selected_subjects)
        if fillna:
            logging.debug("Performing fillna...")
            df = df.fillna(0)
        return df
699210
def to_pandas(self, wrap=False, **kwargs):
        

        try:
            import pandas as pd
        except ImportError:
            raise DependencyNotInstalledError(
                    'to_pandas requires for `pandas` library')

        def wrapper(result):
            df = result.values
            if wrap:
                from .. import DataFrame
                df = DataFrame(df)
            return df[self.name]

        return self.execute(wrapper=wrapper, **kwargs)
1336660
def as_df(self, ignore_vals=["history"], separator=".", verbose=True):
        

        def add_eval(res):
            if "eval" not in res:
                if isinstance(res["history"], list):
                    # take the average across all folds
                    eval_names = list(res["history"][0]["loss"].keys())
                    eval_metrics = np.array([[v[-1] for k, v in hist["loss"].items()]
                                             for hist in res["history"]]).mean(axis=0).tolist()
                    res["eval"] = {eval_names[i]: eval_metrics[i] for i in range(len(eval_metrics))}
                else:
                    res["eval"] = {k: v[-1] for k, v in res["history"]["loss"].items()}
            return res

        def add_n_epoch(df):
            df_epoch = self.train_history().groupby("tid")["epoch"].max().reset_index()
            df_epoch.rename(columns={"epoch": "n_epoch"}, inplace=True)
            return pd.merge(df, df_epoch, on="tid", how="left")

        results = self.get_ok_results(verbose=verbose)
        rp = [_flatten_dict(_delete_keys(add_eval(x), ignore_vals), separator) for x in results]
        df = pd.DataFrame.from_records(rp)

        df = add_n_epoch(df)

        first = ["tid", "loss", "status"]
        return _put_first(df, first)
382810
def _construct_df(self, mol2_lines, col_names, col_types):
        """"""
        return self._atomsection_to_pandas(self._get_atomsection(mol2_lines),
                                           col_names=col_names,
                                           col_types=col_types)
1306462
def as_dataframe(self):
        
        time_series = {}
        for ts_index, ts in enumerate(self.timeSeries):
            index = []
            data = []
            for value in ts.values:
                index.append(value.simTime)
                data.append(value.value)
            time_series[ts_index] = pd.Series(data, index=index)
        return pd.DataFrame(time_series)
227328
def from_pandas(cls, series):
        
        from pandas import Index as PandasIndex, MultiIndex as PandasMultiIndex

        if isinstance(series.index, PandasIndex):
            baloo_index = Index.from_pandas(series.index)
        elif isinstance(series.index, PandasMultiIndex):
            baloo_index = MultiIndex.from_pandas(series.index)
        else:
            raise TypeError('Cannot convert pandas index of type={} to baloo'.format(type(series.index)))

        return _series_from_pandas(series, baloo_index)
207949
def to_pandas(raster, name='value'):
    
    df = pd.DataFrame(raster.raster)
    df = df.stack()
    df = df.reset_index()
    df.columns = ['row', 'col', name]
    df['x'] = df.col.apply(lambda col: raster.geot[0]+(col)*raster.geot[1])
    df['y'] = df.row.apply(lambda row: raster.geot[3]+(row)*raster.geot[-1])
    return df
497460
def dataframe(self):
        """"""
        data = self.data
        channel_names = self.get_channel_names()
        return pd.DataFrame(data, columns=channel_names)
1290242
def _get_df(self):
        
        grids = {}
        df = pd.DataFrame()
        for bnd in self.bands:
            s,b = self.get_band(bnd, **self.kwargs)
            logging.debug('loading {} band from {}'.format(b,s))
            if s not in grids:
                grids[s] = self.get_hdf(s)
            if self.common_columns[0] not in df:
                df[list(self.common_columns)] = grids[s][list(self.common_columns)]
            col = grids[s][b]
            n_nan = np.isnan(col).sum()
            if n_nan > 0:
                logging.debug('{} NANs in {} column'.format(n_nan, b))
            df.loc[:, bnd] = col.values #dunno why it has to be this way; something
                                        # funny with indexing.

        return df