#247·PySnooper

Deactivate all snooping except explicitly specified "watch"es

Author: wolthomCreated Aug 20, 2023Updated Aug 29, 2023

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:

python
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.