question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ENH: snapshot testing of dataframes

See original GitHub issue

Is your feature request related to a problem?

When testing dataframe manipulating functions defining explicit expected dataframes takes a lot of time.

Describe the solution you’d like

I’ve used snapshottest to test GraphQl APIs. The same approach could be implemented in a pytest plugin for pandas as well.

API breaking implications

[this should provide a description of how this feature will affect the API]

Describe alternatives you’ve considered

[this should provide a description of any alternative solutions or features you’ve considered]

Additional context

[add any other context, code examples, or references to existing implementations about the feature request here]

# Your code here, if applicable

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
clintmodcommented, Sep 25, 2020

It’s worth noting that this works pretty well with pytest and snapshottest for a dataframe:

def test_something_works(snapshot): # snapshot is a pytest fixture from snapshottest
    data_frame = calc_something_and_return_pandas_dataframe()
    snapshot.assert_match(data_frame.to_csv(index=False), 'some_module_level_unique_name_for_the_snapshot')
0reactions
fkromercommented, Oct 1, 2020

@clintmod Yepp. The problem is that .csv does not save the df meta data (types of rows/columns, etc.) and that multi rows/columnns are tricky. Instead I usually store the data into .h5 instead. In any case you have to work with files which are not easy to read and diff. But right now I’m totally fine with implementing it this way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Snapshot Testing - Jest
Snapshot tests are a very useful tool whenever you want to make sure your UI does not change unexpectedly.
Read more >
Snapshot tests - testthat
The goal of a unit test is to record the expected output of a function using code. This is a powerful technique because...
Read more >
How do you Unit Test Python DataFrames - Stack Overflow
One technique you can use is to define one set of test data for a number of functions. That way, you can use...
Read more >
Parse huge json file
The following is an example JSON object used in this test: JSON Object. ... using both the Dataframe and Spark SQL. json"); }...
Read more >
Plotly button click - Topsh.it
I tried to replicate the code provided for testing the button click event for ... names it 'Snapshot', and re-directs its click event...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found