Spaces:
Sleeping
Sleeping
Mustehson commited on
Commit ·
9d0ca90
1
Parent(s): d43019d
Updated Prompt
Browse files
app.py
CHANGED
|
@@ -92,20 +92,16 @@ def describe(df):
|
|
| 92 |
def validate_pandera(tests, df):
|
| 93 |
validation_results = []
|
| 94 |
|
| 95 |
-
# Loop through each test rule and validate each column separately
|
| 96 |
for test in tests:
|
| 97 |
column_name = test['column_name']
|
| 98 |
-
rule = eval(test['pandera_rule']) # Evaluate the Pandera column rule
|
| 99 |
-
|
| 100 |
try:
|
| 101 |
-
|
| 102 |
-
validated_column = rule(df[[column_name]])
|
| 103 |
validation_results.append({
|
| 104 |
"Columns": column_name,
|
| 105 |
"Result": "✅ Pass"
|
| 106 |
})
|
| 107 |
except Exception as e:
|
| 108 |
-
# If validation fails, catch the exception and mark the column as 'Fail'
|
| 109 |
validation_results.append({
|
| 110 |
"Columns": column_name,
|
| 111 |
"Result": f"❌ Fail - {str(e)}"
|
|
|
|
| 92 |
def validate_pandera(tests, df):
|
| 93 |
validation_results = []
|
| 94 |
|
|
|
|
| 95 |
for test in tests:
|
| 96 |
column_name = test['column_name']
|
|
|
|
|
|
|
| 97 |
try:
|
| 98 |
+
rule = eval(test['pandera_rule'])
|
| 99 |
+
validated_column = rule(df[[column_name]])
|
| 100 |
validation_results.append({
|
| 101 |
"Columns": column_name,
|
| 102 |
"Result": "✅ Pass"
|
| 103 |
})
|
| 104 |
except Exception as e:
|
|
|
|
| 105 |
validation_results.append({
|
| 106 |
"Columns": column_name,
|
| 107 |
"Result": f"❌ Fail - {str(e)}"
|
prompt.py
CHANGED
|
@@ -8,6 +8,7 @@ Follow this process:
|
|
| 8 |
2. **For each column**, create a validation rule using Pandera syntax.
|
| 9 |
Here are the valid pandera check class methods DO NOT USE ANYOTHER METHODS OTHER THAN THE BELOW GIVEN METHODS:
|
| 10 |
DO NOT USE SINGLE backslashes \ BUT USE DOUBLE backslashes \\ IN PATTERN
|
|
|
|
| 11 |
[
|
| 12 |
'pa.Check.between(min_value, max_value, include_min=True, include_max=True, **kwargs)',
|
| 13 |
'pa.Check.eq(value, **kwargs)',
|
|
@@ -32,7 +33,8 @@ Follow this process:
|
|
| 32 |
'pa.Check.str_startswith(string, **kwargs)',
|
| 33 |
'pa.Check.unique_values_eq(values, **kwargs)'
|
| 34 |
]
|
| 35 |
-
|
|
|
|
| 36 |
3. Ensure that each rule specifies the expected data type and applies necessary checks such as:
|
| 37 |
name argument should be a valid column name. DO NOT USE ANYOTHER PANDERA
|
| 38 |
- **Data Type Validation** (e.g., `pa.Column(int, nullable=False, name="age")` ensures integers)
|
|
|
|
| 8 |
2. **For each column**, create a validation rule using Pandera syntax.
|
| 9 |
Here are the valid pandera check class methods DO NOT USE ANYOTHER METHODS OTHER THAN THE BELOW GIVEN METHODS:
|
| 10 |
DO NOT USE SINGLE backslashes \ BUT USE DOUBLE backslashes \\ IN PATTERN
|
| 11 |
+
USE CORRECT SYNTAX AS SHOWN GIVEN BELOW
|
| 12 |
[
|
| 13 |
'pa.Check.between(min_value, max_value, include_min=True, include_max=True, **kwargs)',
|
| 14 |
'pa.Check.eq(value, **kwargs)',
|
|
|
|
| 33 |
'pa.Check.str_startswith(string, **kwargs)',
|
| 34 |
'pa.Check.unique_values_eq(values, **kwargs)'
|
| 35 |
]
|
| 36 |
+
|
| 37 |
+
|
| 38 |
3. Ensure that each rule specifies the expected data type and applies necessary checks such as:
|
| 39 |
name argument should be a valid column name. DO NOT USE ANYOTHER PANDERA
|
| 40 |
- **Data Type Validation** (e.g., `pa.Column(int, nullable=False, name="age")` ensures integers)
|