▶ 사용목적
- 데이터 전처리 시에 .
head() 나 .shape 과 같은 함수를 사용해 데이터의 구조나 형태를 살펴보고 분석을 진행하는 경우가 많은데 열(column) 의 값이 너무 많을 경우에는 중간에 열의 이름이 생략되서 출력되는 경우가 많다. 이럴 때 df.columns() 함수를 사용하면 된다.
df.columns
df.columns는 판다스(pandas) 라이브러리에서 DataFrame 객체의 전체 열 이름을 가져오거나 설정할 때 사용하는 속성이다. 이를 통해 DataFrame의 열 이름을 확인하거나 새로운 열 이름으로 변경하는 것이 가능하다.
▶ 결과
Index(['gameId', 'creationTime', 'gameDuration', 'seasonId', 'winner',
'firstBlood', 'firstTower', 'firstInhibitor', 'firstBaron',
'firstDragon', 'firstRiftHerald', 't1_champ1id', 't1_champ1_sum1',
't1_champ1_sum2', 't1_champ2id', 't1_champ2_sum1', 't1_champ2_sum2',
't1_champ3id', 't1_champ3_sum1', 't1_champ3_sum2', 't1_champ4id',
't1_champ4_sum1', 't1_champ4_sum2', 't1_champ5id', 't1_champ5_sum1',
't1_champ5_sum2', 't1_towerKills', 't1_inhibitorKills', 't1_baronKills',
't1_dragonKills', 't1_riftHeraldKills', 't1_ban1', 't1_ban2', 't1_ban3',
't1_ban4', 't1_ban5', 't2_champ1id', 't2_champ1_sum1', 't2_champ1_sum2',
't2_champ2id', 't2_champ2_sum1', 't2_champ2_sum2', 't2_champ3id',
't2_champ3_sum1', 't2_champ3_sum2', 't2_champ4id', 't2_champ4_sum1',
't2_champ4_sum2', 't2_champ5id', 't2_champ5_sum1', 't2_champ5_sum2',
't2_towerKills', 't2_inhibitorKills', 't2_baronKills', 't2_dragonKills',
't2_riftHeraldKills', 't2_ban1', 't2_ban2', 't2_ban3', 't2_ban4',
't2_ban5'],
dtype='object')