VSCODE - PYTHON - Pandas DataFrame - Intellisense doesn't show Attributes/methods of the object

Viewed 5263

After importing Pandas, when creating a pandas dataframe, Intellisense doesn't show the available attributes/methods of the created object.(Image 2, where I try to use the .head() function).

It detects the module pd(pandas) methods without any problem (see Image 1).

I don't have this problem when running a Jupyter Notebook or Jupyter Lab on the browser.

I'm using:

  • Windows 7
  • Python 3.8.3 in a Conda environment.
  • VSCODE 1.46.1
  • Python extension 2020.6.90262
  • Microsoft Language Server
  • Visual Studio Intellicode 1.2.8

IMAGE 1: It uses intellisense to detect the module methods/attributes

IMAGE 1:It uses intellisense to detect the module methods

IMAGE 2: Intellisense doesn't show the pandas object available attributes/methods

IMAGE 2:Intellisense doesn't show the pandas object available attributes

3 Answers

The detection isn't working because IntelliSense has a hard time with pandas (and pandas.read_csv() especially). It works in Jupyter because it's accessing the live data while IntelliSense has to infer everything from the source code statically.

I would advise trying out Pylance as it's the new language server from Microsoft and we have tried to support pandas appropriately. If Pylance doesn't work then try different values for your python.languageServer setting and see which one gives you the best result.

Go to your VS Code explorer and open that folder you are currently working in. This should solve the problem. Or go to file-> Open Folder. You can also open your current working folder by hotkey ctrl + o .

Close but no cigar. In 2021, language servers still often break. I think VS code is a good idea but sometimes they just break things. I use Intellij for work and it is heavier but better in that regard. I'm sure they will get it right eventually but sadly i don't think they are taking it as serious as they should since data scientists are a big part of their costumers and if you create a pandas object you might be working with its methods for a while rather than direct methods off the modules! So it REALLY helps if we can access lets say pandas.DataFrame.groupby for example rather than just things directly after pandas alone. I keep using VS code as I like keeping my browser up and really enjoy the advantages of having an unified place to keep my python, R and notebook code :) We just need to be patient!

Related