Pandas: 最大行数の設定 質問する

Pandas: 最大行数の設定 質問する

以下の表示に問題がありますDataFrame:

n = 100
foo = DataFrame(index=range(n))
foo['floats'] = np.random.randn(n)
foo

問題は、ipython ノートブックでデフォルトですべての行が印刷されず、結果の行を表示するにはスライスする必要があることです。次のオプションでも出力は変わりません。

pd.set_option('display.max_rows', 500)

配列全体を表示する方法を知っている人はいますか?

ベストアンサー1

セットdisplay.max_rows

pd.set_option('display.max_rows', 500)

pandas の古いバージョン (<=0.11.0) の場合は、display.heightとの両方を変更する必要がありますdisplay.max_rows

pd.set_option('display.height', 500)
pd.set_option('display.max_rows', 500)

参照pd.describe_option('display')

次のように、オプションを 1 回だけ一時的に設定することもできます。

from IPython.display import display
with pd.option_context('display.max_rows', 100, 'display.max_columns', 10):
    display(df) #need display to show the dataframe when using with in jupyter
    #some pandas stuff

次のようにしてオプションをデフォルト値にリセットすることもできます。

pd.reset_option('display.max_rows')

そして、すべてをリセットします。

pd.reset_option('all')

おすすめ記事