Skip to content

Commit

Permalink
feat: reindex conditions in random sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
younesStrittmatter committed Jul 23, 2024
1 parent 45e4b42 commit cc92c4d
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 cc92c4d

Please sign in to comment.