You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If cond is callable, it is computed on the Series/DataFrame and should return boolean Series/DataFrame or array. The callable must not change input Series/DataFrame (though pandas doesn’t check it).
To Reproduce
Minimally runnable pandas example that is not properly checked by the stubs:
Show the error message received from that type checker while checking your example.
(.venv) ➜ python -m mypy test.py
test.py:2: error: Argument "cond" to "mask" of "DataFrame" has incompatible type "Callable[[Any], Any]"; expected "Series[Any] | DataFrame | ndarray[Any, Any]" [arg-type]
Found 1 error in 1 file (checked 1 source file)
Please complete the following information:
OS: MacOS
OS Version: Sonoma 14.2.1
python version: Python 3.10.14
version of type checker: 1.10.0
version of installed pandas-stubs: 2.2.1.240316
Additional context
I've also tried using typing.cast to cast the lambda into Callable[[DataFrame], DataFrame], but it doesn't work, as expected. Happy to provide more details if needed.
The text was updated successfully, but these errors were encountered:
Describe the bug
The
cond
argument of theDataFrame.mask
method currently doesn't expect a callable, even though it should, according to the method's documentation page:To Reproduce
pandas
example that is not properly checked by the stubs:Type checker:
mypy
Show the error message received from that type checker while checking your example.
Please complete the following information:
pandas-stubs
: 2.2.1.240316Additional context
I've also tried using
typing.cast
to cast the lambda intoCallable[[DataFrame], DataFrame]
, but it doesn't work, as expected. Happy to provide more details if needed.The text was updated successfully, but these errors were encountered: