keep-loving-pythonのブログ

Pythonを愛し続けたいです(Pythonが流行っている限りですが。。。)

Pandas。表示を省略しない方法。そうじゃなくて、max_colwidthです。

何? Pandas。表示を省略しない方法。でぐぐると、、、

display.max_columns
display.max_rows
とかでるのでは?

そうじゃなくて、max_colwidth

たとえば、↓みたいなcsvがあるとして、

Lineid   Label   Month   Date    Time    Level   Component   PID Content EventId
0   -   Jan 5   12:30:40    5   httpd   2345    get_url "asahi.com"
1   ng  Jan 5   12:30:41    5   httpd   2345    get_url asahi.com
2   -   Jan 5   12:30:42    5   httpd   2345    post_data   today,it is fine.fine.fine.Very fine.I fine thank you.today,it is fine.fine.fine.Very fine.I fine thank you.The end.
3   ng  Jan 5   12:30:43    5   wtdd    23  get_url asahi.com
4   -   Jan 5   12:31:40    5   httpd   2345    get_url asahi.com
5   -   Jan 5   12:32:40    5   httpd   2345    get_url asahi.com
6   -   Jan 5   12:33:40    5   httpd   2345    post_data   today,it is fine.fine.fine.very fine.
7   ng  Jan 5   12:34:41    5   httpd   2345    get_url asahi.com

これを表示させようとしたら、

import pandas as pd

df = pd.read_csv('test00.csv',delimiter="\t")

pd.set_option('display.max_columns', 1500)
pd.set_option('display.max_rows', 150)
pd.set_option('', 150)
pd.set_option("display.width", 1000)
pd.set_option("display.max_colwidth", 1000)


print(df.head(5))

参考にしたサイト

note.nkmk.me

コメント

max_colwidth です。