HTML DataFrame 출력 조절
HTML DataFrame 출력 조절하기
ipynb 을 이용하여 github blog를 다루고 있기 때문에 html에서 dataframe은 매우 크게 나와 가독성에 문제가 생기므로 해결책을 찾습니다.
테이블 크기 조정
- 데이터 프레임을 출력하는 HTML 테이블의 크기를 조정하여 가독성을 높일 수 있습니다.
- 스크롤바를 추가하는 것보다 더 복잡하지만, 더욱 세밀한 제어가 가능하고 아래는 테이블 크기를 조정하는 예제 코드입니다.
- 단점으로는 출력하기 위한 python 코드가 table 내에서 주석으로 처리되어 출력됩니다.
- 그래도 출력 결과물을 보니 가독성이 훨씬 좋아진 것 같습니다.
- 블로그 만들때 귀찮을 것 같은데 자동으로 md 형태에서 html에 넣을 때 자동으로 고쳐주는 프로그램을 만들어야겠습니다.
<table style="width:50%">
<!-- 데이터 프레임 출력 코드 -->
</table>
<table style="width:50%">
id | Gender | Customer Type | Age | Type of Travel | Class | Flight Distance | Inflight wifi service | Departure/Arrival time convenient | Ease of Online booking | ... | Inflight entertainment | On-board service | Leg room service | Baggage handling | Checkin service | Inflight service | Cleanliness | Departure Delay in Minutes | Arrival Delay in Minutes | satisfaction | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 84455 | Female | disloyal Customer | 23 | Business travel | Eco | 290 | 3 | 4 | 3 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | neutral or dissatisfied |
1 | 90180 | Male | Loyal Customer | 61 | Personal Travel | Eco | 957 | 3 | 5 | 3 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | neutral or dissatisfied |
2 | 33002 | Male | Loyal Customer | 43 | Personal Travel | Eco | 163 | 4 | 5 | 0 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | neutral or dissatisfied |
3 | 124430 | Female | Loyal Customer | 28 | Personal Travel | Eco | 1262 | 2 | 4 | 2 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | neutral or dissatisfied |
4 | 93970 | Female | Loyal Customer | 39 | Business travel | Business | 1218 | 4 | 4 | 4 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | satisfied |
5 rows × 24 columns
</table>
<table style="width:50%">
id | Gender | Customer Type | Age | Type of Travel | Class | Flight Distance | Inflight wifi service | Departure/Arrival time convenient | Ease of Online booking | ... | Inflight entertainment | On-board service | Leg room service | Baggage handling | Checkin service | Inflight service | Cleanliness | Departure Delay in Minutes | Arrival Delay in Minutes | satisfaction | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 84455 | Female | disloyal Customer | 23 | Business travel | Eco | 290 | 3 | 4 | 3 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | neutral or dissatisfied |
1 | 90180 | Male | Loyal Customer | 61 | Personal Travel | Eco | 957 | 3 | 5 | 3 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | neutral or dissatisfied |
2 | 33002 | Male | Loyal Customer | 43 | Personal Travel | Eco | 163 | 4 | 5 | 0 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | neutral or dissatisfied |
3 | 124430 | Female | Loyal Customer | 28 | Personal Travel | Eco | 1262 | 2 | 4 | 2 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | neutral or dissatisfied |
4 | 93970 | Female | Loyal Customer | 39 | Business travel | Business | 1218 | 4 | 4 | 4 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | satisfied |
5 rows × 24 columns
</table>