Skip to content

Deactivate all snooping except explicitly specified "watch"es #247

Open
@wolthom

Description

@wolthom

Hey There,

First of:
Thank you a lot for this awesome package :)
It's super useful for ad-hoc debugging of algorithms and data manipulations!

It would be awesome, if I could specify only certain variables, expressions, etc. to snoop on.
E.g., consider this minimal, constructed example:

import pandas as pd
import pysnooper

df = pd.DataFrame({"Job": ["3591.", "22226.", "2873.", "3591."]})

@pysnooper.snoop(watch="sub_df.shape")
def clean_df(df):
     sub_df = df
     sub_df = df.groupby("Job").agg("first").reset_index()
     return sub_df

clean_df(df)

In this case, I'd like to see only the expression passed to watch, to see how the DataFrame shape changes throughout the manipulations of some data processing pipeline.
Potentially, this could also interoperate really nicely with .pipe or .assign chains in pandas.

My apologies in case I missed this feature in the docs somewhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions