Last active
January 16, 2022 18:38
-
-
Save alexkyllo/9b57f0b25d3dde1fa03a9a3e12ccb666 to your computer and use it in GitHub Desktop.
Debugging in the middle of a pandas method chain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Example of how to open a debugger anywhere in the middle of a pandas method chain.""" | |
import numpy as np | |
import seaborn as sns | |
from IPython.core.debugger import Pdb | |
df = sns.load_dataset("iris") | |
df = ( | |
df.assign(sepal_ratio=lambda x: np.divide(x["sepal_width"], x["sepal_length"])) | |
.pipe(lambda x: Pdb().set_trace()) # Opens the debugger, the dataframe is assigned to `x` | |
.assign(petal_ratio=lambda x: np.divide(x["petal_width"], x["petal_length"])) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment