[Python(파이썬)] 데이터(DATA) 전처리/Data shape(형태) 확인, Data column(열) 종류 확인 // df.columns

김대현·2024년 6월 19일
0

▶ 사용목적

  • 데이터 전처리 시에 .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')
profile
데이터 분석 스쿨 블로그 입니다.

0개의 댓글