question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No autocomplete for pandas column name in Jupyter notebook using bracket notation ['col']

See original GitHub issue

Environment data

  • VS Code version: 1.64.00
  • Jupyter Extension version (available under the Extensions sidebar): v2022.1.1001821375
  • Python Extension version (available under the Extensions sidebar): v2022.0.1814523869
  • OS (Windows | Mac | Linux distro) and version: Windows 10
  • Python and/or Anaconda version: python 3.8.12
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
  • Jupyter server running: Local

Expected behaviour

Autocomplete works for pandas dataframes in jupyter notebooks.

Actual behaviour

Autocomplete does not work. Users have to manually type the column names every time. It even doesn’t work when I’ve manually specified the column name several times. I’ve tried all the language servers, including Jedi, Pylance, and the default option. No autocomplete.

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Create pandas dataframe

df = pd.DataFrame({'test': [1,2], 'test2': [2,3]})

  1. Call dataframe variable and check if autocomplete works for the columns

df['test']

autocomplete_fail

Logs

Output for Jupyter in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Jupyter)

XXX

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:25 (16 by maintainers)

github_iconTop GitHub Comments

5reactions
rchiodocommented, Feb 18, 2022

I can get completions to work in a jupyter notebook (outside of VS code) and it does support the df.['column_name'] syntax:

image

(Jupyter brings up completions on the ‘tab’ key)

So it would seem like we could implement this.

3reactions
rchiodocommented, May 25, 2022

Not super happy with this. Jupyter completions suck.

This is the result I get if I ‘fix’ this and put it back how it was:

image

As you can see it’s listing out every possible match for the letter ‘a’. Not just columns. Jupyter isn’t filtering anything.

Jupyter notebook is more precise though. It gives me this:

image

And the difference is in our use of Jedi. We disable this because of perf problems with Jedi in a kernel. If I reenable it, our completions come out the same as Jupyter

image

(after typing a) image

I’m going to add a setting to enable more precise intellisense. With a warning that this makes everything potentially slower.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use the brackets to select a single pandas DataFrame column ...
Use the brackets to select a single column from a pandas DataFrame and not dot notation. It is a single method that works...
Read more >
Problem with autocompletion with Pandas in Jupyter
if col contains string values like 'abc', 'def' or in other words, it's type is object, then df.col.str.mat + tab will work. But...
Read more >
How to enable auto-completion in Jupyter Notebook
Simply hit the “Tab” key while writing code. This will open a menu with suggestions.
Read more >
Should you use "dot notation" or "bracket notation" with pandas?
There are two ways to select a Series from a DataFrame: "dot notation" and "bracket notation" (square brackets). Find out which one you ......
Read more >
Autocomplete dataframe columns names not working in jupyter
Hi there, julia newbie here, switching from python :). I am using jupyter and dataframe package. Please, is there a way how to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found