🔥알림🔥
① 테디노트 유튜브 -
구경하러 가기!
② LangChain 한국어 튜토리얼
바로가기 👀
③ 랭체인 노트 무료 전자책(wikidocs)
바로가기 🙌
④ RAG 비법노트 LangChain 강의오픈
바로가기 🙌
⑤ 서울대 PyTorch 딥러닝 강의
바로가기 🙌
Pandas 데이터프레임 출력결과 및 표기옵션 수정(컬럼, 행 최대 출력, 콤마 구분자, 과학표기법)
판다스(Pandas) 데이터프레임(DataFrame)의 출력결과 표기형식을 설정할 수 있는 다양한 옵션들에 대해 알아보겠습니다.
주요 내용
- 최대, 최소 행/열 개수 지정
- 반올림
- 1,000 단위 콤마 구분자
- 특정 값 이하 절삭
import numpy as np
import pandas as pd
# 샘플데이터 생성
df = pd.DataFrame(np.random.randn(100, 30))
df
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | -0.035806 | 0.540773 | 2.048162 | 0.987971 | 1.297979 | -0.975736 | 1.511243 | 0.761065 | 0.466870 | 1.246932 | ... | 0.662477 | -0.597404 | -0.357058 | -0.329638 | 0.070825 | -0.836523 | -0.229360 | 0.335023 | 0.602947 | 0.746151 |
1 | 0.981804 | 0.566098 | -0.670318 | 1.900650 | 1.184195 | 1.185684 | 1.036443 | 0.147689 | 1.261201 | -0.455557 | ... | -0.884224 | -0.363598 | 1.959401 | -1.197709 | -0.630205 | -0.062158 | -1.478759 | 0.188979 | 0.293474 | 2.170450 |
2 | -0.196254 | -0.341994 | 0.568631 | -0.977499 | -1.818653 | -0.756704 | -2.174387 | 0.322598 | 0.692976 | 0.991518 | ... | -1.064358 | -0.005801 | -1.352274 | 1.679056 | -1.716728 | -1.346657 | -0.887417 | 0.698803 | -0.548383 | 0.999490 |
3 | 1.747521 | -0.009455 | 0.029300 | -0.055126 | 1.697121 | -0.043711 | -0.164797 | -1.031167 | -0.521485 | 0.759069 | ... | -0.600646 | -0.027879 | 1.578827 | 0.387868 | -0.949340 | -0.875935 | 0.521120 | -0.175317 | -0.050255 | 1.424726 |
4 | -1.372283 | 0.446507 | 1.324593 | -0.093968 | -1.102458 | 0.658459 | 1.537070 | -2.330284 | -0.427623 | 0.088559 | ... | 2.072393 | -0.685572 | 1.167391 | -0.920462 | -0.378917 | -0.505438 | 1.098358 | 0.462141 | 0.291459 | -1.390486 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
95 | 0.440286 | -1.159524 | 1.399405 | 1.882673 | 0.915369 | -1.743549 | -0.710229 | 1.536277 | 0.844029 | -1.626463 | ... | -0.754897 | -0.342387 | -1.048288 | -0.481786 | 0.548180 | -2.110016 | 1.639998 | 0.937382 | -0.092592 | 0.707600 |
96 | 0.681607 | 0.281317 | -0.389708 | 0.943291 | 1.006331 | 0.432428 | -0.719073 | -1.737020 | -1.418606 | 0.481165 | ... | 1.708825 | 0.563480 | -1.000136 | 0.046754 | 1.107975 | 0.075705 | -1.073683 | 1.184550 | 0.981149 | -0.502977 |
97 | 0.409718 | -0.559125 | -0.622972 | -0.131378 | 0.208289 | 0.887148 | -0.093293 | -0.003069 | -1.861841 | 0.174812 | ... | 0.929058 | -0.929894 | -1.949187 | -0.414730 | -0.123279 | 0.266217 | 1.277206 | -1.391318 | -1.406094 | 1.060128 |
98 | 1.211452 | 0.339517 | -0.288101 | 1.582239 | 0.581834 | -0.536842 | 0.270649 | -0.941815 | 0.752292 | 2.856031 | ... | 0.553618 | -0.464397 | -0.668322 | -0.112496 | 1.534438 | -2.455272 | 0.555450 | -0.268942 | -0.612532 | 0.209424 |
99 | -0.117216 | -0.231614 | 1.728668 | 1.116696 | 0.059390 | -0.921383 | 1.488752 | 0.540287 | -0.369421 | 0.134456 | ... | 0.363531 | -1.614530 | 0.731306 | 0.024341 | -0.897175 | 0.027369 | -0.695695 | -1.064006 | -1.431332 | -0.979335 |
100 rows × 30 columns
행, 열 출력
행(row)
-
display.max_rows
에 최대 출력 행(row) 개수 지정.None
지정시 전체 행 출력. -
display.min_rows
에 최소 출력 행(row) 개수 지정.
# 최대 출력 행 개수 지정
pd.set_option('display.max_rows', 30)
# 최소 출력 행 개수 지정
pd.set_option('display.min_rows', 20)
# 출력결과
df
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | -0.035806 | 0.540773 | 2.048162 | 0.987971 | 1.297979 | -0.975736 | 1.511243 | 0.761065 | 0.466870 | 1.246932 | ... | 0.662477 | -0.597404 | -0.357058 | -0.329638 | 0.070825 | -0.836523 | -0.229360 | 0.335023 | 0.602947 | 0.746151 |
1 | 0.981804 | 0.566098 | -0.670318 | 1.900650 | 1.184195 | 1.185684 | 1.036443 | 0.147689 | 1.261201 | -0.455557 | ... | -0.884224 | -0.363598 | 1.959401 | -1.197709 | -0.630205 | -0.062158 | -1.478759 | 0.188979 | 0.293474 | 2.170450 |
2 | -0.196254 | -0.341994 | 0.568631 | -0.977499 | -1.818653 | -0.756704 | -2.174387 | 0.322598 | 0.692976 | 0.991518 | ... | -1.064358 | -0.005801 | -1.352274 | 1.679056 | -1.716728 | -1.346657 | -0.887417 | 0.698803 | -0.548383 | 0.999490 |
3 | 1.747521 | -0.009455 | 0.029300 | -0.055126 | 1.697121 | -0.043711 | -0.164797 | -1.031167 | -0.521485 | 0.759069 | ... | -0.600646 | -0.027879 | 1.578827 | 0.387868 | -0.949340 | -0.875935 | 0.521120 | -0.175317 | -0.050255 | 1.424726 |
4 | -1.372283 | 0.446507 | 1.324593 | -0.093968 | -1.102458 | 0.658459 | 1.537070 | -2.330284 | -0.427623 | 0.088559 | ... | 2.072393 | -0.685572 | 1.167391 | -0.920462 | -0.378917 | -0.505438 | 1.098358 | 0.462141 | 0.291459 | -1.390486 |
5 | 1.252676 | 0.520109 | -0.086972 | -1.390119 | -1.328195 | 0.159062 | -0.185403 | 1.136238 | -2.323753 | -0.153739 | ... | -0.586609 | -1.454865 | -1.141790 | 0.251067 | -1.650410 | -1.399671 | 0.053298 | 0.184873 | -0.152222 | -0.547457 |
6 | 0.748208 | -0.601630 | 0.370751 | 1.508725 | 1.031906 | 0.684378 | 1.289777 | 0.382114 | 0.462913 | -0.761836 | ... | -0.448044 | -0.361551 | -0.713991 | -0.004631 | -2.384194 | -0.691138 | -1.083416 | 0.315635 | -0.477509 | -0.736364 |
7 | 2.122694 | 1.648141 | -0.551223 | 0.581174 | -0.910993 | 0.090683 | 0.227400 | -0.718582 | 0.515417 | -0.111297 | ... | -0.479713 | 0.303648 | 1.164275 | 0.971229 | -0.160322 | 3.029640 | 1.383594 | -0.509485 | 0.505870 | -1.039575 |
8 | -0.002618 | 0.261833 | -0.573321 | 1.177740 | -1.238453 | 2.439766 | 0.959073 | 1.062197 | 0.217570 | -0.025249 | ... | 0.903160 | -0.538873 | -0.085188 | 0.538790 | 2.007834 | -0.532897 | -1.078179 | -1.165601 | 0.157725 | -2.001069 |
9 | -0.251036 | -1.673364 | 0.373563 | 0.300650 | 0.823024 | 1.314862 | -1.198112 | -0.932139 | 1.025538 | 0.261294 | ... | -0.004391 | -1.502177 | -0.598474 | -0.491475 | -0.253052 | 0.070125 | -1.021431 | 0.673204 | -0.328213 | -0.926225 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
90 | 1.012421 | -0.844343 | 1.624287 | 0.457222 | -0.869078 | 0.633851 | 0.674425 | -1.283140 | 1.510371 | 1.683848 | ... | 1.431287 | 0.423220 | 1.485521 | 0.201107 | -0.472796 | 0.359677 | 0.651251 | -0.258083 | 3.026651 | -0.137928 |
91 | 0.135754 | 0.698098 | 0.547223 | 0.484535 | -0.116011 | -0.769140 | -0.591393 | 0.546883 | -0.508868 | 0.524660 | ... | -0.946001 | 0.971161 | 0.646309 | 0.596603 | 0.862084 | 0.594964 | 0.369562 | 0.393629 | -1.235659 | -1.412415 |
92 | 0.862689 | 0.086395 | 0.942105 | -0.896561 | -0.382631 | -0.540536 | -1.475590 | -1.462621 | 0.553185 | -1.192904 | ... | 3.035245 | 0.346097 | -0.743209 | 1.727618 | -1.552566 | 0.817770 | 0.042594 | 0.644676 | 0.539964 | 0.910347 |
93 | -0.825056 | 0.646993 | 0.311538 | -0.507771 | -0.798882 | 0.716366 | 0.045604 | 0.019914 | 0.122563 | 1.573202 | ... | -0.577820 | -1.616715 | -1.922380 | -0.039266 | 1.651102 | 0.234814 | 0.816973 | 1.180786 | -0.160160 | -0.812621 |
94 | -1.316661 | -0.827844 | 1.541134 | -1.600997 | -1.548939 | 0.423432 | -0.387452 | 0.897517 | -0.082423 | 0.032062 | ... | 0.777377 | 1.288470 | 0.643530 | -0.146580 | 0.340498 | -0.949201 | 0.925776 | -0.154046 | -0.302537 | 0.750083 |
95 | 0.440286 | -1.159524 | 1.399405 | 1.882673 | 0.915369 | -1.743549 | -0.710229 | 1.536277 | 0.844029 | -1.626463 | ... | -0.754897 | -0.342387 | -1.048288 | -0.481786 | 0.548180 | -2.110016 | 1.639998 | 0.937382 | -0.092592 | 0.707600 |
96 | 0.681607 | 0.281317 | -0.389708 | 0.943291 | 1.006331 | 0.432428 | -0.719073 | -1.737020 | -1.418606 | 0.481165 | ... | 1.708825 | 0.563480 | -1.000136 | 0.046754 | 1.107975 | 0.075705 | -1.073683 | 1.184550 | 0.981149 | -0.502977 |
97 | 0.409718 | -0.559125 | -0.622972 | -0.131378 | 0.208289 | 0.887148 | -0.093293 | -0.003069 | -1.861841 | 0.174812 | ... | 0.929058 | -0.929894 | -1.949187 | -0.414730 | -0.123279 | 0.266217 | 1.277206 | -1.391318 | -1.406094 | 1.060128 |
98 | 1.211452 | 0.339517 | -0.288101 | 1.582239 | 0.581834 | -0.536842 | 0.270649 | -0.941815 | 0.752292 | 2.856031 | ... | 0.553618 | -0.464397 | -0.668322 | -0.112496 | 1.534438 | -2.455272 | 0.555450 | -0.268942 | -0.612532 | 0.209424 |
99 | -0.117216 | -0.231614 | 1.728668 | 1.116696 | 0.059390 | -0.921383 | 1.488752 | 0.540287 | -0.369421 | 0.134456 | ... | 0.363531 | -1.614530 | 0.731306 | 0.024341 | -0.897175 | 0.027369 | -0.695695 | -1.064006 | -1.431332 | -0.979335 |
100 rows × 30 columns
설정 초기화
초기 설정 값으로 되돌리기 위해서는 pd.reset_option(옵션명)
을 호출하면 됩니다.
# 원래 설정으로 초기화
pd.reset_option('display.max_rows')
pd.reset_option('display.min_rows')
열(column)
display.max_columns
에 최대 출력 열(column) 개수 지정.None
지정시 전체 출력.
# 최대 출력 컬럼 개수 지정
pd.set_option('display.max_columns', None)
# 출력결과
df
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | -0.035806 | 0.540773 | 2.048162 | 0.987971 | 1.297979 | -0.975736 | 1.511243 | 0.761065 | 0.466870 | 1.246932 | 0.041226 | -0.309691 | 0.358050 | -1.313568 | -0.776349 | 1.710610 | 0.969274 | -1.399644 | 0.395019 | 1.053263 | 0.662477 | -0.597404 | -0.357058 | -0.329638 | 0.070825 | -0.836523 | -0.229360 | 0.335023 | 0.602947 | 0.746151 |
1 | 0.981804 | 0.566098 | -0.670318 | 1.900650 | 1.184195 | 1.185684 | 1.036443 | 0.147689 | 1.261201 | -0.455557 | -0.291492 | -0.497445 | 1.296869 | 1.410124 | -1.920911 | -0.378394 | 1.447838 | -1.454872 | -0.446637 | -1.355824 | -0.884224 | -0.363598 | 1.959401 | -1.197709 | -0.630205 | -0.062158 | -1.478759 | 0.188979 | 0.293474 | 2.170450 |
2 | -0.196254 | -0.341994 | 0.568631 | -0.977499 | -1.818653 | -0.756704 | -2.174387 | 0.322598 | 0.692976 | 0.991518 | -0.117331 | 0.862454 | -1.449798 | 2.176193 | 0.243537 | 0.411133 | 0.533833 | -0.393785 | -0.928627 | -0.393218 | -1.064358 | -0.005801 | -1.352274 | 1.679056 | -1.716728 | -1.346657 | -0.887417 | 0.698803 | -0.548383 | 0.999490 |
3 | 1.747521 | -0.009455 | 0.029300 | -0.055126 | 1.697121 | -0.043711 | -0.164797 | -1.031167 | -0.521485 | 0.759069 | -1.148656 | -0.895544 | 0.784258 | 1.556413 | -1.345823 | -0.353388 | -0.128010 | -0.109613 | 1.234353 | -0.698380 | -0.600646 | -0.027879 | 1.578827 | 0.387868 | -0.949340 | -0.875935 | 0.521120 | -0.175317 | -0.050255 | 1.424726 |
4 | -1.372283 | 0.446507 | 1.324593 | -0.093968 | -1.102458 | 0.658459 | 1.537070 | -2.330284 | -0.427623 | 0.088559 | -0.854313 | -0.665910 | 1.368841 | -0.642099 | 0.934470 | -0.953041 | -0.245948 | -1.082086 | 0.089842 | 1.113693 | 2.072393 | -0.685572 | 1.167391 | -0.920462 | -0.378917 | -0.505438 | 1.098358 | 0.462141 | 0.291459 | -1.390486 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
95 | 0.440286 | -1.159524 | 1.399405 | 1.882673 | 0.915369 | -1.743549 | -0.710229 | 1.536277 | 0.844029 | -1.626463 | -0.460458 | 1.067152 | -1.573902 | -1.210941 | 0.827637 | -1.033014 | -1.972978 | -1.811644 | 1.555603 | 0.277433 | -0.754897 | -0.342387 | -1.048288 | -0.481786 | 0.548180 | -2.110016 | 1.639998 | 0.937382 | -0.092592 | 0.707600 |
96 | 0.681607 | 0.281317 | -0.389708 | 0.943291 | 1.006331 | 0.432428 | -0.719073 | -1.737020 | -1.418606 | 0.481165 | 1.172533 | -0.401827 | -1.951013 | -2.207138 | 2.045194 | 1.839619 | 1.157589 | -0.082741 | 0.060264 | -0.793476 | 1.708825 | 0.563480 | -1.000136 | 0.046754 | 1.107975 | 0.075705 | -1.073683 | 1.184550 | 0.981149 | -0.502977 |
97 | 0.409718 | -0.559125 | -0.622972 | -0.131378 | 0.208289 | 0.887148 | -0.093293 | -0.003069 | -1.861841 | 0.174812 | -0.191320 | 0.039081 | -0.749582 | -0.258455 | 0.070604 | 1.428898 | 0.172877 | 0.368134 | 0.444407 | 0.808398 | 0.929058 | -0.929894 | -1.949187 | -0.414730 | -0.123279 | 0.266217 | 1.277206 | -1.391318 | -1.406094 | 1.060128 |
98 | 1.211452 | 0.339517 | -0.288101 | 1.582239 | 0.581834 | -0.536842 | 0.270649 | -0.941815 | 0.752292 | 2.856031 | -0.075809 | 1.824439 | -0.619107 | 1.148403 | 1.167635 | 0.519472 | 0.271008 | -0.234025 | 0.052374 | -0.534476 | 0.553618 | -0.464397 | -0.668322 | -0.112496 | 1.534438 | -2.455272 | 0.555450 | -0.268942 | -0.612532 | 0.209424 |
99 | -0.117216 | -0.231614 | 1.728668 | 1.116696 | 0.059390 | -0.921383 | 1.488752 | 0.540287 | -0.369421 | 0.134456 | 0.118990 | -0.206389 | -1.544280 | 0.792406 | 0.180844 | -0.548614 | -0.704487 | 1.327546 | -1.553650 | 0.216136 | 0.363531 | -1.614530 | 0.731306 | 0.024341 | -0.897175 | 0.027369 | -0.695695 | -1.064006 | -1.431332 | -0.979335 |
100 rows × 30 columns
# 최대 출력 컬럼 개수 지정
pd.set_option('display.max_columns', 10)
# 출력결과
df
0 | 1 | 2 | 3 | 4 | ... | 25 | 26 | 27 | 28 | 29 | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | -0.035806 | 0.540773 | 2.048162 | 0.987971 | 1.297979 | ... | -0.836523 | -0.229360 | 0.335023 | 0.602947 | 0.746151 |
1 | 0.981804 | 0.566098 | -0.670318 | 1.900650 | 1.184195 | ... | -0.062158 | -1.478759 | 0.188979 | 0.293474 | 2.170450 |
2 | -0.196254 | -0.341994 | 0.568631 | -0.977499 | -1.818653 | ... | -1.346657 | -0.887417 | 0.698803 | -0.548383 | 0.999490 |
3 | 1.747521 | -0.009455 | 0.029300 | -0.055126 | 1.697121 | ... | -0.875935 | 0.521120 | -0.175317 | -0.050255 | 1.424726 |
4 | -1.372283 | 0.446507 | 1.324593 | -0.093968 | -1.102458 | ... | -0.505438 | 1.098358 | 0.462141 | 0.291459 | -1.390486 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
95 | 0.440286 | -1.159524 | 1.399405 | 1.882673 | 0.915369 | ... | -2.110016 | 1.639998 | 0.937382 | -0.092592 | 0.707600 |
96 | 0.681607 | 0.281317 | -0.389708 | 0.943291 | 1.006331 | ... | 0.075705 | -1.073683 | 1.184550 | 0.981149 | -0.502977 |
97 | 0.409718 | -0.559125 | -0.622972 | -0.131378 | 0.208289 | ... | 0.266217 | 1.277206 | -1.391318 | -1.406094 | 1.060128 |
98 | 1.211452 | 0.339517 | -0.288101 | 1.582239 | 0.581834 | ... | -2.455272 | 0.555450 | -0.268942 | -0.612532 | 0.209424 |
99 | -0.117216 | -0.231614 | 1.728668 | 1.116696 | 0.059390 | ... | 0.027369 | -0.695695 | -1.064006 | -1.431332 | -0.979335 |
100 rows × 30 columns
반올림(float_format)
# 소수점 2째자리 이하에서 반올림
pd.set_option('display.float_format', lambda x: f'{x:.2f}')
# 출력결과
df
0 | 1 | 2 | 3 | 4 | ... | 25 | 26 | 27 | 28 | 29 | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | -0.04 | 0.54 | 2.05 | 0.99 | 1.30 | ... | -0.84 | -0.23 | 0.34 | 0.60 | 0.75 |
1 | 0.98 | 0.57 | -0.67 | 1.90 | 1.18 | ... | -0.06 | -1.48 | 0.19 | 0.29 | 2.17 |
2 | -0.20 | -0.34 | 0.57 | -0.98 | -1.82 | ... | -1.35 | -0.89 | 0.70 | -0.55 | 1.00 |
3 | 1.75 | -0.01 | 0.03 | -0.06 | 1.70 | ... | -0.88 | 0.52 | -0.18 | -0.05 | 1.42 |
4 | -1.37 | 0.45 | 1.32 | -0.09 | -1.10 | ... | -0.51 | 1.10 | 0.46 | 0.29 | -1.39 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
95 | 0.44 | -1.16 | 1.40 | 1.88 | 0.92 | ... | -2.11 | 1.64 | 0.94 | -0.09 | 0.71 |
96 | 0.68 | 0.28 | -0.39 | 0.94 | 1.01 | ... | 0.08 | -1.07 | 1.18 | 0.98 | -0.50 |
97 | 0.41 | -0.56 | -0.62 | -0.13 | 0.21 | ... | 0.27 | 1.28 | -1.39 | -1.41 | 1.06 |
98 | 1.21 | 0.34 | -0.29 | 1.58 | 0.58 | ... | -2.46 | 0.56 | -0.27 | -0.61 | 0.21 |
99 | -0.12 | -0.23 | 1.73 | 1.12 | 0.06 | ... | 0.03 | -0.70 | -1.06 | -1.43 | -0.98 |
100 rows × 30 columns
# 설정 초기화
pd.reset_option('display.float_format')
출력 형식에 콤마 구분자(comma separation) 추가
- 금융 데이터 분석 및 보고서 작성에 주로 활용
# 소수점 2째자리 이하에서 반올림
# 1000 자리수마다 , 구분자 추가
pd.set_option('display.float_format', lambda x: f'{x:,.2f}')
# 출력결과
df * 1000000
0 | 1 | 2 | 3 | 4 | ... | 25 | 26 | 27 | 28 | 29 | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | -35,806.46 | 540,772.90 | 2,048,161.99 | 987,971.01 | 1,297,978.51 | ... | -836,522.70 | -229,359.65 | 335,023.45 | 602,947.07 | 746,151.45 |
1 | 981,803.57 | 566,097.83 | -670,318.26 | 1,900,649.55 | 1,184,195.02 | ... | -62,158.31 | -1,478,759.17 | 188,979.42 | 293,474.27 | 2,170,449.66 |
2 | -196,254.37 | -341,994.26 | 568,631.29 | -977,498.95 | -1,818,652.91 | ... | -1,346,656.94 | -887,416.74 | 698,803.28 | -548,383.15 | 999,490.35 |
3 | 1,747,520.77 | -9,455.15 | 29,300.34 | -55,125.88 | 1,697,121.09 | ... | -875,934.87 | 521,120.23 | -175,316.54 | -50,255.35 | 1,424,726.29 |
4 | -1,372,283.03 | 446,506.95 | 1,324,592.72 | -93,967.97 | -1,102,457.96 | ... | -505,438.16 | 1,098,358.06 | 462,141.14 | 291,459.06 | -1,390,485.88 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
95 | 440,286.01 | -1,159,524.49 | 1,399,404.51 | 1,882,672.92 | 915,368.70 | ... | -2,110,016.45 | 1,639,998.04 | 937,382.45 | -92,591.77 | 707,600.31 |
96 | 681,607.33 | 281,317.08 | -389,707.58 | 943,290.59 | 1,006,331.23 | ... | 75,704.64 | -1,073,683.29 | 1,184,549.99 | 981,149.35 | -502,977.15 |
97 | 409,718.35 | -559,125.32 | -622,972.50 | -131,378.25 | 208,288.96 | ... | 266,217.01 | 1,277,206.46 | -1,391,317.87 | -1,406,093.94 | 1,060,128.26 |
98 | 1,211,451.53 | 339,516.75 | -288,100.50 | 1,582,239.23 | 581,833.55 | ... | -2,455,271.54 | 555,450.19 | -268,942.36 | -612,532.22 | 209,423.89 |
99 | -117,216.34 | -231,614.45 | 1,728,667.90 | 1,116,695.97 | 59,390.22 | ... | 27,368.98 | -695,695.09 | -1,064,006.46 | -1,431,331.50 | -979,334.87 |
100 rows × 30 columns
만약 소수점 이하는 절삭하고 싶은 경우
# 소수점은 반올림하여 정수형
# 1000 자리수마다 , 구분자 추가
pd.set_option('display.float_format', lambda x: f'{x:,.0f}')
# 출력결과
df * 1000000
0 | 1 | 2 | 3 | 4 | ... | 25 | 26 | 27 | 28 | 29 | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | -35,806 | 540,773 | 2,048,162 | 987,971 | 1,297,979 | ... | -836,523 | -229,360 | 335,023 | 602,947 | 746,151 |
1 | 981,804 | 566,098 | -670,318 | 1,900,650 | 1,184,195 | ... | -62,158 | -1,478,759 | 188,979 | 293,474 | 2,170,450 |
2 | -196,254 | -341,994 | 568,631 | -977,499 | -1,818,653 | ... | -1,346,657 | -887,417 | 698,803 | -548,383 | 999,490 |
3 | 1,747,521 | -9,455 | 29,300 | -55,126 | 1,697,121 | ... | -875,935 | 521,120 | -175,317 | -50,255 | 1,424,726 |
4 | -1,372,283 | 446,507 | 1,324,593 | -93,968 | -1,102,458 | ... | -505,438 | 1,098,358 | 462,141 | 291,459 | -1,390,486 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
95 | 440,286 | -1,159,524 | 1,399,405 | 1,882,673 | 915,369 | ... | -2,110,016 | 1,639,998 | 937,382 | -92,592 | 707,600 |
96 | 681,607 | 281,317 | -389,708 | 943,291 | 1,006,331 | ... | 75,705 | -1,073,683 | 1,184,550 | 981,149 | -502,977 |
97 | 409,718 | -559,125 | -622,972 | -131,378 | 208,289 | ... | 266,217 | 1,277,206 | -1,391,318 | -1,406,094 | 1,060,128 |
98 | 1,211,452 | 339,517 | -288,101 | 1,582,239 | 581,834 | ... | -2,455,272 | 555,450 | -268,942 | -612,532 | 209,424 |
99 | -117,216 | -231,614 | 1,728,668 | 1,116,696 | 59,390 | ... | 27,369 | -695,695 | -1,064,006 | -1,431,332 | -979,335 |
100 rows × 30 columns
# 설정 초기화
pd.reset_option('display.float_format')
과학 표기법(scientific notation) 자릿수 변환
# 소수3째자리 이하는 과학표기법으로 표현
pd.set_option('display.precision', 3)
소수 3째자리 이하는 과학표기법(scientific notation) 으로 변환됨을 확인할 수 있습니다.
df / 1000
0 | 1 | 2 | 3 | 4 | ... | 25 | 26 | 27 | 28 | 29 | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | -3.581e-05 | 5.408e-04 | 2.048e-03 | 9.880e-04 | 1.298e-03 | ... | -8.365e-04 | -2.294e-04 | 3.350e-04 | 6.029e-04 | 7.462e-04 |
1 | 9.818e-04 | 5.661e-04 | -6.703e-04 | 1.901e-03 | 1.184e-03 | ... | -6.216e-05 | -1.479e-03 | 1.890e-04 | 2.935e-04 | 2.170e-03 |
2 | -1.963e-04 | -3.420e-04 | 5.686e-04 | -9.775e-04 | -1.819e-03 | ... | -1.347e-03 | -8.874e-04 | 6.988e-04 | -5.484e-04 | 9.995e-04 |
3 | 1.748e-03 | -9.455e-06 | 2.930e-05 | -5.513e-05 | 1.697e-03 | ... | -8.759e-04 | 5.211e-04 | -1.753e-04 | -5.026e-05 | 1.425e-03 |
4 | -1.372e-03 | 4.465e-04 | 1.325e-03 | -9.397e-05 | -1.102e-03 | ... | -5.054e-04 | 1.098e-03 | 4.621e-04 | 2.915e-04 | -1.390e-03 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
95 | 4.403e-04 | -1.160e-03 | 1.399e-03 | 1.883e-03 | 9.154e-04 | ... | -2.110e-03 | 1.640e-03 | 9.374e-04 | -9.259e-05 | 7.076e-04 |
96 | 6.816e-04 | 2.813e-04 | -3.897e-04 | 9.433e-04 | 1.006e-03 | ... | 7.570e-05 | -1.074e-03 | 1.185e-03 | 9.811e-04 | -5.030e-04 |
97 | 4.097e-04 | -5.591e-04 | -6.230e-04 | -1.314e-04 | 2.083e-04 | ... | 2.662e-04 | 1.277e-03 | -1.391e-03 | -1.406e-03 | 1.060e-03 |
98 | 1.211e-03 | 3.395e-04 | -2.881e-04 | 1.582e-03 | 5.818e-04 | ... | -2.455e-03 | 5.555e-04 | -2.689e-04 | -6.125e-04 | 2.094e-04 |
99 | -1.172e-04 | -2.316e-04 | 1.729e-03 | 1.117e-03 | 5.939e-05 | ... | 2.737e-05 | -6.957e-04 | -1.064e-03 | -1.431e-03 | -9.793e-04 |
100 rows × 30 columns
# 설정 초기화
pd.reset_option('display.precision')
특정 값이하 절삭(chop_threshold)
# 값이 1보다 작으면 0으로 절삭
pd.set_option('display.chop_threshold', 1)
# 출력결과
df
0 | 1 | 2 | 3 | 4 | ... | 25 | 26 | 27 | 28 | 29 | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0.000000 | 0.000000 | 2.048162 | 0.000000 | 1.297979 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
1 | 0.000000 | 0.000000 | 0.000000 | 1.900650 | 1.184195 | ... | 0.000000 | -1.478759 | 0.000000 | 0.000000 | 2.170450 |
2 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | -1.818653 | ... | -1.346657 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
3 | 1.747521 | 0.000000 | 0.000000 | 0.000000 | 1.697121 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 1.424726 |
4 | -1.372283 | 0.000000 | 1.324593 | 0.000000 | -1.102458 | ... | 0.000000 | 1.098358 | 0.000000 | 0.000000 | -1.390486 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
95 | 0.000000 | -1.159524 | 1.399405 | 1.882673 | 0.000000 | ... | -2.110016 | 1.639998 | 0.000000 | 0.000000 | 0.000000 |
96 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 1.006331 | ... | 0.000000 | -1.073683 | 1.184550 | 0.000000 | 0.000000 |
97 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | ... | 0.000000 | 1.277206 | -1.391318 | -1.406094 | 1.060128 |
98 | 1.211452 | 0.000000 | 0.000000 | 1.582239 | 0.000000 | ... | -2.455272 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
99 | 0.000000 | 0.000000 | 1.728668 | 1.116696 | 0.000000 | ... | 0.000000 | 0.000000 | -1.064006 | -1.431332 | 0.000000 |
100 rows × 30 columns
댓글남기기