-
Notifications
You must be signed in to change notification settings - Fork 299
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
No autocomplete for pandas column name in Jupyter notebook using bracket notation ['col'] #8983
Comments
@natwille1 I repro the same. We have . completion after the column is name is completed but no autocompletion for the name itself when typing it as df['column_name']. We do have auto complete for just df.column_name, but that doesn't look like what you are looking for here: |
Hi Ian, thanks for quick response - I do not get autocomplete for df['test'] in a jupyter notebook, but it appears autocomplete in a juypter notebook isn't working for me in general (another issue). I do get completion when using .column_name in a jupyter notebook in vscode, but it's quite slow (takes a few seconds).. what language server do you use? I also do not get any autocompletion using either method when using the interactive feature of executing jupyter code cells in a python file in vscode On a side note, I never had problems with autocompletion for the df['test'] or df.test methods in Atom with Hydrogen.. (also inline, interactive cell execution) Thanks |
I have my language server set to pylance. Pylance should be using the python interpreter that you have selected for the current workspace so there could be an issue here if the kernel you have selected doesn't line up with the currently selected python interpreter. For the interactive inline execution were you looking for completions in the .py file itself? Or in the input box of the interactive window? If the completions of both types are missing in the .py file that would be an issue that we might have to transfer to the pylance team to investigate. |
Okay, my settings for python language server are "Default" which should use pylance given I have the extension installed. How can I check that the kernel and the selected python interpreter match? I use conda and select a specific environment for a specific project in the dropdown menu in the top right hand corner of the jupyter notebook. For interactive inline execution, I do not see any completions in the jupyter code cell in the .py file, but I do get the df.column_name completion in the input box of the interactive window. Thanks |
Interesting - I never see this. What could be the factors affecting this behaviour? I can think of language server but I think we're also using pylance? Anything else? |
@natwille1 Could you take a look at the Python Language Service section of the output window? When that starts up Pylance there is some logging about the interpreter that is being used, as well as any possible errors. Here is an example from my machine:
|
Yep mine looks the same as yours.. :/ [Info - 09:53:47] (20496) Pylance language server 2022.2.3 (pyright 9b0ea9eb) starting |
@natwille1 My apologies. I think I need to back up a second to make sure that I'm looking at your specific scenario. Do you mind if I back up for a second and restate? From your comments (all of this is referring to inside of VS Code):
Is that the right summary? I've looking at these scenarios and I think that I repro basically the same as you do. I think that I understand why most of the differences are happening, but I agree that there is some confusion about why things are seen in some scenarios and not others.
|
Sounds good I wasn't seeing the [''] syntax in my Jupyter install but it was having a bunch of auto complete issues in general. I'm going to leave this issue open for supporting the bracket syntax, and I'm going to file a new issue to look at if we want to consider adding Jupyter completions into .py files when using the interactive window so we can track those issues separately. |
Correct description and thanks for outlining why and creating a new issue around this - looking forward to seeing any new support for these features! |
In relation to this open issue, Jupyter Notebooks are also able to tab autocomplete files that are in the same working directory as the open notebook. For example, if the file The Jupyter Notebook extension in VS Code does not replicate this behavior. |
Internal notes for the team to discuss I think we should revert the change that fixed #7136 My suggestion is to first unblock the users) then look into a long term proper fix. |
We could change this so that:
|
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: 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: 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 I'm going to add a setting to enable more precise intellisense. With a warning that this makes everything potentially slower. |
Verification steps:
"jupyter.enableExtendedKernelCompletions": true
|
That's by design. Jupyter isn't smart enough to filter them out. |
The verification would be that the column names do show up in that list. It looks like you had 'test' and 'test2'? They did show up? |
@rchiodo it works well but still reproduces with |
@rebornix can you explain what you mean by still reproduces? I have that setting enabled and it works for me: |
@rchiodo I was not seeing |
This does not work, or at least is very unstable. Sometimes, it works in the editor but not the interactive window, and sometimes the other way around. Very often... Neither dot nor brackets notion works at all. |
Environment data
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]
df = pd.DataFrame({'test': [1,2], 'test2': [2,3]})
df['test']
Logs
Output for
Jupyter
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toJupyter
)The text was updated successfully, but these errors were encountered: