# Exact match for expect\_table\_columns\_to\_match\_set

**URL:** <https://discourse.greatexpectations.io/t/exact-match-for-expect-table-columns-to-match-set/1446>\
**Category:** Share\
**Created:** [October 23, 2023, 3:36pm UTC](https://discourse.greatexpectations.io/t/exact-match-for-expect-table-columns-to-match-set/1446 "2023-10-23T15:36:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aleksei](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@Aleksei](https://discourse.greatexpectations.io/u/Aleksei)\
**Post date:** [October 23, 2023, 3:36pm UTC](https://discourse.greatexpectations.io/t/exact-match-for-expect-table-columns-to-match-set/1446/1 "2023-10-23T15:36:52Z")

</div>

GX has an expectation called [expect\_table\_columns\_to\_match\_set](https://greatexpectations.io/expectations/expect_table_columns_to_match_set?filterType=Backend%20support&gotoPage=1&showFilters=true&viewType=Summary) that checks if the columns in a data frame match an unordered set. This expectation has a parameter called exact\_match, which allows users to specify whether the list of columns must exactly match the observed columns. However, based on my experience, this parameter might not be clear to all users.

To provide a better understanding of how this parameter affects the expectation’s behavior, let’s consider an example. Assume we have a data frame called df with the following columns: “a”, “b”, and “c”. We can implement several expectations with different values by using the GX:

`pd_gx = gx.from_pandas(df)`

1. `pd_gx.expect_table_columns_to_match_set(["a", "b"], exact_match=False)`  
This expectation will return True because exact\_match is set to False, meaning that the data frame must have at least the expected columns (in any order).
2. `pd_gx.expect_table_columns_to_match_set(["a", "b"], exact_match=True)`  
This expectation will return False because exact\_match is set to True, meaning that the data frame must have the expected columns exactly (in any order).
3. `pd_gx.expect_table_columns_to_match_set(["a", "b", "c", "d"], exact_match=False)`
4. `pd_gx.expect_table_columns_to_match_set(["a", "b", "c", "d"], exact_match=True)`  
Both of these expectations will return False because the data frame does not have all the expected columns.  
I believe these examples will help you gain a deeper understanding of the exact\_match parameter.

Full example:

```auto
import pandas as pd
import great_expectations as gx

df = pd.DataFrame({"a": [1,2,3], "b": ["a", "b", "c"], "c": [True, False, True]})
pd_gx = gx.from_pandas(df)
result = [
  pd_gx.expect_table_columns_to_match_set(["a", "b"], exact_match=False).success,
  pd_gx.expect_table_columns_to_match_set(["a", "b"], exact_match=True).success,
  pd_gx.expect_table_columns_to_match_set(["a", "b","c", "d"], exact_match=False).success,
  pd_gx.expect_table_columns_to_match_set(["a", "b","c", "d"], exact_match=True).success 
]
result

```

---

<div class="post-metadata">

**Author:** ![HaebichanGX](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.greatexpectations.io/haebichangx/32/211_2.png) [@HaebichanGX](https://discourse.greatexpectations.io/u/HaebichanGX)\
**Post date:** [October 23, 2023, 5:39pm UTC](https://discourse.greatexpectations.io/t/exact-match-for-expect-table-columns-to-match-set/1446/2 "2023-10-23T17:39:42Z")

</div>

Thank you for sharing this information for the community @Aleksei !
