DSPy: The framework for programming—not prompting—language models
Python
fix(dspy): use DataFrame.applymap in older pandas
Max Friedriche53fcbe8953e
diff --git a/dspy/evaluate/evaluate.py b/dspy/evaluate/evaluate.pyindex 486e4b68e..603b552aa 100644--- a/dspy/evaluate/evaluate.py+++ b/dspy/evaluate/evaluate.py@@ -184,7 +184,10 @@ class Evaluate:df = pd.DataFrame(data)# Truncate every cell in the DataFrame- df = df.map(truncate_cell)+ if hasattr(df, "map"): # DataFrame.applymap was renamed to DataFrame.map in Pandas 2.1.0+ df = df.map(truncate_cell)+ else:+ df = df.applymap(truncate_cell)# Rename the 'correct' column to the name of the metric objectassert callable(metric)