Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with autocompletion with Pandas in Jupyter

I am having a problem similar to this user: when calling autocomplete on df.col., I get no autocompletion even after evaluating a cell containing only df.col. For instance, I'd like to see df.col.str.matc to autocomplete to df.col.str.match. What can I do to solve this?

Take as example the following dataframe:

import pandas as pd
data = [['Alex in FL','ten'],['Bob in FLORIDA','five'],['Will in GA','three']]
df = pd.DataFrame(data,columns=['Name','Age'])

#Dataframe:
    Name             Age
0   Alex in FL       ten
1   Bob in FLORIDA   five
2   Will in GA       three

#Command that should autocomplete (but does not):
df.Name.str.matc [+TAB]

I do not want to try hinterland since I only want autocomplete upon pressing tab.

Thanks a lot in advance!

like image 518
Sos Avatar asked Oct 08 '19 07:10

Sos


People also ask

Does Jupyter support code autocompletion?

Enable autocomplete featureTo enable code autocomplete in Jupyter Notebook or JupyterLab, you just need to hit the Tab key while writing code. Jupyter will suggest a few completion options. Navigate to the one you want with the arrow keys, and hit Enter to choose the suggestion.

Does Jupyter Notebook support Pandas?

In JupyterLab, create a new (Python 3) notebook: In the first cell of the notebook, you can import pandas and check the version with: Now you are ready to use pandas, and you can write your code in the next cells.


1 Answers

After reading this, it seems that this problem is faced by other people and with specific version of ipython. The solution is also given on that link.

It is like this:

Run below command from the terminal:

ipython profile create

It will create a default profile at ~/.ipython/profile_default/ipython_config.py

Now edit this ipython_config.py and add the below lines and it will solve the issue.

c = get_config()
c.Completer.use_jedi = False

Reference:

  1. https://github.com/jupyter/notebook/issues/2435
  2. https://ipython.readthedocs.io/en/stable/config/intro.html
like image 162
vb_rises Avatar answered Sep 21 '22 09:09

vb_rises