Search code examples
pythonunit-testingvaex

vaex: Check for equality between two frames


Does vaex have any utility functions that help with checking for equality between two dataframes?

For example: pandas has pandas.testing.assert_frame_equal to check if two frames hold the same columns and values, which is rather nice when writing unit tests. Is there something similar in vaex? Or maybe there is another convenient way to achieve this?


Solution

  • There is no utility, but I think it's a good idea to have (If you care, you could open an issue at https://github.com/vaexio/vaex/issues):

    A short version would be (ignoring NaN's):

    import vaex
    df1 = vaex.example()
    df2 = vaex.example()
    
    df = df1.join(df2, rprefix='rhs_')  # join based on rows number
    column_names = df1.get_column_names()
    equal = all((df[name] != df["rhs_" + name]).sum() == 0 for name in column_names)
    print(equal)
    
    True