Restore the main dataframe
9469
def restore(self):
        
        if self.backup_df is None:
            self.warning("No dataframe is backed up: nothing restore")
            return
        self.df = self.backup_df
        self.ok("Dataframe is restored")
1255693
def dataframe(self):
        """"""

        if self._dataframe is None:
            try:
                import pandas as pd
            except ImportError:
                raise RuntimeError('To enable dataframe support, '
                                   'run \'pip install datadotworld[pandas]\'')

            self._dataframe = pd.DataFrame.from_records(self._iter_rows(),
                                                        coerce_float=True)

        return self._dataframe
549561
def save_dataframes(self, outdir, prefix='df_'):
        
        # Get list of attributes that start with "df_"
        dfs = list(filter(lambda x: x.startswith(prefix), dir(self)))

        counter = 0
        for df in dfs:
            outpath = ssbio.utils.outfile_maker(inname=df, outext='.csv', outdir=outdir)
            my_df = getattr(self, df)
            if not isinstance(my_df, pd.DataFrame):
                raise TypeError('{}: object is not a Pandas DataFrame'.format(df))

            if my_df.empty:
                log.debug('{}: empty dataframe, not saving'.format(df))
            else:
                my_df.to_csv(outpath)
                log.debug('{}: saved dataframe'.format(outpath))
                counter += 1

        log.debug('Saved {} dataframes at {}'.format(counter, outdir))
1093363
def _init_dataframes(self):
        
        df = pd.read_sql_query("SELECT elapsed, epoch, scriptrun_time, custom_timers FROM result ORDER BY epoch ASC",
                               db.get_conn())

        self._get_all_timers(df)
        self.main_results = self._get_processed_dataframe(df)

        # create all custom timers dataframes
        for key, value in six.iteritems(self._timers_values):
            df = pd.DataFrame(value, columns=['epoch', 'scriptrun_time'])
            df.index = pd.to_datetime(df['epoch'], unit='s')
            timer_results = self._get_processed_dataframe(df)
            self.timers_results[key] = timer_results

        # clear memory
        del self._timers_values
944056
def reset(self):
        
        self.curr_batch_index = 0
        if self.permute:
            # shuffle batch start indices
            random.shuffle(self.batch_indices)

            # restore the data permutation
            self.data = self.data.permute(self.inverse_data_permutations)

            # permute the data within each batch
            self.data_permutations, self.inverse_data_permutations = get_permutations(self.data.get_bucket_counts())
            self.data = self.data.permute(self.data_permutations)
858650
def restore(self):
        
        if self._fire_model_event("restoring") is False:
            return False

        setattr(self, self.get_deleted_at_column(), None)

        self.set_exists(True)

        result = self.save()

        self._fire_model_event("restored")

        return result
54521
def retrieve_data(self):
        

        #==== Retrieve data ====#

        df = self.manager.get_historic_data(self.start.date(), self.end.date())
        df.replace(0, np.nan, inplace=True)
        return df
1031380
def reindex(self, axis, labels, **kwargs):
        

        # To reindex, we need a function that will be shipped to each of the
        # partitions.
        def reindex_builer(df, axis, old_labels, new_labels, **kwargs):
            if axis:
                while len(df.columns) < len(old_labels):
                    df[len(df.columns)] = np.nan
                df.columns = old_labels
                new_df = df.reindex(columns=new_labels, **kwargs)
                # reset the internal columns back to a RangeIndex
                new_df.columns = pandas.RangeIndex(len(new_df.columns))
                return new_df
            else:
                while len(df.index) < len(old_labels):
                    df.loc[len(df.index)] = np.nan
                df.index = old_labels
                new_df = df.reindex(index=new_labels, **kwargs)
                # reset the internal index back to a RangeIndex
                new_df.reset_index(inplace=True, drop=True)
                return new_df

        old_labels = self.columns if axis else self.index
        new_index = self.index if axis else labels
        new_columns = labels if axis else self.columns
        func = self._prepare_method(
            lambda df: reindex_builer(df, axis, old_labels, labels, **kwargs)
        )
        # The reindex can just be mapped over the axis we are modifying. This
        # is for simplicity in implementation. We specify num_splits here
        # because if we are repartitioning we should (in the future).
        # Additionally this operation is often followed by an operation that
        # assumes identical partitioning. Internally, we *may* change the
        # partitioning during a map across a full axis.
        new_data = self._map_across_full_axis(axis, func)
        return self.__constructor__(new_data, new_index, new_columns)
888614
def reload(self):
        ''
        self.rows = []

#        if len(self.origCols) == 1 and self.origCols[0].type in (int, float, currency):
#            self.numericBinning()
#        else:
        self.discreteBinning()

        # automatically add cache to all columns now that everything is binned
        for c in self.nonKeyVisibleCols:
            c._cachedValues = collections.OrderedDict()
1121441
def restore(self):
        """"""
        current, self.nlp.pipeline = self.nlp.pipeline, self.original_pipeline
        unexpected = [name for name, pipe in current if not self.nlp.has_pipe(name)]
        if unexpected:
            # Don't change the pipeline if we're raising an error.
            self.nlp.pipeline = current
            raise ValueError(Errors.E008.format(names=unexpected))
        self[:] = []
1284086
def apply(self, data_source):
        
        dataframe = self.__get_dataframe(data_source, use_target=False)
        dataframe = self.__cleaner.apply(dataframe)
        dataframe = self.__transformer.apply(dataframe)
        return dataframe
613186
def update_dataframe(self, df, table, validate=False):
        """"""
        df = df.copy()
        recoded_columns = self.recode(table=table, validate=validate)
        return pd.concat([df, recoded_columns], axis=1)
476155
def back_dfs(self, start, end=None):
        
        return list(self.iterdfs(start, end, forward=False))
183933
def _render_dataframe(dataframe):
  """"""
  data = dataframe.to_dict(orient='records')
  fields = dataframe.columns.tolist()
  return IPython.core.display.HTML(
      datalab.utils.commands.HtmlBuilder.render_table(data, fields))
132699
public void restore(List<DataSlice> slices) {
    schema = JMFRegistry.instance.createJMFSchema(slices.get(0).getBytes());
  }
1105463
def clean(self, data):
        
        try:
            value = data[self.column_name]
        except KeyError:
            raise KeyError("Column '%s' not found in dataset. Available "
                           "columns are: %s" % (self.column_name, list(data)))

        # If ValueError is raised here, import_obj() will handle it
        value = self.widget.clean(value, row=data)

        if value in self.empty_values and self.default != NOT_PROVIDED:
            if callable(self.default):
                return self.default()
            return self.default

        return value
197580
def from_dataframe(dataframe, table_name=""):
        

        return TableData(table_name, list(dataframe.columns.values), dataframe.values.tolist())