Skip to content

Commit

Permalink
Merge pull request #76 from AutoResearch/75-reset-condition-index-aft…
Browse files Browse the repository at this point in the history
…er-random-sampling

feat: reindex conditions in random sampling
  • Loading branch information
younesStrittmatter authored Jul 25, 2024
2 parents 06d52f6 + cc92c4d commit c72b556
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/autora/experimentalist/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,25 +157,29 @@ def sample(
>>> import pandas as pd
>>> sample(
... pd.DataFrame({"x": range(100, 200)}), num_samples=5, random_state=180)
x
67 167
71 171
64 164
63 163
96 196
x
0 167
1 171
2 164
3 163
4 196
From a list (returns a DataFrame):
>>> sample(range(1000), num_samples=5, random_state=180)
0
270 270
908 908
109 109
331 331
978 978
0
0 270
1 908
2 109
3 331
4 978
"""
conditions_ = pd.DataFrame(conditions)
return pd.DataFrame.sample(
conditions_, random_state=random_state, n=num_samples, replace=replace
conditions_,
random_state=random_state,
n=num_samples,
replace=replace,
ignore_index=True,
)


Expand Down

0 comments on commit c72b556

Please sign in to comment.