def test_to_expectation_suite_no_context(mod, df): report = ProfileReport(df) _ = report.to_expectation_suite( data_context=None, save_suite=False, run_validation=False, build_data_docs=False, ) mod.data_context.DataContext.assert_called_once()
def test_to_expectations_suite_title(context, df): report = ProfileReport(df, title="Expectations Dataset") _ = report.to_expectation_suite( suite_name=None, data_context=context, run_validation=False, ) context.create_expectation_suite.assert_called_once_with( "expectations-dataset", overwrite_existing=True )
def test_to_expectations_suite_context_no_save_and_no_build_data_docs(mod, context, df): report = ProfileReport(df) _ = report.to_expectation_suite( data_context=context, save_suite=False, run_validation=False, build_data_docs=False, ) mod.data_context.DataContext.assert_not_called() mod.dataset.PandasDataset.assert_called_once() context.create_expectation_suite.assert_called_once() context.save_expectation_suite.assert_not_called() context.build_data_docs.assert_not_called() context.open_data_docs.assert_not_called()
from pandas_profiling import ProfileReport from pandas_profiling.utils.cache import cache_file file_name = cache_file( "titanic.csv", "https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv", ) df = pd.read_csv(file_name) profile = ProfileReport(df, title="Pandas Profiling Report", explorative=True) # Example 1 # Obtain expectation suite, this includes profiling the dataset, saving the expectation suite, validating the # dataframe, and building data docs suite = profile.to_expectation_suite(suite_name="titanic_expectations") # Example 2 # Run Great Expectations while specifying the directory with an existing Great Expectations set-up by passing in a # Data Context data_context = ge.data_context.DataContext( context_root_dir="my_ge_root_directory/") suite = profile.to_expectation_suite(suite_name="titanic_expectations", data_context=data_context) # Example 3 # Just build the suite suite = profile.to_expectation_suite( suite_name="titanic_expectations", save_suite=False,
def test_to_expectation_suite_raises(df): report = ProfileReport(df) with pytest.raises(ImportError): report.to_expectation_suite()