-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Spacy import breaks pandas output in jupyter #3208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is very mysterious. I had a look and it seems like this has also been reported in jupyter/notebook#4369 and fastai/fastai#1531. What's especially confusing is that the error occurs here and is a result of IPython's spaCy itself doesn't interact with pandas at all, and it doesn't interact with IPython in the global scope either. So one possible explanation I can think of is that spaCy imports a dependency that does something like this? I'll try to reproduce the problem and see if I can track this down. Edit 1: Okay, I can reproduce this. I also checked the diff for the latest pandas version and it shows that this function was introduced there in the latest version. Edit 2: We do check whether we're in a Jupyter notebook in the global scope, which would be executed when you import spaCy. Edit 3: Not accessing the config properties within Here's a minimal reproducible example without spaCy: # In[1]:
import pandas as pd
df = pd.DataFrame()
df
# In[2]:
cfg = get_ipython().config
cfg['IPKernelApp']['parent_appname']
df We can issue a quick fix that changes the way we check for a notebook in displaCy, and also uses the new and actually correct way we already have on Edit 4: Here's a minimal reproducible example without spaCy or pandas: # In[1]:
def test():
ip = get_ipython()
test = (ip.config.get('KernelApp', {}).get('parent_appname', "") or ip.config.get('IPKernelApp', {}).get('parent_appname', ""))
test.lower()
# In[2]:
test()
# In[3]:
cfg = get_ipython().config
cfg['IPKernelApp']['parent_appname']
# In[4]:
test() |
Prevent interactions with other libraries (pandas) that also access get_ipython().config and its parameters
This will be resolved in the next update of pandas and we'll also be issuing a workaround for spaCy. If you're interested, see here for some background on the problem: pandas-dev/pandas#25036 |
Resolves #3208. Prevent interactions with other libraries (pandas) that also access `get_ipython().config` and its parameters. See #3208 for details. I don't fully understand why this happens, but in spaCy, we can at least make sure we avoid calling into this method. <!--- Provide a general summary of your changes in the title. --> ## Description <!--- Use this section to describe your changes. If your changes required testing, include information about the testing environment and the tests you ran. If your test fixes a bug reported in an issue, don't forget to include the issue number. If your PR is still a work in progress, that's totally fine – just include a note to let us know. --> ### Types of change <!-- What type of change does your PR cover? Is it a bug fix, an enhancement or new feature, or a change to the documentation? --> ## Checklist <!--- Before you submit the PR, go over this checklist and make sure you can tick off all the boxes. [] -> [x] --> - [x] I have submitted the spaCy Contributor Agreement. - [x] I ran the tests, and all new and existing tests passed. - [x] My changes don't require a change to the documentation, or if they do, I've added all required information.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
How to reproduce the behaviour
Your Environment
Notes
This only affects pandas 0.24.0 (0.23.4 works fine). Functions like
.head()
are also affected.Exception details:
The text was updated successfully, but these errors were encountered: