Open xareelee opened 1 year ago
A possible quick fix is to convert the DataFrame to CSV before passing it to snapshottest;
snapshot.assert_match(df.to_csv(index=False), "snapshot_name")
The main downside is that if the assert fails, the error will concern the difference in string values of the CSVs and not those of the actual DataFrames. Additionally, the index cannot be verified.
Alternatively, look at the following extension, which automatically serializes/deserializes the DataFrame and performs the comparison with the pandas assert_frame_equal
function;
https://github.com/swuecho/snapshottest_ext/blob/master/snapshottest_ext/dataframe.py
Is that possible to support Pandas Dataframe?
Currently,
snapshottest
only translatedf
intoGenericRepr
string value. The detailed data will be abbreviated.I hope it can put the dataframe into csv like format, and compare them row by row.