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

df = pd.DataFrame({'a': pd.to_datetime(pd.Series(['2020-01-01']))})
df['b'] = df['a'].convert_dtypes(dtype_backend='pyarrow')
print(df['b'] < df['a'])

Issue Description

Should the above be supported? it currently raises

Expected Behavior

i think

0    False
dtype: bool[pyarrow]

Installed Versions

INSTALLED VERSIONS ------------------ commit : 0691c5cf90477d3503834d983f69350f250a6ff7 python : 3.12.6 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 : C.UTF-8 pandas : 2.2.3 numpy : 2.2.3 pytz : 2025.1 dateutil : 2.9.0.post0 pip : None Cython : None sphinx : None IPython : 8.31.0 adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : None blosc : None bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : 2025.2.0 html5lib : None hypothesis : 6.125.2 gcsfs : None jinja2 : 3.1.5 lxml.etree : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None psycopg2 : None pymysql : None pyarrow : 19.0.0 pyreadstat : None pytest : 8.3.4 python-calamine : None pyxlsb : None s3fs : None scipy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None xlsxwriter : None zstandard : None tzdata : 2025.1 qtpy : None pyqt5 : None

Comment From: abhigyan631

I think this fix can be used

import pandas as pd

df = pd.DataFrame({'a': pd.to_datetime(pd.Series(['2020-01-01']))})

df['b'] = df['a'].convert_dtypes(dtype_backend='pyarrow')

df['b'] = df['b'].astype('datetime64[ns]') # Convert 'b' back to datetime64[ns]

print(df['b'] < df['a'])

We need to convert the PyArrow-backed column (df['b']) back to a NumPy-backed datetime64[ns] type before performing the comparison to get the expected result.

Comment From: rhshadrach

I think the discussion in #60639 implies that yes, this should be supported.