multimeric / PandasSchema

A validation library for Pandas data frames using user-friendly schemas
https://multimeric.github.io/PandasSchema/
GNU General Public License v3.0
189 stars 35 forks source link

Suggestion to fix: Validation warning handling None values #51

Open llikaj17 opened 3 years ago

llikaj17 commented 3 years ago

Validation error doesn't print row, column and value if value is None.

For instance, for DateType checks which should handle null values, the error printed is as follows:

0,This field should be date type instead of 0,"{row: 1, column: ""Date_column""}: ""None"" This field should be date type"

This issue is due to ValidationWarning class (in validation_warning.py) which is ignoring None for the value and prints the generic message. Instead of ignoring None for the value, we could change the value to string in order to print the row and column as it should.

Before:

# line 19: ValidationWarning at validation_warning.py
if self.row is not None and self.column is not None and self.value is not None:
        return '{{row: {}, column: "{}"}}: "{}" {}'.format(self.row, self.column, self.value, self.message)
else:
        return self.message

After:

# line 19: ValidationWarning at validation_warning.py
if self.row is not None and self.column is not None:
        value = self.value if self.value is not None else "None"
        return '{{row: {}, column: "{}"}}: "{}" {}'.format(self.row, self.column, value, self.message)
else:
        return self.message