to_dataframe() — langchain Function Reference
Architecture documentation for the to_dataframe() function in runner_utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD c8c431c9_edb6_7a8a_6dd8_508fa675ba6c["to_dataframe()"] 2faa7d51_38e2_8d63_1f1e_b482b4401e76["TestResult"] c8c431c9_edb6_7a8a_6dd8_508fa675ba6c -->|defined in| 2faa7d51_38e2_8d63_1f1e_b482b4401e76 e45d7c4e_b434_e04f_5d6a_822b3cb84b5a["get_aggregate_feedback()"] e45d7c4e_b434_e04f_5d6a_822b3cb84b5a -->|calls| c8c431c9_edb6_7a8a_6dd8_508fa675ba6c style c8c431c9_edb6_7a8a_6dd8_508fa675ba6c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/smith/evaluation/runner_utils.py lines 104–149
def to_dataframe(self) -> pd.DataFrame:
"""Convert the results to a dataframe."""
try:
import pandas as pd
except ImportError as e:
msg = (
"Pandas is required to convert the results to a dataframe."
" to install pandas, run `pip install pandas`."
)
raise ImportError(msg) from e
indices = []
records = []
for example_id, result in self["results"].items():
feedback = result["feedback"]
output_ = result.get("output")
if isinstance(output_, dict):
output = {f"outputs.{k}": v for k, v in output_.items()}
elif output_ is None:
output = {}
else:
output = {"output": output_}
r = {
**{f"inputs.{k}": v for k, v in result["input"].items()},
**output,
}
if "reference" in result:
if isinstance(result["reference"], dict):
r.update(
{f"reference.{k}": v for k, v in result["reference"].items()},
)
else:
r["reference"] = result["reference"]
r.update(
{
**{f"feedback.{f.key}": f.score for f in feedback},
"error": result.get("Error"),
"execution_time": result["execution_time"],
"run_id": result.get("run_id"),
},
)
records.append(r)
indices.append(example_id)
return pd.DataFrame(records, index=indices)
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does to_dataframe() do?
to_dataframe() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/smith/evaluation/runner_utils.py.
Where is to_dataframe() defined?
to_dataframe() is defined in libs/langchain/langchain_classic/smith/evaluation/runner_utils.py at line 104.
What calls to_dataframe()?
to_dataframe() is called by 1 function(s): get_aggregate_feedback.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free