<예시용 표>
german = german_sample[['Type of apartment',
'Sex & Marital Status',
'Credit Amount']]
german.head() # 잘 가져와졌는지 확인
Type of apartment Sex & Marital Status Credit Amount
0 1 2 1049
1 1 3 2799
2 1 2 841
3 1 3 2122
4 2 3 2171
△예시용 표
<for 써서 그룹바이>
for type, g in german.groupby('Type of apartment'):
print(g.head(n=3))
print('--------------------------------------------------------------')
출력>
Type of apartment Sex & Marital Status Credit Amount
0 1 2 1049
1 1 3 2799
2 1 2 841
--------------------------------------------------------------
Type of apartment Sex & Marital Status Credit Amount
4 2 3 2171
6 2 3 3398
7 2 3 1361
--------------------------------------------------------------
Type of apartment Sex & Marital Status Credit Amount
29 3 3 4796
44 3 3 1239
69 3 3 2032
--------------------------------------------------------------