데이터 처리 도구/Python
[Python] 데이터프레임 생략없이 출력하기 (디스플레이 옵션 수정)
yourhm
2025. 3. 9. 18:11
행(로우), 열(컬럼) 생략없이 출력하기
# row 생략 없이 출력
pd.set_option('display.max_rows', None) # 모두 출력
pd.set_option('display.max_rows', 10) # 10개만 출력
# col 생략 없이 출력
pd.set_option('display.max_columns', None) # 모두 출력
pd.set_option('display.max_columns', 10) # 10개만 출력
데이터 값(셀) 생략없이 출력하기
pd.set_option('display.max_colwidth', None) # 모두 출력
pd.set_option('display.max_colwidth', 50) # 문자열의 길이가 50일때 자른다
pandas를 사용할 때 데이터 값(셀)의 내용이 길면 잘려서(truncated) 출력되는 것이 디폴트 옵션임.
설정했던 옵션 값 초기화
reset_option
: set_option으로 설정한 디스플레이 옵션을 디폴트값으로 되돌릴 때 사용.
pd.reset_option('display.max_rows')
pd.reset_option('display.max_columns')
pd.reset_option('display.max_colwidth')
위의 세 줄을 한 번에 처리하려면? 'all' 을 입력하여 모든 디스플레이 옵션 초기화 가능.
pd.reset_option('all')