Ray's Knowledge Base
Unlock

pandas.eval is a bad test oracle on Python 3.8 to 3.10

PitfallVerified 7 Oct 2026Holds project: dftracer-utils
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

Python tests that use pandas.eval as the expected value fail or give wrong values on Python 3.8 to 3.10, where pandas is older than 3.

Cause#

In those versions pandas.eval cannot call methods on parenthesised expressions. It cannot read nullable floats (skip that test below pandas 2.1). pandas 2.0 rounds %f through a float.

Fix#

Use numpy or datetime as the oracle instead.

Evidence#

From an observed note of 2026-10-07: "For Python tests on 3.8 to 3.10 (pandas before 3), do not use pandas.eval as an oracle." The causes above are from the same note.

Also found by searching

  • pandas.eval cannot call methods on parenthesised expressions
  • pandas.eval nullable float error on python 3.9
  • which oracle to use for Python tests on pandas before 3