Unified dataset empty data values

This commit is contained in:
Aleksey Filippov 2023-05-29 22:56:34 +04:00
parent bf376c66c9
commit e16131b436
4 changed files with 19 additions and 8 deletions

View File

@ -32,6 +32,8 @@ def __main(json_file_name):
current_col.append(person[key])
df[key] = pd.Series(current_col)
df = df.drop(columns=['is_closed', 'deactivated'])
pathname, extension = os.path.splitext(json_file_name)
filename = pathname.split('/')[-1]

View File

@ -23,28 +23,37 @@ class RawData:
@staticmethod
def get_int_st(value, attr):
if value is None:
return -1
return ''
result = value[attr]
if result is None:
return -1
return ''
if not str(result).isnumeric():
print(f'The value {result} is not a number')
return -1
return ''
return result
@staticmethod
def str_to_date(value, str_format):
return datetime.strptime(value, str_format).date().strftime('%d.%m.%Y')
@staticmethod
def get_date_st(value):
if value is None:
return ''
try:
return datetime.strptime(value, '%d.%m.%Y').date()
return RawData.str_to_date(value, '%d.%m.%Y')
except ValueError:
try:
return datetime.strptime(value, '%d.%m.%y').date()
return RawData.str_to_date(value, '%d.%m.%y')
except ValueError:
print(f'Invalid date {value}')
return ''
@staticmethod
def get_collection_st(collection, function):
return list(map(lambda item: function(item), [] if collection is None else collection))
if collection is None:
return ''
result_list = list(map(lambda item: function(item), collection))
if len(result_list) == 0:
return ''
return result_list

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long