Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set IntelliJ/Pycharm to handle pandas "Unresolved references" warning

Whenever I try to access a non-method attribute of a Series or DataFrame (such as columns or loc), IntelliJ throws me an "unresolved reference" warning which doesn't crash my code, but is fairly annoying to see. I'd rather not disable this inspection, and I'd like to avoid peppering my code with suppressions.

I've set the "Collect run-time types information for code insight" option of the debugger, but this didn't work. I've also tried adding references to ignore in the "Ignore References" list in the Inspections tab, but nothing I tried seemed to work.

The warning I get will be something like Cannot find reference loc in 'Series | Series'.

like image 364
James Kelleher Avatar asked Mar 31 '16 20:03

James Kelleher


1 Answers

One thing that works for me when PyCharm's autocomplete is having trouble figuring out my variable type is type hinting. It happens rarely enough that I (thankfully) don't have to do it that often.

df = pd.DataFrame()  # type: pd.DataFrame

More info on typing can be found here: What are Type hints in Python 3.5

like image 66
Alex C. Avatar answered Oct 05 '22 02:10

Alex C.