tsteuer il y a 5 ans
Parent
commit
d6d7a593f6

+ 0 - 73
utils/ClassLogging.py

@@ -1,73 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-"""
-Created on Fri Sep 27 14:20:58 2019
-
-@author: tanya
-"""
-
-import os
-import sys
-import pandas as pd
-sys.path.append(os.getcwd())
-
-
-class ClassLogging:
-    '''
-    '''
-    def __init__(self, log_name: str = None):
-        '''
-        '''
-        from libraries.log import Log
-
-        self._log = Log(log_name)
-
-    def log_and_raise(self, message):
-        '''
-        '''
-        self._log.error(message)
-
-        raise Exception(message)
-
-    def log_and_warn(self, message):
-        '''
-        '''
-        self._log.warning(message)
-
-    def check_is_file(self, path):
-        '''
-        '''
-        if not os.path.isfile(path):
-            err = "File {} not found".format(path)
-            self._log.error(err)
-            raise FileNotFoundError(err)
-
-    def _check_column_abscence(self, columns: (str, list), data: pd.DataFrame,
-                               error_or_warning: str):
-        '''
-        '''
-        if isinstance(columns, str):
-            columns = [columns]
-
-        for column in columns:
-
-            if column not in data.columns:
-                err = ("{} is not an internal column name".format(column))
-                getattr(self._log, error_or_warning)(err)
-
-                if error_or_warning == "error":
-                    raise Exception(err)
-
-    def error_column_abscence(self, columns: (str, list), data: pd.DataFrame):
-        '''
-        '''
-        return self._check_column_abscence(columns=columns,
-                                           data=data,
-                                           error_or_warning="error")
-
-    def warn_column_abscence(self, columns: (str, list), data: pd.DataFrame):
-        '''
-        '''
-        return self._check_column_abscence(columns=columns,
-                                           data=data,
-                                           error_or_warning="warning")

+ 0 - 62
utils/CleaningUtils.py

@@ -1,62 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-"""
-Created on Fri Sep 27 16:20:03 2019
-
-@author: tanya
-"""
-
-import pandas as pd
-import numpy as np
-
-
-class CleaningUtils:
-    '''
-    '''
-    def convert_dates(series: pd.Series, formats: (str, list)) -> pd.Series:
-        '''
-        '''
-        formats = list(formats)
-
-        converted = pd.Series([pd.to_datetime(np.nan)]*len(series))
-
-        for formt in formats:
-            if formt == "%d%m%Y":
-                missing_leading_zero = (series.astype(str).str.len() == 7)
-
-                series = series.astype(str)
-
-                series.loc[missing_leading_zero] = "0" +\
-                    series.loc[missing_leading_zero]
-
-            converted_this_format = pd.to_datetime(series,
-                                                   format=formt,
-                                                   errors="coerce")
-
-            converted.fillna(converted_this_format, inplace=True)
-
-        return converted
-
-    def standarize_writing(self, s: str):
-        '''
-        '''
-        import re
-
-        german_character_mapping = {"ß": "ss",
-                                    "ü": "ue",
-                                    "Ü": "Ue",
-                                    "ä": "ae",
-                                    "Ä": "Ae",
-                                    "ö": "oe",
-                                    "Ö": "Oe"}
-
-        s = s.encode('raw_unicode_escape').decode('raw_unicode_escape')
-        for char, correct_char in german_character_mapping.items():
-            s = s.replace(char, correct_char)
-
-        s = s.lower()
-
-        s = re.sub('[^0-9a-zA-Z]+', '_', s)
-
-        return s
-

BIN
utils/__pycache__/ClassLogging.cpython-37.pyc


BIN
utils/__pycache__/CleaningUtils.cpython-37.pyc