Skip to content

Commit

Permalink
fix: linter and delete try execpt
Browse files Browse the repository at this point in the history
  • Loading branch information
agistyaanugrah committed Mar 5, 2024
1 parent 6437f67 commit 3cab238
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions datasae/profiling/profiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@ def check_data_types(data: list) -> dict:
for key, value in data_types.items():
if len(value) == 1:
if list(value)[0] == str:
data_types[key] = 'Text'
data_types[key] = "Text"
elif list(value)[0] == bool:
data_types[key] = 'Boolean'
data_types[key] = "Boolean"
elif list(value)[0] == int or list(value)[0] == float:
data_types[key] = 'Numeric'
data_types[key] = "Numeric"
else:
data_types[key] = 'Unkown'
data_types[key] = "Unkown"
else:
data_types[key] = 'Unkown'
data_types[key] = "Unkown"
return data_types

def profiling(self):
Expand All @@ -196,7 +196,7 @@ def profiling(self):
"number_of_variables": self.check_number_of_variables(data),
"missing_cells": self.check_missing_cells(data),
"duplicate_rows": self.check_duplicate_rows(data),
"data_types": self.check_data_types(data)
"data_types": self.check_data_types(data),
},
"sample": {
"head": self.check_head_and_tail(data)[0],
Expand All @@ -216,13 +216,13 @@ def check_max(data: list) -> float:
Returns:
float: A float containing the total number of rows.
"""
try :
try:
results = max(data)
result = f"Maximum value : {results}"
except :
except:
result = "Value list must be of float data type"
return result

@staticmethod
def check_min(data: list) -> float:
"""
Expand All @@ -234,10 +234,10 @@ def check_min(data: list) -> float:
Returns:
float: A float containing the total number of rows.
"""
try :
try:
results = min(data)
result = f"Minimun value : {results}"
except :
except:
result = "Value list must be of float data type"
return result

Expand All @@ -257,19 +257,19 @@ def check_quantile(data: list, percentile: float) -> float:
Returns:
float: A float containing the total number of rows.
"""
try :
try:
n = len(data)
idx = n * percentile / 100
results = sorted(data)[math.floor(idx)]
result = f"Quantile value : {results}"
except :
except:
result = "Value list must be of float data type"
return result

@staticmethod
def check_median(data: list) -> float:
"""
Check the the value in the middle of a series of values arranged
Check the the value in the middle of a series of values arranged
in sequential data from small to large.
Args:
Expand All @@ -278,10 +278,10 @@ def check_median(data: list) -> float:
Returns:
float: A float containing the total number of rows.
"""
try :
try:
results = statistics.median(data)
result = f"Median value: {results}"
except :
except:
result = "Value list must be of float data type"
return result

Expand Down Expand Up @@ -355,9 +355,9 @@ def check_std_dev(data: list) -> dict:
count[key] = count.get(key, 0) + 1
mean = result[key] / count[key]
squared_diff = (value - mean) ** 2
sum_squared_diff[key] = sum_squared_diff.get(
key, 0
) + squared_diff
sum_squared_diff[key] = (
sum_squared_diff.get(key, 0) + squared_diff
)
elif key not in result:
result[key] = "Invalid Data Type"
count[key] = 0
Expand Down Expand Up @@ -396,9 +396,9 @@ def check_coeff_var(data: list) -> dict:
count[key] = count.get(key, 0) + 1
mean = result[key] / count[key]
squared_diff = (value - mean) ** 2
sum_squared_diff[key] = sum_squared_diff.get(
key, 0
) + squared_diff
sum_squared_diff[key] = (
sum_squared_diff.get(key, 0) + squared_diff
)
elif key not in result:
result[key] = "Invalid Data Type"
count[key] = 0
Expand All @@ -408,7 +408,8 @@ def check_coeff_var(data: list) -> dict:
if isinstance(result[key], (int, float)):
if count[key] > 1:
std_dev = math.sqrt(
sum_squared_diff[key] / (count[key] - 1))
sum_squared_diff[key] / (count[key] - 1)
)
mean = result[key] / count[key]
result[key] = (std_dev / mean) * 100
else:
Expand Down

0 comments on commit 3cab238

Please sign in to comment.