GAミント至上主義

Web Monomaniacal Developer.

pandasで表示が省略されるのを防ぐ

Google Cloud Datalab localを使って、日次レポートを作っているけど、長いURLや行数が多いとき省略されてしまい困った。

HTML()やdataframeで探しても見当たらなかった。pandasの設定で変えられた。

import pandas as pd

#カラム内の文字数。デフォルトは50だった
pd.set_option("display.max_colwidth", 80)

#行数
pd.set_option("display.max_rows", 101)

他のオプションはdir()などで確認できる

dir(pd.options.display)

['chop_threshold',
 'colheader_justify',
 'column_space',
 'date_dayfirst',
 'date_yearfirst',
 'encoding',
 'expand_frame_repr',
 'float_format',
 'height',
 'large_repr',
 'latex',
 'line_width',
 'max_categories',
 'max_columns',
 'max_colwidth',
 'max_info_columns',
 'max_info_rows',
 'max_rows',
 'max_seq_items',
 'memory_usage',
 'mpl_style',
 'multi_sparse',
 'notebook_repr_html',
 'pprint_nest_depth',
 'precision',
 'show_dimensions',
 'unicode',
 'width']

Pythonによるデータ分析入門 ―NumPy、pandasを使ったデータ処理

Pythonによるデータ分析入門 ―NumPy、pandasを使ったデータ処理