Python-language-server: Improve intellisense for common pandas functions

Created on 7 Nov 2018  路  6Comments  路  Source: microsoft/python-language-server

While pandas does not currently have type definitions, there are a handful of very common pandas methods/patterns that should be easy to provide our own definitions for.

Some examples, read_csv typically returns a data frame:

import pandas as pd
df = pd.read_csv('survey2017.csv')
df. # no intellisense, df should be DataFrame

The loc and iloc properties on a DataFrame are also missing, I think they typically return pandas.core.series.Series.

Similarly the index operator of a DataFrame returns a series if it's argument is a single value, e.g.

type(summary['percent'])
pandas.core.series.Series

If input is a series or a list of values it will return a dataframe:

type(summary[['percent', 'count']])
pandas.core.frame.DataFrame

type(summary[summary['percent'] > 0.1])
pandas.core.frame.DataFrame

A handful of such definitions would make IntelliSense for pandas much more useful for the most common use cases.

intellisense

Most helpful comment

image

All 6 comments

I have the same issue, and intellisense doesn't seem to have lots of methods indexed with Python. Some basic pandas methods and attributes, like .value_counts() and .columns, never show up. Besides, intellsense doesn't seem to index the column name in a pandas DataFrame either since I never got any suggestion. I wish it could be improved and work like the autocompletion in Jupyter lab.

jupyter

image

I assume that's in a future PR? (Since I can't make that show up against master.)

Yes
image

Pandas autocomplete is very slow. Is this expected? (2019.5.18875)

Please file a new issue with your language server version and a code sample (and hopefully an explanation of what's slow), this one is very old and applies to not having completion on DataFrames at all. https://github.com/microsoft/python-language-server/blob/master/TROUBLESHOOTING.md#filing-an-issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jakebailey picture jakebailey  路  6Comments

luanft picture luanft  路  3Comments

jakebailey picture jakebailey  路  4Comments

jakebailey picture jakebailey  路  4Comments

rsalunga29 picture rsalunga29  路  5Comments