- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 19.2k
Description
Pandas version checks
- 
I have checked that this issue has not already been reported. 
- 
I have confirmed this bug exists on the latest version of pandas. 
- 
I have confirmed this bug exists on the main branch of pandas. 
Reproducible Example
import pandas as pd
from io import StringIO
alloc_txt = """User_Id  Date  Allocated_Points  alloc_flag_day
1      466 2025-02-08                560            True
1      469 2025-02-08                560            True"""
red_txt = """User_Id  Date  Deducted_Points  red_flag_day
1         466 2025-02-08              560          True
2         728 2025-02-02              750          True
3         728 2025-02-09              540          True
4         829 2025-04-03              800          True
5         869 2025-04-22             1400          True"""
# Read as if reading a CSV/TSV file
alloc_df = pd.read_csv(StringIO(alloc_txt), delim_whitespace=True)
red_df = pd.read_csv(StringIO(red_txt), delim_whitespace=True)
alloc_df['User_Id'] = alloc_df['User_Id'].astype(int)
red_df['User_Id'] = red_df['User_Id'].astype(int)
# Ensure date is datetime and remove any possible NaT
alloc_df = alloc_df[alloc_df['Date'].notnull()]
red_df = red_df[red_df['Date'].notnull()]
alloc_df['Date'] = pd.to_datetime(alloc_df['Date'])
red_df['Date'] = pd.to_datetime(red_df['Date'])
try:
    one_result = pd.merge_asof(
        alloc_df,
        red_df,
        by='User_Id',
        left_on='Date',
        right_on='Date',
        direction='forward',
        tolerance=pd.Timedelta(days=3),
        suffixes=('_alloc', '_red')
    )
    print("Success!", one_result)
except Exception as ex:
    print("Fails for first row alone:", ex)Issue Description
I am trying to find the users who have redeemed some points within 3 days of allocation. This is a sample data.
Not sure why this fails.
Expected Behavior
Ideally it should return the users who have entries in red_df within 3 days of alloc_df
Installed Versions
INSTALLED VERSIONS
commit                : 4665c10
python                : 3.12.9
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.3.2
numpy                 : 2.2.5
pytz                  : 2025.2
dateutil              : 2.9.0.post0
pip                   : 25.0
Cython                : None
sphinx                : None
IPython               : 8.30.0
adbc-driver-postgresql: None
adbc-driver-sqlite    : None
bs4                   : 4.12.3
blosc                 : None
bottleneck            : None
dataframe-api-compat  : None
fastparquet           : None
fsspec                : None
html5lib              : None
hypothesis            : None
gcsfs                 : None
jinja2                : 3.1.6
lxml.etree            : None
matplotlib            : 3.10.3
numba                 : None
numexpr               : None
odfpy                 : None
openpyxl              : 3.1.5
pandas_gbq            : None
psycopg2              : None
pymysql               : None
pyarrow               : None
pyreadstat            : None
pytest                : None
python-calamine       : None
pyxlsb                : None
s3fs                  : None
scipy                 : None
sqlalchemy            : 2.0.40
tables                : None
tabulate              : 0.9.0
xarray                : None
xlrd                  : None
xlsxwriter            : None
zstandard             : 0.23.0
tzdata                : 2025.2
qtpy                  : 2.4.1
pyqt5                 : None