티스토리 뷰

반응형

Stack Overflow에 자주 검색, 등록되는 문제들과 제가 개발 중 찾아 본 문제들 중에서 나중에도 찾아 볼 것 같은 문제들을 정리하고 있습니다.

Stack Overflow에서 가장 먼저 확인하게 되는 가장 높은 점수를 받은 Solution과 현 시점에 도움이 될 수 있는 가장 최근에 업데이트(최소 점수 확보)된 Solution을 각각 정리하였습니다.

 

아래 word cloud를 통해 이번 포스팅의 주요 키워드를 미리 확인하세요.

Pretty-print an entire Pandas Series / DataFrame

전체 Pands 시리즈/데이터 프레임 이쁘게 인쇄하기

 문제 내용 

I work with Series and DataFrames on the terminal a lot. The default __repr__ for a Series returns a reduced sample, with some head and tail values, but the rest missing.

저는 터미널에서 Series와 DataFrames를 많이 사용합니다. 시리즈의 기본 __repr__은 헤드 및 테일 값이 일부 있지만 나머지는 누락된 축소된 샘플을 반환합니다.

 

Is there a builtin way to pretty-print the entire Series / DataFrame? Ideally, it would support proper alignment, perhaps borders between columns, and maybe even color-coding for the different columns.

전체 Series/DataFrame을 예쁘게 인쇄하는 기본 방법이 있습니까? 이상적으로는 적절한 정렬, 아마도 열 사이의 경계, 다른 열에 대한 색상 코딩을 지원하면 좋을 것 같습니다.

 

 

 

 높은 점수를 받은 Solution 

You can also use the option_context, with one or more options:

option_context를 하나 이상의 옵션과 함께 사용할 수도 있습니다.
with pd.option_context('display.max_rows', None, 'display.max_columns', None):  # more options can be specified also
    print(df)

 

This will automatically return the options to their previous values.

그러면 옵션이 이전 값으로 자동으로 돌아갑니다.

 

If you are working on jupyter-notebook, using display(df) instead of print(df) will use jupyter rich display logic (like so).

jupyter-notebook에서 작업하는 경우 print(df) 대신 display(df)를 사용하면 jupyter의 풍부한 디스플레이 로직이 사용됩니다.

 

 

 

 가장 최근 달린 Solution 

this link can help ypu

이 링크는 당신을 도울 수 있습니다.

 

hi my friend just run this

안녕 내 친구 그냥 이것을 실행해.
    pd.set_option("display.max_rows", None, "display.max_columns", None)
    print(df)

 

just do this

그냥 이렇게 해.

 

Output

출력
Column
0    row 0
1    row 1
2    row 2
3    row 3
4    row 4
5    row 5
6    row 6
7    row 7
8    row 8
9    row 9
10  row 10
11  row 11
12  row 12
13  row 13
14  row 14
15  row 15
16  row 16
17  row 17
18  row 18
19  row 19
20  row 20
21  row 21
22  row 22
23  row 23
24  row 24
25  row 25
26  row 26
27  row 27
28  row 28
29  row 29
30  row 30
31  row 31
32  row 32
33  row 33
34  row 34
35  row 35
36  row 36
37  row 37
38  row 38
39  row 39
40  row 40
41  row 41
42  row 42
43  row 43
44  row 44
45  row 45
46  row 46
47  row 47
48  row 48
49  row 49
50  row 50
51  row 51
52  row 52
53  row 53
54  row 54
55  row 55
56  row 56
57  row 57
58  row 58
59  row 59
60  row 60
61  row 61
62  row 62
63  row 63
64  row 64
65  row 65
66  row 66
67  row 67
68  row 68
69  row 69

 

 

출처 : https://stackoverflow.com/questions/19124601/pretty-print-an-entire-pandas-series-dataframe

반응형
댓글
공지사항
최근에 올라온 글