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.
Deze oefening maakt deel uit van de cursus
Experimental Design in Python
Oefeninstructies
- Randomly select 250 subjects from the
weightsDataFrame into a new DataFramegroup1without replacement. - Put the remaining 250 subjects into
group2. - Concatenate the descriptive statistics of your two newly created DataFrames.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# 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)