Closed
Description
Describe the bug
pd.isna
does not support np.datetime64
and np.timedelta64
input types.
To Reproduce
from __future__ import annotations
import datetime as dt
from typing import TypeVar
import numpy as np
import pandas as pd
TV_TD = TypeVar('TV_TD', dt.datetime, np.datetime64, dt.timedelta, np.timedelta64)
def test_isna(value: TV_TD) -> bool:
return pd.isna(value)
mypy
output:
error: No overload variant of "isna" matches argument type "datetime64" [call-overload]
note: Possible overload variants:
note: def isna(obj: DataFrame) -> DataFrame
note: def isna(obj: Series[Any]) -> Series[bool]
note: def isna(obj: Union[Index, List[Any], Union[ExtensionArray, ndarray[Any, Any]]]) -> ndarray[Any, dtype[bool_]]
note: def isna(obj: Union[Union[Union[str, bytes, date, datetime, timedelta, bool, int, float, Timestamp, Timedelta], complex], NaTType, NAType, None]) -> TypeGuard[Union[NaTType, NAType, None]]
error: No overload variant of "isna" matches argument type "timedelta64" [call-overload]
Found 2 errors in 1 file (checked 1 source file)
Please complete the following information:
- OS: MacOS
- OS 12.6.3
- python: 3.8.0
- mypy: 1.0.1
- version of installed
pandas-stubs
: 1.5.3.230214
Additional context
The problem seems to be that the IndexIterScalar
TypeAlias does not include np.datetime64
and np.timedelta64
. The test_isna
test case is also missing tests for np.datetime64
and np.timedelta64
input. PR with a fix here
Metadata
Metadata
Assignees
Labels
No labels