Skip to content

Commit 9b95c20

Browse files
committed
Add data exporting section to the first tutorial
1 parent 78d4def commit 9b95c20

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/source/tutorial/tutorial.Learner1D.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,26 @@ adaptive.runner.simple(learner_2, goal=npoints_goal)
202202

203203
More info about using custom loss functions can be found in {ref}`Custom adaptive logic for 1D and 2D`.
204204

205+
## Exporting the data
206+
207+
We can view the raw data by looking at the dictionary `learner.data`.
208+
Alternatively, we can view the data as NumPy array with
209+
210+
```{code-cell} ipython3
211+
learner.to_numpy()
212+
```
213+
214+
If Pandas is installed (optional dependency), you can also run
215+
```{code-cell} ipython3
216+
df = learner.to_dataframe()
217+
df
218+
```
219+
220+
and load that data into a new learner with
221+
```{code-cell} ipython3
222+
new_learner = adaptive.Learner1D(sin_exp, (-1, 1)) # create an empty learner
223+
new_learner.load_dataframe(df) # load the pandas.DataFrame's data
224+
new_learner.plot()
225+
```
226+
205227
[^download]: This notebook can be downloaded as **{nb-download}`tutorial.Learner1D.ipynb`** and {download}`tutorial.Learner1D.md`.

0 commit comments

Comments
 (0)