Get generation time series of fluctuating renewables (only active
        power)

        Returns
        -------
        :pandas:`pandas.DataFrame<dataframe>`
            See class definition for details.
173008
def generation_fluctuating(self):
        
        try:
            return self._generation_fluctuating.loc[[self.timeindex], :]
        except:
            return self._generation_fluctuating.loc[self.timeindex, :]
1065103
def pandas(self):
        
        names,prior,posterior = [],[],[]
        for iname,name in enumerate(self.posterior_parameter.row_names):
            names.append(name)
            posterior.append(np.sqrt(float(
                self.posterior_parameter[iname, iname]. x)))
            iprior = self.parcov.row_names.index(name)
            prior.append(np.sqrt(float(self.parcov[iprior, iprior].x)))
        for pred_name, pred_var in self.posterior_prediction.items():
            names.append(pred_name)
            posterior.append(np.sqrt(pred_var))
            prior.append(self.prior_prediction[pred_name])
        return pd.DataFrame({"posterior": posterior, "prior": prior},
                                index=names)
705707
def generate_null_timeseries(self, ts, mu, sigma):
        
        l = len(ts)
        return np.random.normal(mu, sigma, l)
1142082
def toPandas(self):
        
        assert pd is not None
        nindices = self.getNumIndices()
        headers = self.getHeaders()
        columns = {
            header: list(self.getColumn(header))
            for header in headers[nindices:]
        }
        index = zip(*[
            list(self.getColumn(header))
            for header in headers[:nindices]
        ])
        index = [key if len(key) > 1 else key[0] for key in index]
        if index == []:
            return pd.DataFrame(columns, index=None)
        else:
            return pd.DataFrame(columns, index=index)
120109
def to_series(self):
        
        return pandas.Series(
            self.cdf, index=[numpy.nan] + list(self.bin_edges) + [numpy.nan])
1020911
def list_generators(self, session):
        
        srid = str(int(cfg_ding0.get('geo', 'srid')))

        # build dicts to map MV grid district and Load Area ids to related objects
        mv_grid_districts_dict,\
        lv_load_areas_dict,\
        lv_grid_districts_dict,\
        lv_stations_dict = self.get_mvgd_lvla_lvgd_obj_from_id()

        # import renewable generators
        # build query
        generators_sqla = session.query(
                self.orm['orm_re_generators'].columns.id,
                self.orm['orm_re_generators'].columns.subst_id,
                self.orm['orm_re_generators'].columns.la_id,
                self.orm['orm_re_generators'].columns.mvlv_subst_id,
                self.orm['orm_re_generators'].columns.electrical_capacity,
                self.orm['orm_re_generators'].columns.generation_type,
                self.orm['orm_re_generators'].columns.generation_subtype,
                self.orm['orm_re_generators'].columns.voltage_level,
                func.ST_AsText(func.ST_Transform(
                   self.orm['orm_re_generators'].columns.rea_geom_new, srid)).label('geom_new'),
                func.ST_AsText(func.ST_Transform(
                   self.orm['orm_re_generators'].columns.geom, srid)).label('geom')
                ).filter(
                self.orm['orm_re_generators'].columns.subst_id.in_(list(mv_grid_districts_dict))). \
                filter(self.orm['orm_re_generators'].columns.voltage_level.in_([4, 5, 6, 7])). \
                filter(self.orm['version_condition_re'])

        # read data from db
        generators_res = pd.read_sql_query(generators_sqla.statement,
                                        session.bind,
                                        index_col='id')

        generators_res.columns = ['GenCap' if c=='electrical_capacity' else
                                  'type' if c=='generation_type' else
                                  'subtype' if c=='generation_subtype' else
                                  'v_level' if c=='voltage_level' else
                                  c for c in generators_res.columns]
        ###########################
        # Imports conventional (conv) generators
        # build query
        generators_sqla = session.query(
                self.orm['orm_conv_generators'].columns.id,
                self.orm['orm_conv_generators'].columns.subst_id,
                self.orm['orm_conv_generators'].columns.name,
                self.orm['orm_conv_generators'].columns.capacity,
                self.orm['orm_conv_generators'].columns.fuel,
                self.orm['orm_conv_generators'].columns.voltage_level,
                func.ST_AsText(func.ST_Transform(
                   self.orm['orm_conv_generators'].columns.geom, srid)).label('geom')
                ).filter(
                self.orm['orm_conv_generators'].columns.subst_id.in_(list(mv_grid_districts_dict))). \
                filter(self.orm['orm_conv_generators'].columns.voltage_level.in_([4, 5, 6])). \
                filter(self.orm['version_condition_conv'])

        # read data from db
        generators_conv = pd.read_sql_query(generators_sqla.statement,
                                           session.bind,
                                           index_col='id')

        generators_conv.columns = ['GenCap' if c=='capacity' else
                                   'type' if c=='fuel' else
                                   'v_level' if c=='voltage_level' else
                                   c for c in generators_conv.columns]
        ###########################
        generators = pd.concat([generators_conv, generators_res], axis=0)
        generators = generators.fillna('other')
        return generators
497460
def dataframe(self):
        """"""
        data = self.data
        channel_names = self.get_channel_names()
        return pd.DataFrame(data, columns=channel_names)
1310526
def (self):
        """"""

        status = FAILED
        msg = "not started"

        try:

            msg = "generating request"
            log.info(msg)

            # noqa https://stackoverflow.com/questions/29815129/pandas-dataframe-to-list-of-dictionaries
            publish_req = generate_ai_request(
                predict_rows=self.df.fillna(
                    ANTINEX_MISSING_VALUE).to_dict("records"),
                req_dict=self.request_dict)

            if publish_req["status"] != SUCCESS:
                log.error(("failed generate_ai_request with err={}")
                          .format(
                            publish_req["error"]))
                status = ERROR

            else:

                msg = "publishing as user={} url={} model={}".format(
                    ANTINEX_USER,
                    ANTINEX_URL,
                    ANTINEX_USE_MODEL_NAME)

                log.info(msg)

                response = self.client.run_job(
                    body=publish_req["data"])

                if response["status"] == SUCCESS:
                    log.info("predictions sent")
                    status = SUCCESS
                elif response["status"] == FAILED:
                    log.error(("job failed with error='{}' with response={}")
                              .format(
                                response["error"],
                                response["data"]))
                    status = ERROR
                elif response["status"] == ERROR:
                    log.error(("job had an error='{}' with response={}")
                              .format(
                                response["error"],
                                response["data"]))
                    status = ERROR
                elif response["status"] == LOGIN_FAILED:
                    log.error(("job reported user was not able to log in "
                               "with an error='{}' with response={}")
                              .format(
                                response["error"],
                                response["data"]))
                    status = ERROR
                # logging for good/bad cases during publish
            # if generated a good request
        except Exception as e:
            log.error(("failed generating request last_step='{}' ex={}")
                      .format(
                        msg,
                        e))
        # end of try/ex

        return status
149089
def _get_dataframe(self):
        
        if self.source_conn is None:  # Use local file
            return ge.read_csv(self.dataset_name, **self.dataset_params)

        if isinstance(self.source_conn, S3Hook):
            hook = ExpectationS3CsvHook(aws_conn_id=self.source_conn_id)

            return hook.get_ge_df(self.dataset_name, self.source_bucket_name, **self.dataset_params)

        if isinstance(self.source_conn, DbApiHook):
            hook = ExpectationMySQLHook(mysql_conn_id=self.source_conn_id)

            return hook.get_ge_df(self.dataset_name, **self.dataset_params)
572938
def make_dataframe(result):
    
    import pandas as pd
    ret = {}
    if isinstance(result,dict):
        if 'timeseries' in result:
            result = result['timeseries']
    for uuid, data in result.items():
        df = pd.DataFrame(data)
        if len(df.columns) == 5: # statistical data
            df.columns = ['time','min','mean','max','count']
        else:
            df.columns = ['time','value']
        df['time'] = pd.to_datetime(df['time'],unit='ns')
        df = df.set_index(df.pop('time'))
        ret[uuid] = df
    return ret
188972
def peak_generation_per_technology_and_weather_cell(self):
        
        peak_generation = defaultdict(float)
        for gen in self.generators:
            if hasattr(gen, 'weather_cell_id'):
                if (gen.type, gen.weather_cell_id) in peak_generation.keys():
                    peak_generation[gen.type, gen.weather_cell_id] += gen.nominal_capacity
                else:
                    peak_generation[gen.type, gen.weather_cell_id] = gen.nominal_capacity
            else:
                message = 'No weather cell ID found for ' \
                          'generator {}.'.format(repr(gen))
                raise KeyError(message)

        series_index = pd.MultiIndex.from_tuples(list(peak_generation.keys()),
                                                 names=['type', 'weather_cell_id'])

        return pd.Series(peak_generation, index=series_index)
86810
def generate_values(self, *args, **kwargs):
        
        assert 'ref value' in self.kwargs

        # 1. Generate $\mu$
        start_date = self.times[0].to_pydatetime()
        end_date = self.times[-1].to_pydatetime()
        ref_date = self.ref_date

        mu = self.generate_mu(end_date, ref_date, start_date)

        # 3. Generate $\sigma$
        ## Prepare array with growth values $\sigma$
        if self.sample_mean_value:
            sigma = np.zeros((len(self.times), self.size))
        else:

            if self.kwargs['type'] == 'interp':

                def get_date(record):
                    return datetime.datetime.strptime(record[0], "%Y-%m-%d")

                ref_value_ = sorted(json.loads(self.kwargs['ref value'].strip()).items(), key=get_date)
                intial_value = ref_value_[0][1]
            else:
                intial_value = self.kwargs['ref value']

            variability_ = intial_value * self.kwargs['initial_value_proportional_variation']
            logger.debug(f'sampling random distribution with parameters -{variability_}, 0, {variability_}')
            sigma = np.random.triangular(-1 * variability_, 0, variability_,
                                         (len(self.times), self.size))
        ## 4. Prepare growth array for $\alpha_{sigma}$
        alpha_sigma = growth_coefficients(start_date,
                                          end_date,
                                          ref_date,
                                          self.kwargs['ef_growth_factor'], 1)

        ### 5. Prepare DataFrame
        iterables = [self.times, range(self.size)]
        index_names = ['time', 'samples']
        _multi_index = pd.MultiIndex.from_product(iterables, names=index_names)

        df = pd.DataFrame(index=_multi_index, dtype=float)

        from dateutil import relativedelta
        r = relativedelta.relativedelta(end_date, start_date)
        months = r.years * 12 + r.months + 1
        name = kwargs['name']
        ## Apply growth to $\sigma$ and add $\sigma$ to $\mu$
        df[name] = ((sigma * alpha_sigma) + mu.reshape(months, 1)).ravel()

        ## test if df has sub-zero values
        df_sigma__dropna = df[name].where(df[name] < 0).dropna()
        if not df_sigma__dropna.empty:
            logger.warning(f"Negative values for parameter {name} from {df_sigma__dropna.index[0][0]}")

        return df[name]
1028540
def to_dataframe(self) -> "pandas.DataFrame":
        
        import pandas as pd
        df = pd.DataFrame(
            {
                "left": self.bin_left_edges,
                "right": self.bin_right_edges,
                "frequency": self.frequencies,
                "error": self.errors,
            },
            columns=["left", "right", "frequency", "error"])
        return df
196118
def get_frame(self):
        
        metric_items = list(self.db.metrics.find({'run_name': self.model_config.run_name}).sort('epoch_idx'))
        if len(metric_items) == 0:
            return pd.DataFrame(columns=['run_name'])
        else:
            return pd.DataFrame(metric_items).drop(['_id', 'model_name'], axis=1).set_index('epoch_idx')
1343971
def to_pandas_series_rdd(self):
        
        pd_index = self.index().to_pandas_index()
        return self.map(lambda x: (x[0], pd.Series(x[1], pd_index)))
1287774
def df(self):
        
        data = self._final_data()
        
        if len(data) == 0:
            adf = pd.DataFrame(columns = [self.index.name, self.name])
            return adf.set_index(self.index.name)
            
        adf = pd.DataFrame(data)
        
        if len(adf.columns) != 2:
            msg = "Symbol ({}) needs to be cached prior to building a Dataframe"
            msg = msg.format(self.name)
            raise Exception(msg)
        adf.columns = [self.index.name, self.name]
        return self._finish_df(adf, 'FINAL')
19136
def _get_data(self):
        
        # Split the list of times into begin and end dates. If only
        # one date is supplied, set both begin and end dates equal to that date.

        body, header, dates_long, dates = self._get_data_raw()

        params = self._get_fwf_params()

        df_body = pd.read_fwf(StringIO(body), **params['body'])
        df_header = pd.read_fwf(StringIO(header), **params['header'])
        df_body['date'] = dates_long

        df_body = self._clean_body_df(df_body)
        df_header = self._clean_header_df(df_header)
        df_header['date'] = dates

        return df_body, df_header