Random assignment of subjects
Having built trust from your last work with the agricultural firm, you have been given the task of properly setting up the experiment.
Use your knowledge of best practice experimental design set up to assign the sheep to two even groups of 250 each.
The weights
DataFrame is available for you to use. Additionally, numpy
and pandas
have been imported as np
and pd
respectively.
This exercise is part of the course
Experimental Design in Python
Exercise instructions
- Randomly select 250 subjects from the
weights
DataFrame into a new DataFramegroup1
without replacement. - Put the remaining 250 subjects into
group2
. - Concatenate the descriptive statistics of your two newly created DataFrames.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Randomly assign half
group1_random = weights.____(____, random_state=42, ____)
# Create second assignment
group2_random = weights.____(group1_random.____)
# Compare assignments
compare_df_random = pd.concat([group1_random['weight'].____, group2_random['weight'].____], axis=1)
compare_df_random.columns = ['group1', 'group2']
print(compare_df_random)