Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtruong committed Jan 13, 2025
1 parent 233ea1d commit bb3b9a6
Showing 1 changed file with 40 additions and 14 deletions.
54 changes: 40 additions & 14 deletions docs/docs/guides/core-types/datasets.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,51 @@ This guide will show you how to:

<Tabs groupId="programming-language" queryString>
<TabItem value="python" label="Python" default>
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.
<Tabs groupId="use-case">
<TabItem value="from-calls" label="From Calls">
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.
```
</TabItem>

<TabItem value="from-pandas" label="From Pandas">
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)
```

</TabItem>

</Tabs>

</TabItem>
<TabItem value="typescript" label="TypeScript">

```typescript
This feature is not available in TypeScript yet. Stay tuned!
```

```typescript
This feature is not available in TypeScript yet. Stay tuned!
```

</TabItem>
</Tabs>

0 comments on commit bb3b9a6

Please sign in to comment.