diff --git a/docs/docs/guides/core-types/datasets.md b/docs/docs/guides/core-types/datasets.md index 3388fd9c425b..eb8741dcd4fa 100644 --- a/docs/docs/guides/core-types/datasets.md +++ b/docs/docs/guides/core-types/datasets.md @@ -73,25 +73,51 @@ This guide will show you how to: - Datasets can also be constructed from common Weave objects like `list[Call]`, which is useful if you want to run an evaluation on a handful of examples. + Datasets can also be constructed from common Weave objects like `Call`s, and popular python objects like `pandas.DataFrame`s. + + + This can be useful if you want to create an example from specific examples. -```python -@weave.op -def model(task: str) -> str: - return f"Now working on {task}" + ```python + @weave.op + def model(task: str) -> str: + return f"Now working on {task}" -res1, call1 = model.call(task="fetch") -res2, call2 = model.call(task="parse") + res1, call1 = model.call(task="fetch") + res2, call2 = model.call(task="parse") -dataset = Dataset.from_calls([call1, call2]) -# Now you can use the dataset to evaluate the model, etc. -``` + dataset = Dataset.from_calls([call1, call2]) + # Now you can use the dataset to evaluate the model, etc. + ``` + + + + You can also freely convert between `Dataset`s and `pandas.DataFrame`s. + + ```python + import pandas as pd + + df = pd.DataFrame([ + {'id': '0', 'sentence': "He no likes ice cream.", 'correction': "He doesn't like ice cream."}, + {'id': '1', 'sentence': "She goed to the store.", 'correction': "She went to the store."}, + {'id': '2', 'sentence': "They plays video games all day.", 'correction': "They play video games all day."} + ]) + dataset = Dataset.from_pandas(df) + df2 = dataset.to_pandas() + + assert df.equals(df2) + ``` + + + + - - ```typescript - This feature is not available in TypeScript yet. Stay tuned! - ``` + +```typescript +This feature is not available in TypeScript yet. Stay tuned! +``` +