Skip to content

RDKit PandasPatcher incompatible with pandas 3.0 (applymap removed) #50

@HFooladi

Description

@HFooladi

Problem

When using THEMAP with pandas 3.0.0 and rdkit 2025.09.4, the following warning appears during featurization:

Failed to patch pandas - PandasTools will have limited functionality

This is triggered when get_featurizer() is called (via molfeat's import chain), which imports rdkit.Chem.PandasTools, which in turn imports rdkit.Chem.PandasPatcher.

Root Cause

pandas.DataFrame.applymap was deprecated in pandas 2.1 (renamed to DataFrame.map) and fully removed in pandas 3.0. RDKit 2025.09.4's PandasPatcher.py (line 91) calls pd.DataFrame.applymap unconditionally before the try/except fallback to pd.DataFrame.map:

# rdkit/Chem/PandasPatcher.py (installed version)
dataframe_applymap = pd.DataFrame.applymap       # line 91 — raises AttributeError on pandas 3.0
try:
    if tuple(map(int, (pd.__version__.split(".")))) >= (2, 1, 0):
        dataframe_applymap = pd.DataFrame.map     # line 94 — never reached
except:
    pass

The fix exists on rdkit's master branch (reverses the try/except order), but hasn't been released in a pip-installable rdkit package yet. The latest available version is 2025.09.4.

Impact

  • THEMAP does not use PandasTools directly — the warning is a side-effect of molfeat importing rdkit internals
  • The warning is cosmetic and does not affect THEMAP's distance computation or featurization results
  • May confuse users into thinking something is broken

Environment

  • pandas 3.0.0
  • rdkit 2025.09.4
  • Python 3.11

Options

  1. Pin pandas < 3.0 — avoids the issue but blocks access to pandas 3.0 features and future releases
  2. Suppress the warning — add a warnings.filterwarnings or logging filter to hide it until rdkit releases a fix
  3. Wait for upstream fix — rdkit master already has the fix; wait for next release (2025.09.5+)
  4. Pin pandas < 3.0 temporarily + track upstream rdkit release to unpin later

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions