Skip to content

Commit

Permalink
fix(dspy): use DataFrame.applymap in older pandas
Browse files Browse the repository at this point in the history
  • Loading branch information
maxfriedrich authored Mar 13, 2024
1 parent 2d845de commit e53fcbe
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dspy/evaluate/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ def wrapped_program(example_idx, example):
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 object
assert callable(metric)
Expand Down

0 comments on commit e53fcbe

Please sign in to comment.