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

后端 未结 2 1739
滥情空心
滥情空心 2021-02-20 01:04

My function returns a pandas series, where all elements have a specific type (say str). The following MWE should give an impression:

import pandas as         


        
2条回答
  •  迷失自我
    2021-02-20 01:41

    Unfortunately Python's type hinting does not support this out of the shelf. Nonetheless, you can always make use of dataenforce library (link) to add hints or even enforce validation.

提交回复
热议问题