IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Experimental Design in Python

Visualizza il corso

Istruzioni dell'esercizio

  • Randomly select 250 subjects from the weights DataFrame into a new DataFrame group1 without replacement.
  • Put the remaining 250 subjects into group2.
  • Concatenate the descriptive statistics of your two newly created DataFrames.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# 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)
Modifica ed esegui il codice