Skip to content

Commit

Permalink
Merge pull request stanfordnlp#643 from maxfriedrich/patch-1
Browse files Browse the repository at this point in the history
fix(dspy): use DataFrame.applymap in older pandas
  • Loading branch information
detaos authored Mar 13, 2024
2 parents 2d845de + e53fcbe commit 65551ef
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 65551ef

Please sign in to comment.