Mastering Data Quality
The dimensions of data quality, applied with Great Expectations — a practical guide to making bad data loud.
Photo by Krys Amon on Unsplash
Introduction
Many are familiar with the various tools and frameworks for data quality, but do you know how to effectively utilize them? Do you know how to properly test and assert your data? This is where the Dimensions Principles come into play. Let's dive right in.
Data Quality Dimensions
In this article, we're going to explore five key dimensions of data quality: accuracy, completeness, consistency, validity, and uniqueness. While there are more dimensions to consider — an MIT article from 1991 lists about 20 — we'll focus on these five for the sake of brevity.
Embracing these dimensions in your data projects ensures that the insights and models generated from your data are reliable and meaningful.
Tools and Frameworks
We'll be using the Great Expectations Python framework to write data quality tests, also known as expectations. All the code can be found in this GitHub repository.
Real-world Application
To illustrate these principles in practice, we'll be using a real-world example — the 2021–2022 Public Schools dataset from the National Center for Education Statistics (NCES). This dataset provides a wealth of information about public schools in the United States, including data on school characteristics, demographics, and geolocation.
Practical Application

Accuracy
Accuracy in data quality refers to the degree to which data correctly describes the "real world" object or event being described. For data to be accurate, it must be correct and free from errors.
In terms of our dataset, here are the expectations we set to ensure accuracy:
expect_column_values_to_match_regex(column='PHONE', regex='^\(\d{3}\)\d{3}-\d{4}$')— checks that phone numbers follow a standard pattern.expect_column_values_to_match_regex(column='SURVYEAR', regex='^2021-2022$')— verifies all values in 'SURVYEAR' precisely match the expected year range.expect_column_values_to_be_between(column='Y', min_value=-90, max_value=90)— checks that latitude coordinates fall within the acceptable range.expect_column_values_to_be_between(column='X', min_value=-180, max_value=180)— verifies longitude coordinates are within the valid range.
Expectations for Accuracy
Validity
Validity in data quality refers to the extent to which the data conforms to defined business rules or constraints.
expect_column_values_to_be_in_set(column='STABR', value_set=['AL', 'AK', 'AZ', ...])— checks 'STABR' values are valid U.S. state abbreviations.expect_column_values_to_be_in_set("SCHOOL_LEVEL", ["Elementary", "Middle", "High", "Other", "Prekindergarten"])— verifies school level entries are within an accepted set.expect_column_values_to_be_in_set("TITLEI", ["1-Yes", "2-No"])— checks 'TITLEI' entries match either "1-Yes" or "2-No".
Expectations for Validity
Uniqueness
Uniqueness refers to the requirement that a data value should be represented only once in a dataset. This is especially important when dealing with identifiers.
expect_column_values_to_be_unique(column='OBJECTID')— ensures each 'OBJECTID' value is unique.expect_column_values_to_be_unique("NCESSCH")— guarantees the uniqueness of 'NCESSCH' values.
Expectations for Uniqueness
Completeness
Completeness refers to the requirement that a particular set of data should be comprehensive and contain all the necessary elements.
expect_column_values_to_not_be_null(column='OBJECTID')— asserts there are no null or missing values in the 'OBJECTID' column.
Expectations for Completeness
Consistency
Consistency means that the data across the entire dataset follows a specific format, range, or pattern.
expect_column_values_to_be_increasing(column='OBJECTID')— checks whether 'OBJECTID' values are in ascending order.expect_column_mean_to_be_between("TOTAL STUDENTS", 100, 2000)— ensures the average number of students per school falls within a known range.expect_column_mean_to_be_between("TOTAL TEACHERS", 10, 100)— checks the average number of teachers per school falls within a practical range.
Expectations for Consistency
Conclusion
Ensuring data quality is vital in our data-centric world. This tutorial demonstrated how to apply the principles of data quality dimensions — accuracy, validity, uniqueness, completeness, and consistency — using the Great Expectations Python framework and a real-world dataset. The value of your data lies in its quality. By investing in data quality checks, you pave the way for accurate, reliable insights that can inform decision-making.