Python 코딩 Master Course - Advance 26강 질문

 

 

  • 과정명: Python 코딩 Master Course - Advance 26강
  • 강사명: 신동욱 강사

for sex_group in grouped:
print('the type is: {}\n'.format(type(sex_group)))
print('the length is: {}\n'.format(len(sex_group))) # 남,녀 2개

first_element=sex_group[0] # Male

print('the first element is: {}\n'.format(first_element))
print('it has a type of: {}\n'.format(type(sex_group[0])))

second_element=sex_group[1] # Female

print('the second element is: {}\n'.format(second_element))
print('it has a type of: {}\n'.format(type(second_element)))

print('what we have:')
print(sex_group)

break

강의중에 이 코딩에서 second_element인 Female 데이터가 출력이

안되고 Male만 출력이 되는 결과인데도 그냥 넘어가시길래

궁금해서 질문드립니다

 

the type is: <class 'tuple'>

the length is: 2

the first element is: Male

it has a type of: <class 'str'>

the second element is:      total_bill   tip   sex smoker   day    time  size
24        19.82  3.18  Male     No   Sat  Dinner     2
6          8.77  2.00  Male     No   Sun  Dinner     2
153       24.55  2.00  Male     No   Sun  Dinner     4
211       25.89  5.16  Male    Yes   Sat  Dinner     4
176       17.89  2.00  Male    Yes   Sun  Dinner     2
192       28.44  2.56  Male    Yes  Thur   Lunch     2
9         14.78  3.23  Male     No   Sun  Dinner     2

it has a type of: <class 'pandas.core.frame.DataFrame'>

what we have:
('Male',      total_bill   tip   sex smoker   day    time  size
24        19.82  3.18  Male     No   Sat  Dinner     2
6          8.77  2.00  Male     No   Sun  Dinner     2
153       24.55  2.00  Male     No   Sun  Dinner     4
211       25.89  5.16  Male    Yes   Sat  Dinner     4
176       17.89  2.00  Male    Yes   Sun  Dinner     2
192       28.44  2.56  Male    Yes  Thur   Lunch     2
9         14.78  3.23  Male     No   Sun  Dinner     2)

 여기 보면 

the first element is: Male

it has a type of: <class 'str'> 처럼

Female도 

the first element is: Female

it has a type of: <class 'str'> 이 나와야하는데 

전체 Male 데이터가 나와버립니다

0

댓글

댓글 0개

댓글을 남기려면 로그인하세요.

 

원하는 것을 찾지 못하셨나요?

질문하기