Pycharm type checker - expected Series, got int

≡放荡痞女 提交于 2021-02-19 16:35:38

问题


I have very simple Python function that subtracts scalar value from pandas Series:

def sub(x: pd.Series, a: int) -> pd.Series:
    return x - a

It works as expected. I'm using type hints to enable type checker directly in my PyCharm IDE. The issue here is I get this warning message:

Expected type 'Series', got 'int' instead

As you can see in the image below:

I understand that Python is dynamically typed language so in some cases type checking with type hints has its own limitations. But this sounds as a clear case to me. Do you know how to deal with it? Or am I missing something in my simple code?

(I am using Python 3.8.2, PyCharm 2020.1 - Professional Edition)

来源:https://stackoverflow.com/questions/60726641/pycharm-type-checker-expected-series-got-int

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!