Unified dataset empty data values
This commit is contained in:
parent
bf376c66c9
commit
e16131b436
@ -32,6 +32,8 @@ def __main(json_file_name):
|
|||||||
current_col.append(person[key])
|
current_col.append(person[key])
|
||||||
df[key] = pd.Series(current_col)
|
df[key] = pd.Series(current_col)
|
||||||
|
|
||||||
|
df = df.drop(columns=['is_closed', 'deactivated'])
|
||||||
|
|
||||||
pathname, extension = os.path.splitext(json_file_name)
|
pathname, extension = os.path.splitext(json_file_name)
|
||||||
filename = pathname.split('/')[-1]
|
filename = pathname.split('/')[-1]
|
||||||
|
|
||||||
|
@ -23,28 +23,37 @@ class RawData:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_int_st(value, attr):
|
def get_int_st(value, attr):
|
||||||
if value is None:
|
if value is None:
|
||||||
return -1
|
return ''
|
||||||
result = value[attr]
|
result = value[attr]
|
||||||
if result is None:
|
if result is None:
|
||||||
return -1
|
return ''
|
||||||
if not str(result).isnumeric():
|
if not str(result).isnumeric():
|
||||||
print(f'The value {result} is not a number')
|
print(f'The value {result} is not a number')
|
||||||
return -1
|
return ''
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def str_to_date(value, str_format):
|
||||||
|
return datetime.strptime(value, str_format).date().strftime('%d.%m.%Y')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_date_st(value):
|
def get_date_st(value):
|
||||||
if value is None:
|
if value is None:
|
||||||
return ''
|
return ''
|
||||||
try:
|
try:
|
||||||
return datetime.strptime(value, '%d.%m.%Y').date()
|
return RawData.str_to_date(value, '%d.%m.%Y')
|
||||||
except ValueError:
|
except ValueError:
|
||||||
try:
|
try:
|
||||||
return datetime.strptime(value, '%d.%m.%y').date()
|
return RawData.str_to_date(value, '%d.%m.%y')
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print(f'Invalid date {value}')
|
print(f'Invalid date {value}')
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_collection_st(collection, function):
|
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
Loading…
Reference in New Issue
Block a user