API Reference#
- datapact.test(dataframe: DataFrame) DataframeTest #
Creates a datapact test object.
>>> df = pandas.read_csv(...) >>> dp = datapact.test(df)
- class datapact.DataframeTest(dataframe: DataFrame)#
- describe(title: Optional[str] = None, description: Optional[str] = None, url: Optional[str] = None)#
Adds human-readable information to the report.
>>> dp.describe( >>> title="Vacancy statistics", >>> description="data sourced from NYC housing markets" >>> )
- collect() DataframeResult #
Collects all tests and returns a DataframeResult object. If connected, uploads results.
>>> dp.day.must.be_datetime() >>> dp.collect() # DataframeResult(...)
- expectations() list[Expectation] #
Returns a list of all executed expectations.
>>> dp.age.should.be_positive() # Pass(be_positive) >>> dp.day.must.be_datetime() # Fail(be_datetime) >>> dp.failed_critical_expectations() # [ Pass(be_positive), Fail(be_datetime) ]
- failed_expectations() list[Expectation] #
Returns a list of all failed expectations.
>>> dp.age.should.be_negative() # Fail(be_negative) >>> dp.day.must.be_datetime() # Fail(be_datetime) >>> dp.failed_critical_expectations() # [ Fail(be_negative), Fail(be_datetime) ]
- failed_critical_expectations() list[Expectation] #
Returns a list of all failed critical expectations.
>>> dp.age.should.be_negative() # Fail(be_negative) >>> dp.day.must.be_datetime() # Fail(be_datetime) >>> dp.failed_critical_expectations() # [ Fail(be_datetime) ]
- is_failure() bool #
Returns True if one of the expectations failed.
>>> dp.day.should.be_datetime() # Fail(be_datetime) >>> dp.is_failure() # True
- is_critical_failure() bool #
Returns True if a critical expectation failed.
>>> dp.day.should.be_datetime() # Fail(be_datetime) >>> dp.is_critical_failure() # False >>> dp.day.must.be_datetime() # Fail(be_datetime) >>> dp.is_critical_failure() # True
- check()#
Raises an exception if a critical expectation failed.
>>> dp.day.must.be_datetime() # Fail(be_datetime) >>> dp.check() # 💥
- to_html()#
Returns a human-readable test result as HTML.
>>> dp.to_html() # "<script>..."
- write_html(to: PathLike)#
Writes the test result to a file.
>>> dp.write_html("test.html")
- class datapact.SeriesTest(parent: DataframeTest, series: Series)#
- should#
should makes an assertion relaxed (results in warnings, not exceptions).
>>> dp.SepalWidth.should.be_in_range(0, 10)
- must#
must makes an assertion critical (results in exceptions, not warnings).
>>> dp.SepalWidth.must.be_in_range(0, 10)
- describe(title: Optional[str] = None, description: Optional[str] = None, unit: Optional[str] = None)#
Adds human-readable information to the column report.
>>> dp.SepalWidth.describe( >>> description="Usually green, sepals typically function as protection ...", >>> unit="cm" >>> )