画面の表示設定
Jupyter Notebookの画面の幅を変更することができます。
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:90% !important; }</style>"))Pandasの表示設定
取得
# 行数
print(pd.get_option("display.max_rows"))
# 列数
print(pd.get_option("display.max_columns"))変更
# 行数
pd.set_option('display.max_rows', 100)
print(pd.get_option("display.max_rows"))
# 100
# 列数
pd.set_option('display.max_columns', 50)
print(pd.get_option("display.max_columns"))
# 50上記で駄目な場合は以下です。print時の幅を制御するようです。
pd.set_option('display.width', 100)処理速度の計測
%%time
Wall timeが処理速度のようです。
%%time
sum = 0
for n in range(100000):
sum += n
print(sum)
# 4999950000
# CPU times: user 15.6 ms, sys: 481 µs, total: 16 ms
# Wall time: 16 ms%%timeit
なぜかprintを入れるとたくさん表示(出力)されます。
処理を何度か自動的に実行して、時間を計測しているようです。
以下の例では、7回の実行の平均±標準偏差ということになります。しかしprintはもっと実行されています。
ですので、処理が遅いようです。こちらの方が正確かもしれませんが。
%%timeit
sum = 0
for n in range(100000):
sum += n
print(sum)
# 4999950000
# 4999950000
# 4999950000
# ・・・
# 7.57 ms ± 241 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
