How to use the mindsdb.libs.helpers.text_helpers.clean_float function in MindsDB

To help you get started, we’ve selected a few MindsDB examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mindsdb / mindsdb / mindsdb / libs / phases / stats_generator / stats_generator.py View on Github external
def _is_number(self, string):
        """ Returns True if string is a number. """
        try:
            # Should crash if not number
            clean_float(str(string))
            if '.' in str(string) or ',' in str(string):
                return DATA_SUBTYPES.FLOAT
            else:
                return DATA_SUBTYPES.INT
        except ValueError:
            return False
github mindsdb / mindsdb / mindsdb / libs / phases / stats_generator / stats_generator.py View on Github external
def clean_int_and_date_data(col_data):
        cleaned_data = []

        for value in col_data:
            if value != '' and value != '\r' and value != '\n':
                cleaned_data.append(value)

        cleaned_data = [clean_float(i) for i in cleaned_data if str(i) not in ['', str(None), str(False), str(np.nan), 'NaN', 'nan', 'NA', 'null']]
        return cleaned_data
github mindsdb / mindsdb / mindsdb / libs / phases / stats_generator / stats_generator.py View on Github external
def _is_number(self, string):
        """ Returns True if string is a number. """
        try:
            # Should crash if not number
            clean_float(str(string))
            if '.' in str(string) or ',' in str(string):
                return DATA_SUBTYPES.FLOAT
            else:
                return DATA_SUBTYPES.INT
        except ValueError:
            return False
github mindsdb / mindsdb / mindsdb / libs / phases / data_transformer / data_transformer.py View on Github external
def run(self, input_data):
        for column in input_data.columns:

            if column in self.transaction.lmd['columns_to_ignore']:
                continue
            
            data_type = self.transaction.lmd['column_stats'][column]['data_type']
            data_subtype = self.transaction.lmd['column_stats'][column]['data_subtype']

            if data_type == DATA_TYPES.NUMERIC:
                self._aply_to_all_data(input_data, column, clean_float, self.transaction.lmd['type'])
                self._aply_to_all_data(input_data, column, self._handle_nan, self.transaction.lmd['type'])

                if data_subtype == DATA_SUBTYPES.INT:
                    self._aply_to_all_data(input_data, column, DataTransformer._try_round, self.transaction.lmd['type'])

            if data_type == DATA_TYPES.DATE:
                if data_subtype == DATA_SUBTYPES.DATE:
                    self._aply_to_all_data(input_data, column, self._standardize_date, self.transaction.lmd['type'])

                elif data_subtype == DATA_SUBTYPES.TIMESTAMP:
                    self._aply_to_all_data(input_data, column, self._standardize_datetime, self.transaction.lmd['type'])

            if data_type == DATA_TYPES.CATEGORICAL:
                    self._cast_all_data(input_data, column, 'category', self.transaction.lmd['type'])

            if self.transaction.hmd['model_backend'] == 'lightwood':