Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: add pandas / numpy array support #887

Open
guidopetri opened this issue Aug 29, 2024 · 0 comments
Open

Request: add pandas / numpy array support #887

guidopetri opened this issue Aug 29, 2024 · 0 comments
Labels

Comments

@guidopetri
Copy link

Is your feature request related to a problem? Please describe.

I'm trying to use snapshots with pandas dataframes but it seems difficult to build my own extension separately from syrupy and use it across multiple projects. It also seems less than ideal to serialize the dataframe as text since this loses typing and precision information.

Describe the solution you'd like

I'd like to be able to do this:

assert pd.DataFrame(['test']) == snapshot

Describe alternatives you've considered

Pandas allows for conversion to other formats, e.g. csv/json. Serializing to these formats is not very readable and can lose information (e.g. CSV does not contain types), and does not support custom python objects.

Additional context

I've seen #786 and the code that that commenter wrote, but to use that extension you have to override private methods, and that doesn't seem ideal - if the private methods change, then all the projects using that extension are now broken. Additionally, there's no easy way to import that code, it'd have to be maintained across multiple projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants