How to specify the type of pandas series elements in type hints?

For python 3.8 try:

def f() -> "pd.Series[str]":
    pass

or:

f_return_type = "pd.Series[str]"
def f() -> f_return_type:
    pass

or # type: pd.Series[str] for variables

Leave a Comment