浏览代码

update MigrationCleaning to handel bool Ja/Nein

tsteuer 4 年之前
父节点
当前提交
957f713539
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      cdplib/db_migration/MigrationCleaning.py

+ 12 - 0
cdplib/db_migration/MigrationCleaning.py

@@ -352,6 +352,18 @@ class MigrationCleaning:
                     self.log.log_and_raise_error(("Column {} contains missing values "
                                         "and cannot be of integer type"
                                         .format(column)))
+                    
+                elif python_type == bool:
+                    
+                    data[column] = data[column].str.lower()
+                    accepted_bool = {'ja': True, 'j': True, '1': True, 
+                                     'yes': True, 'y': True, 'true':True, 
+                                     't': True, 'nein': False, 'n': False,
+                                     'no': False, 'false': False, 'f': False,
+                                     '0': False}
+                    data[column] = data[column].map(accepted_bool)
+                    data[column] = data[column].astype(bool)
+
 
                 elif python_type == str: