Python으로 배우는 실험 설계
James Chapman
Curriculum Manager, DataCamp

X가 Y에 아마 영향을 주었습니다. 작은 오류 위험이 있을 수 있습니다
P-값 분석 결과, X가 Y에 영향을 줌. 제1종 오류 위험 10%
여러 분야에서 유용:





heights DataFrame에 저장 id height
0 0 177.98
1 1 174.17
2 2 178.89
DataFrame 슬라이싱으로 배정
group1_nonrandom = heights.iloc[0:100,:] group2_nonrandom = heights.iloc[100:,:]compare_df = pd.concat( [group1_nonrandom['height'].describe(), group2_nonrandom['height'].describe()], axis=1) compare_df.columns = ['group1', 'group2'] print(compare_df)
group1 group2
count 100.00 100.00
mean 170.32 179.19 <--
std 3.28 3.50
min 159.28 175.03
25% 168.06 176.57
50% 170.75 178.03
75% 173.09 180.79
max 174.92 191.32
.sample() 사용n 또는 frac(0-1 비율)group1 = heights.sample(frac=0.5, replace=False, random_state=42)group2 = heights.drop(group1.index)
print(compare_df)
group1 group2
count 100.00 100.00
mean 175.10 174.41 <--
std 5.39 5.78
min 163.07 159.28
25% 171.32 170.17
50% 175.22 174.86
75% 178.32 177.85
max 189.78 191.32
.sample().describe()
Python으로 배우는 실험 설계