def test_long(df_long, wide_to_long):
    melted = wide_to_long(
        dataframe=df_long,
        value_columns=hlp.string_to_list(
            'PHT, PF, KRF, RBF, SDUNK, SDP, SDKR, SDRD, SDAN'),
        value_column_name='cover')

    assert (
        hlp.string_to_list('PHT, PF, KRF, RBF, SDUNK, SDP, SDKR, SDRD, SDAN')
        == melted['species_column'].drop_duplicates().values.tolist()) is True
Exemple #2
0
def covar_handle5():
    covarlned = {'columns': None}
    covarlned['columns'] = string_to_list('TEMP, TAG')
    covarini = ini.InputHandler(name='covarinfo',
                                tablename='covartable',
                                lnedentry=covarlned)
    return covarini
Exemple #3
0
def covar_handle_3_biomass():
    covarlned = {'columns': None}
    covarlned['columns'] = string_to_list('temp')
    covarini = ini.InputHandler(name='covarinfo',
                                tablename='covartable',
                                lnedentry=covarlned)
    return covarini
Exemple #4
0
def covar_handle_4_percent_cover():
    covarlned = {'columns': None}
    covarlned['columns'] = string_to_list('Precip')
    covarini = ini.InputHandler(name='covarinfo',
                                tablename='covartable',
                                lnedentry=covarlned)
    return covarini
Exemple #5
0
def covar_handle_2_density():
    covarlned = {'columns': None}
    covarlned['columns'] = string_to_list('AREA, VIS, OBS_CODE')
    covarini = ini.InputHandler(name='covarinfo',
                                tablename='covartable',
                                lnedentry=covarlned)
    return covarini
def covar_handle2():
    covarlned = {"columns": None}

    covarlned["columns"] = string_to_list("temp")

    covarini = ini.InputHandler(name="covarinfo", tablename="covartable", lnedentry=covarlned)

    return covarini
Exemple #7
0
        def submit_change(self):
            sender = self.sender()
            self.widetolonglned = {
                'value_columns':
                hlp.string_to_list(self.lnedValuecolumns.text()),
                'datatype_name': self.cboxDatatypecolumn.currentText(),
                'panel_data': self.ckPaneldata.isChecked()
            }

            self.widetolongini = ini.InputHandler(
                name='widetolong', lnedentry=self.widetolonglned)
            self.facade.input_register(self.widetolongini)
            self.facade.create_log_record('widetolong')
            self._log = self.facade._tablelog['widetolong']

            try:
                if self.widetolonglned['panel_data'] is False:
                    self.widetolongtable = hlp.wide_to_long(
                        self.facade._data,
                        value_columns=self.widetolonglned['value_columns'],
                        value_column_name=self.widetolonglned['datatype_name'])
                else:
                    temp = self.facade._data.copy()
                    temp['id'] = temp.index
                    self.widetolongtable = wide_to_long(
                        temp,
                        self.widetolonglned['value_columns'],
                        i="id",
                        j=self.widetolonglned['datatype_name'])
                    self.widetolongtable[self.widetolonglned[
                        'datatype_name']] = self.widetolongtable.index.get_level_values(
                            self.widetolonglned['datatype_name'])
                    self.widetolongtable.reset_index(drop=True, inplace=True)
            except Exception as e:
                print(str(e))
                self.error.showMessage('Could not melt data: ', str(e))

            try:
                assert self.widetolonglned['datatype_name'] != 'NULL'
            except Exception as e:
                print(str(e))
                self.error.showMessage('Invalid datatype column: ' + str(e))
                return

            if sender is self.btnPreview:
                self.widetolongmodel = view.PandasTableModel(
                    self.widetolongtable)
                self.preview.tabviewPreview.setModel(self.widetolongmodel)
                self.preview.show()
            elif sender is self.btnSaveClose:
                hlp.write_column_to_log(self.widetolonglned, self._log,
                                        'widetolong')
                self.facade._data = self.widetolongtable
                self.update_data.emit('update')
                self.close()
    def submit_change(self):
        sender = self.sender()
        self.covarlned['columns'] = hlp.string_to_list(
            self.lnedColumns.text()
        )

        self.covarini = ini.InputHandler(
            name='covarinfo', tablename='covartable',
            lnedentry=self.covarlned)

        self.facade.input_register(self.covarini)
        self.facade.create_log_record('covartable')
        self._log = self.facade._tablelog['covartable']

        if self.covarlned['columns'][0] == '':
            print('in pass')
            pass
        else:
            try:
                self.facade._data[self.covarlned['columns']]
            except Exception as e:
                print(str(e))
                self._log.debug(str(e))
                self.error.showMessage(
                    'Column names not valid: Check spacing ' +
                    'and headers.')
                raise ValueError('Column names are incorrect')

        try:
            self.covardata = ddf.DictionaryDataframe(
                self.facade._data, self.covarlned['columns']
            ).convert_records()
        except Exception as e:
            print(str(e))
            self._log.debug(str(e))
            self.error.showMessage('Could not concatenate columns')
            raise TypeError('Could not concatenate columns')

        self.facade.push_tables['covariates'] = self.covardata

        if sender is self.btnColumns:
            self.message.about(self, 'Status', 'Columns recorded')
        elif sender is self.btnPreview:
            self.covarmodel = views.PandasTableModelEdit(
                self.covardata)
            self.preview.tabviewPreview.setModel(self.covarmodel)
            self.preview.show()
        elif sender is self.btnSaveClose:
            hlp.write_column_to_log(
                self.covarlned, self._log, 'covartable')
            self.close()
        def submit_change(self):
            sender = self.sender()
            self.widetolonglned = {
                'value_columns':
                hlp.string_to_list(self.lnedValuecolumns.text()),
                'datatype_name': self.cboxDatatypecolumn.currentText()
            }
            self.widetolongini = ini.InputHandler(
                name='widetolong',
                lnedentry=self.widetolonglned
            )
            self.facade.input_register(self.widetolongini)
            self.facade.create_log_record('widetolong')
            self._log = self.facade._tablelog['widetolong']

            try:
                self.widetolongtable = hlp.wide_to_long(
                    self.facade._data,
                    value_columns=self.widetolonglned['value_columns'],
                    value_column_name=self.widetolonglned['datatype_name']
                )
            except Exception as e:
                print(str(e))
                self.error.showMessage('Could not melt data: ', str(e))

            try:
                assert self.widetolonglned['datatype_name'] != 'NULL'
            except Exception as e:
                print(str(e))
                self.error.showMessage(
                    'Invalid datatype column: ' + str(e))
                return

            hlp.write_column_to_log(
                self.widetolonglned, self._log, 'widetolong')

            if sender is self.btnPreview:
                self.widetolongmodel = view.PandasTableModel(
                    self.widetolongtable)
                self.preview.tabviewPreview.setModel(
                    self.widetolongmodel)
                self.preview.show()
            elif sender is self.btnSaveClose:
                self.facade._data = self.widetolongtable
                self.update_data.emit('update')
                self.close()
Exemple #10
0
    def submit_change(self):
        sender = self.sender()
        self.covarlned['columns'] = hlp.string_to_list(self.lnedColumns.text())

        self.covarini = ini.InputHandler(name='covarinfo',
                                         tablename='covartable',
                                         lnedentry=self.covarlned)

        self.facade.input_register(self.covarini)
        self.facade.create_log_record('covartable')
        self._log = self.facade._tablelog['covartable']

        if self.covarlned['columns'][0] == '':
            print('in pass')
            pass
        else:
            try:
                self.facade._data[self.covarlned['columns']]
            except Exception as e:
                print(str(e))
                self._log.debug(str(e))
                self.error.showMessage(
                    'Column names not valid: Check spacing ' + 'and headers.')
                raise ValueError('Column names are incorrect')

        try:
            self.covardata = ddf.DictionaryDataframe(
                self.facade._data,
                self.covarlned['columns']).convert_records()
        except Exception as e:
            print(str(e))
            self._log.debug(str(e))
            self.error.showMessage('Could not concatenate columns')
            raise TypeError('Could not concatenate columns')

        self.facade.push_tables['covariates'] = self.covardata

        if sender is self.btnColumns:
            self.message.about(self, 'Status', 'Columns recorded')
        elif sender is self.btnPreview:
            self.covarmodel = views.PandasTableModelEdit(self.covardata)
            self.preview.tabviewPreview.setModel(self.covarmodel)
            self.preview.show()
        elif sender is self.btnSaveClose:
            hlp.write_column_to_log(self.covarlned, self._log, 'covartable')
            self.close()
def covar_handle_2_density():
    covarlned = {"columns": None}
    covarlned["columns"] = string_to_list("AREA, VIS, OBS_CODE")
    covarini = ini.InputHandler(name="covarinfo", tablename="covartable", lnedentry=covarlned)
    return covarini