Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reindex conditions in random sampling #76

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading