pythonpandasgreat-expectations

Can't get expect_table_columns_to_match_set to work


If I define df_asset as follows

import great_expectations as ge
df_asset = ge.from_pandas(pd.DataFrame({'A': [1.1, 2.2, 3.3], 'B': [4.4, 5.5, 6.6]}))

then the expect_table_columns_to_match_ordered_list method works (output on 2nd line):

df_asset.expect_table_columns_to_match_ordered_list(['A', 'B'])
{'success': True, 'result': {'observed_value': ['A', 'B']}}

However the following does not:

df_asset.expect_table_columns_to_match_set(set(['A', 'B']))
AttributeError: 'PandasDataset' object has no attribute 'expect_table_columns_to_match_set'

The Great Expectations version is 0.7.6. What is going wrong here?


Solution

  • I would recommend to increase your version. I tried your code on my google colab and was able to run successfully(ge version 0.15.43)

    pip install great_expectations  # version is 0.15.43
    
    import great_expectations as ge
    import pandas as pd
    df_asset = ge.from_pandas(pd.DataFrame({'A': [1.1, 2.2, 3.3], 'B': [4.4, 5.5, 6.6]}))
    df_asset.expect_table_columns_to_match_set(set(['A', 'B']))
    
    #{
      "exception_info": {
        "raised_exception": false,
        "exception_traceback": null,
        "exception_message": null
      },
      "meta": {},
      "result": {
        "observed_value": [
          "A",
          "B"
        ]
      },
      "success": true,
      "expectation_config": {
        "meta": {},
        "expectation_type": "expect_table_columns_to_match_set",
        "kwargs": {
          "column_set": [
            "B",
            "A"
          ],
          "result_format": "BASIC"
        }
      }
    }