Skip to content

Commit

Permalink
Added error message in well explained manner
Browse files Browse the repository at this point in the history
  • Loading branch information
venu-sambarapu-DS committed Oct 10, 2024
1 parent 038d858 commit 6fcc890
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ class CustomExpectationsSettings(BaseSettings):
"Index not in Column Names"
)
INDEX_NOT_IN_COLUMN_NAMES_EXPECTATION_ERR_MSG: str = (
"Column names should not have index as a column"
"Column names should not have 'index' as a column so please rename - {column}"
)
NULL_DATETIME_VALUE_NAME: str = "Null date values Flag - {column}"
NULL_DATETIME_VALUE_MSG: str = (
Expand All @@ -336,7 +336,7 @@ class CustomExpectationsSettings(BaseSettings):
"Numeric values in specific pattern - {column}"
)
NUMERIC_EXPECTATION_ERR_MSG: str = (
"Numeric values should be in proper format both integer and float(roundoff to two decimal places)"
"Numeric values should be in proper format both integer and float(round-off to two decimal places)"
)

NEGATIVE_NUMERIC_VALUES_PATTERN = re.compile(r"^-\d+(\.\d{1,})?$")
Expand All @@ -350,7 +350,7 @@ class CustomExpectationsSettings(BaseSettings):
COLUMN_NAMES_PATTERN = re.compile(r"^[a-z]+(?:_[a-z]+)*$")
COLUMN_NAMES_EXPECTATION_NAME: str = "Column names in specific pattern"
COLUMN_NAMES_EXPECTATION_ERR_MSG: str = (
"Column names should be in lower case and separated by underscore - {column}"
"Column names should be in lower case and separated by underscore - Example 'Sub Category' column should be written as 'sub_category' The improper columns list is: {column}"
)

TRAIL_OR_LEAD_WHITESPACE_PATTERN = re.compile(r"^\s+.*|.*\s+$")
Expand Down
12 changes: 10 additions & 2 deletions app/utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,15 @@ async def column_names_expectation_suite(dataset, result_format):
"cleaning_pdf_link": settings.DATA_CLEANING_GUIDE_LINK,
"expectation_name": custom_settings.COLUMN_NAMES_EXPECTATION_NAME,
"expectation_error_message": custom_settings.COLUMN_NAMES_EXPECTATION_ERR_MSG.format(
column=dataset.columns.tolist()
column=list(
set(dataset.columns.tolist())
- set(
[
i.lower().replace(" ", "_")
for i in dataset.columns.tolist()
]
)
)
),
}
response = {
Expand Down Expand Up @@ -367,7 +375,7 @@ async def index_not_in_columns_expectation_suite(dataset, result_format):
"cleaning_pdf_link": settings.DATA_CLEANING_GUIDE_LINK,
"expectation_name": custom_settings.INDEX_NOT_IN_COLUMN_NAMES_EXPECTATION_NAME,
"expectation_error_message": custom_settings.INDEX_NOT_IN_COLUMN_NAMES_EXPECTATION_ERR_MSG.format(
column=dataset.columns.tolist()
column=[i for i in dataset.columns.tolist() if i == "index"]
),
}
response = {
Expand Down

0 comments on commit 6fcc890

Please sign in to comment.