How to use the datacompy.utils function in datacompy

To help you get started, we’ve selected a few datacompy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github capitalone / datacompy / tests / test_utils.py View on Github external
def test_numeric_columns_equal_abs():
    data = """a|b|expected
1|1|True
2|2.1|True
3|4|False
4|NULL|False
NULL|4|False
NULL|NULL|True"""
    df = pd.read_csv(six.StringIO(data), sep="|")
    actual_out = utils.columns_equal(df.a, df.b, abs_tol=0.2)
    expect_out = df["expected"]
    assert_series_equal(expect_out, actual_out, check_names=False)
github capitalone / datacompy / tests / test_utils.py View on Github external
def test_date_columns_unequal():
    """I want datetime fields to match with dates stored as strings
    """
    df = pd.DataFrame([{"a": "2017-01-01", "b": "2017-01-02"}, {"a": "2017-01-01"}])
    df["a_dt"] = pd.to_datetime(df["a"])
    df["b_dt"] = pd.to_datetime(df["b"])
    assert utils.columns_equal(df.a, df.a_dt).all()
    assert utils.columns_equal(df.b, df.b_dt).all()
    assert utils.columns_equal(df.a_dt, df.a).all()
    assert utils.columns_equal(df.b_dt, df.b).all()
    assert not utils.columns_equal(df.b_dt, df.a).any()
    assert not utils.columns_equal(df.a_dt, df.b).any()
    assert not utils.columns_equal(df.a, df.b_dt).any()
    assert not utils.columns_equal(df.b, df.a_dt).any()