เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

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.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Experimental Design in Python

ดูคอร์ส

คำแนะนำการฝึกหัด

  • 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.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# 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)
แก้ไขและรันโค้ด