Skip to content
Latchkey

Python "pandas FutureWarning treated as error" in CI

pandas emits FutureWarning for APIs scheduled to change. With filterwarnings = error, pytest turns that warning into a failure, so an upgraded pandas can break previously-green tests without any code change.

What this error means

A test fails with "FutureWarning: ... is deprecated and will be removed in a future version. Use ... instead." raised as an error from a pandas call.

pytest
FutureWarning: DataFrame.applymap has been deprecated. Use DataFrame.map instead.

Common causes

A deprecated pandas API in use

Code calls a method or pattern pandas has marked for removal, so it warns.

A pandas upgrade newly emitting the warning

A version bump added the FutureWarning to an API that was silent before.

How to fix it

Migrate to the recommended API

  1. Read the warning to find the replacement API and update the call.
  2. If a migration is blocked, scope a targeted filterwarnings ignore for that specific warning rather than disabling all.
  3. Pin pandas if you need to defer the migration deliberately.
Python
# replace deprecated applymap with map
result = df.map(func)

How to prevent it

  • Keep up with pandas deprecations as you upgrade.
  • Scope warning ignores narrowly, never globally.
  • Pin pandas to control when new warnings appear.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →