Debugging in Jupyter
The previous recipes have shown how to understand pandas code and inspect it from Jupyter. In this section, we will look at using the IPython debugger (ipdb) in Jupyter.
In this section, I will create a function that throws an error when I try to use it with the series .apply
method. I will use ipdb to debug it.
How to do it…
- Load the survey data:
>>> import zipfile >>> url = 'data/kaggle-survey-2018.zip' >>> with zipfile.ZipFile(url) as z: ... kag = pd.read_csv(z.open('multipleChoiceResponses.csv')) ... df = kag.iloc[1:]
- Try and run a function to add one to a series:
>>> def add1(x): ... return x + 1 >>> df.Q3.apply(add1) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-9-6ce28d2fea57> in <module> ...