Skip to content

Commit 0ce5571

Browse files
committed
implemented pyarrow timestamp support
1 parent b64f438 commit 0ce5571

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/core/algorithms.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
)
6060
from pandas.core.dtypes.concat import concat_compat
6161
from pandas.core.dtypes.dtypes import (
62+
ArrowDtype,
6263
BaseMaskedDtype,
6364
CategoricalDtype,
6465
ExtensionDtype,
@@ -78,6 +79,7 @@
7879
na_value_for_dtype,
7980
)
8081

82+
from pandas._libs.tslibs.timestamps import Timestamp
8183
from pandas.core.array_algos.take import take_nd
8284
from pandas.core.construction import (
8385
array as pd_array,
@@ -1691,6 +1693,14 @@ def map_array(
16911693
if na_action == "ignore":
16921694
mapper = mapper[mapper.index.notna()]
16931695

1696+
if isinstance(arr.dtype, ArrowDtype) and arr.dtype.name.startswith("timestamp"):
1697+
try:
1698+
# Convert elements to pandas.Timestamp (or datetime64[ns]) for dict lookup
1699+
arr = arr.astype("datetime64[ns]")
1700+
except Exception:
1701+
# fallback: safe, slow path
1702+
arr = np.array([Timestamp(x.as_py()) for x in arr])
1703+
16941704
# Since values were input this means we came from either
16951705
# a dict or a series and mapper should be an index
16961706
indexer = mapper.index.get_indexer(arr)

0 commit comments

Comments
 (0)