I am trying to use assert_frame_equal
for tests by comparing the function return dataframe to a dataframe read from a csv file. The csv file was created from the dataframe that this function returns:
results = my_fun()
results.to_csv("test.csv", mode="w", sep="\t", index=False)
Therefore, I assume they should be identical. Now, in the test I have the following code.
results = my_fun()
test_df = pd.read_csv("test.csv", sep="\t", header="infer", index_col=False, encoding="utf-8")
assert_frame_equal(results.reset_index(drop=True), test_df.reset_index(drop=True), check_column_type=False, check_dtype=False)
What I get is the following exception:
E AssertionError: DataFrame.iloc[:, 0] (column name="document_id") are different
E
E DataFrame.iloc[:, 0] (column name="document_id") values are different (100.0 %)
E [left]: [1, 1, 1, 2, 2, 2, 2, 2]
E [right]: [1, 1, 1, 2, 2, 2, 2, 2]
I am scratching my head. What is the actual difference here?
Aucun commentaire:
Enregistrer un commentaire