def test_dataframe_builder(): df_builder = DataFrameBuilder(TestClass) df_builder.add(test_variant, test_obj) df = df_builder.to_dataframe() expected = pd.DataFrame(OrderedDict([ ("chr", ["X"]), ("pos", [10]), ("ref", ["CC"]), ("alt", ["C"]), ("a", [test_obj.a]), ("b", [test_obj.b]), ("c", [test_obj.c]), ])) check_same_dataframes(df, expected)
def test_dataframe_builder(): df_builder = DataFrameBuilder(TestClass) df_builder.add(test_variant, test_obj) df = df_builder.to_dataframe() expected = pd.DataFrame( OrderedDict([ ("chr", ["X"]), ("pos", [10]), ("ref", ["CC"]), ("alt", ["C"]), ("a", [test_obj.a]), ("b", [test_obj.b]), ("c", [test_obj.c]), ])) check_same_dataframes(df, expected)
def test_dataframe_rename_and_converters_and_exclude(): df_builder = DataFrameBuilder(TestClass, rename_dict={"c": "C"}, converters=dict(c=int), exclude=["a", "b"]) df_builder.add(test_variant, test_obj) df = df_builder.to_dataframe() expected = pd.DataFrame( OrderedDict([ ("chr", ["X"]), ("pos", [10]), ("ref", ["CC"]), ("alt", ["C"]), ("C", [int(test_obj.c)]), ])) check_same_dataframes(df, expected)
def test_dataframe_rename_and_converters_and_exclude(): df_builder = DataFrameBuilder( TestClass, rename_dict={"c": "C"}, converters=dict(c=int), exclude=["a", "b"]) df_builder.add(test_variant, test_obj) df = df_builder.to_dataframe() expected = pd.DataFrame(OrderedDict([ ("chr", ["X"]), ("pos", [10]), ("ref", ["CC"]), ("alt", ["C"]), ("C", [int(test_obj.c)]), ])) check_same_dataframes(df, expected)
def test_dataframe_rename_and_converters(): df_builder = DataFrameBuilder( TestClass, rename_dict={"a": "A", "b": "B", "c": "C"}, converters=dict(a=float, c=int)) df_builder.add(test_variant, test_obj) df = df_builder.to_dataframe() expected = pd.DataFrame(OrderedDict([ ("chr", ["X"]), ("pos", [10]), ("ref", ["CC"]), ("alt", ["C"]), ("A", [float(test_obj.a)]), ("B", [test_obj.b]), ("C", [int(test_obj.c)]), ])) check_same_dataframes(df, expected)
def test_dataframe_rename_and_converters(): df_builder = DataFrameBuilder(TestClass, rename_dict={ "a": "A", "b": "B", "c": "C" }, converters=dict(a=float, c=int)) df_builder.add(test_variant, test_obj) df = df_builder.to_dataframe() expected = pd.DataFrame( OrderedDict([ ("chr", ["X"]), ("pos", [10]), ("ref", ["CC"]), ("alt", ["C"]), ("A", [float(test_obj.a)]), ("B", [test_obj.b]), ("C", [int(test_obj.c)]), ])) check_same_dataframes(df, expected)