Pandas version checks

  • [x] I have checked that this issue has not already been reported.

  • [x] I have confirmed this bug exists on the latest version of pandas.

  • [x] I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

Here are my reproduction steps that does not work with PyArrow type:

df = pd.DataFrame({"a": pd.date_range("2018-01-01 00:00:00", "2018-01-07 00:00:00")}).astype({"a": "timestamp[ns][pyarrow]"})
date2pos = {date: i for i, date in enumerate(df['a'])}
df["a"].map(date2pos)


0   NaN
1   NaN
2   NaN
3   NaN
4   NaN
5   NaN
6   NaN
Name: a, dtype: float64

Issue Description

For some reason pd.DataFrame.map() function does not work with PyArrow timestamp[ns][pyarrow] type and does not map values.

Expected Behavior

Here is an expected behavior that works with the default pandas type datetime64[ns]:

df = pd.DataFrame({"a": pd.date_range("2018-01-01 00:00:00", "2018-01-07 00:00:00")})
date2pos = {date: i for i, date in enumerate(df['a'])}
df["a"].map(date2pos)
0    0
1    1
2    2
3    3
4    4
5    5
6    6
Name: a, dtype: int64

Installed Versions

INSTALLED VERSIONS ------------------ commit : 0691c5cf90477d3503834d983f69350f250a6ff7 python : 3.11.7 python-bits : 64 OS : Linux OS-release : 5.15.167.4-microsoft-standard-WSL2 Version : #1 SMP Tue Nov 5 00:21:55 UTC 2024 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : C.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.2.3 numpy : 1.26.3 pytz : 2025.1 dateutil : 2.8.2 pip : 23.2.1 Cython : None sphinx : None IPython : 8.20.0 adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 blosc : None bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : 2023.12.2 html5lib : None hypothesis : None gcsfs : 2023.12.2post1 jinja2 : 3.1.3 lxml.etree : None matplotlib : 3.8.2 numba : 0.60.0 numexpr : None odfpy : None openpyxl : 3.1.2 pandas_gbq : None psycopg2 : None pymysql : None pyarrow : 14.0.2 pyreadstat : None pytest : 7.4.4 python-calamine : None pyxlsb : None s3fs : 2023.12.2 scipy : 1.12.0 sqlalchemy : 2.0.29 tables : None tabulate : 0.9.0 xarray : None xlrd : None xlsxwriter : None zstandard : None tzdata : 2023.4 qtpy : None pyqt5 : None

Comment From: snitish

Thanks for reporting. Confirmed on main. Investigations and PRs to fix are welcome.

Comment From: arthurlw

take

Comment From: KevsterAmp

take