skip to Main Content

VS Code 1.41.1

python3-pandas 0.23.3

Debian buster (10)

I cannot get definitions of pandas functions in VS Code. Definitions for all other python3 packages are available though. Here is a MWE:

import pandas
import quandl
df = quandl.get("WIKI/GOOGL")
df.fillna(value=-99999, inplace=True)

The definition for quandl.get() is available but not the one for df.fillna(). Definitions for functions and classes of other python3 modules are available as well. BTW pandas-doc is not available with pip and pip3 but I have it installed from the python repositories (python-pandas-doc). Any idea how this can be fixed?

2

Answers


  1. I strongly suggest you create a virtual environment to work with vscode. Here are the steps I take to create it on Windows 10:

    1. Make sure you have python 3.x in your local machine
      Install virtualenv (pip install virtualenv)
    2. At the root folder of you project, create a virtual environment (virtualenv -p "path_to_python.exe" .venv)
      • vscode should detect this virtual env automatically, otherwise restart vscode
      • vscode should be able to activate .venv when you open a new terminal window, otherwise check for errors
      • you can activate the virtual env manually running .venvbinactivate.ps1 or if you are using Linux source .venv/bin/activate
    3. Create a requirements.txt file with your dependencies:
      [Edit]: it’s key to define proper version for you deps, otherwise you will have to dig wich version is being installed by pip.
    pandas=>0.25.3,<0.26
    quandl==3.4.8
    ...
    
    1. With the virtual env activated in a terminal window, install the dependencies pip install -r requirements.txt (add --no-deps if you just want code completion and you will not run the code locally)

    When the installation is don, you should be able so use all code-completion features in vscode.

    Login or Signup to reply.
  2. I met the same problem: there is a sample:

    import matplotlib.pyplot as plt
    
    fig = plt.figure()
    
    ax = fig.add_subplot(111, projection='3d')
    

    VScode can find the definition of the figure() but failed to find the definition of add_subplot.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search