I have not found stubs for pandas yet, however someone created some for NumPy: https://github.com/machinalis/mypy-data/tree/master/numpy-mypy
One intermediate option may be to define a custom type according to how mypy sees pandas objects. When I wrap the DataFrame object in reveal_type(df)
and run mypy, it shows that the recognized signature is of type Union[builtins.dict[Union[builtins.str, builtins.int], builtins.dict[Any, Any]], Any]
. However, it shows the same for the Series object, so it is not very accurate.
Geoff source share