Is there a way to widen the display of output in either interactive or script-execution mode?
Specifically, I am using the describe()
function on a pand
If you want to set options temporarily to display one large DataFrame, you can use option_context:
with pd.option_context('display.max_rows', None, 'display.max_columns', None):
print (df)
Option values are restored automatically when you exit the with
block.
You can simply do the following steps,
You can change the options for pandas max_columns feature as follows
import pandas as pd
pd.options.display.max_columns = 10
(this allows 10 columns to display, you can change this as you need)
Like that you can change the number of rows as you need to display as follows (if you need to change maximum rows as well)
pd.options.display.max_rows = 999
(this allows to print 999 rows at a time)
Please kindly refer the doc to change different options/settings for pandas
You can use this custom function for displaying things for pandas Dataframe
.
def display_all(df): # for any Dataframe df
with pd.option_context('display.max_rows',1000): # change number of rows accordingly
with pd.option_context('display.max_columns',1000): # change number of columns accordingly
display(df)
display_all(df.head()) # pass this function to your dataframe and Voila!
You don't have use pd.set_option
for whole notebook just use for single cell.
Set column max width using:
pd.set_option('max_colwidth', 800)
This particular statement sets max width to 800px, per column.
If you don't want to mess with your display options and you just want to see this one particular list of columns without expanding out every dataframe you view, you could try:
df.columns.values
You can use print df.describe().to_string()
to force it to show the whole table. (You can use to_string()
like this for any DataFrame. The result of describe
is just a DataFrame itself.)
The 8 is the number of rows in the DataFrame holding the "description" (because describe
computes 8 statistics, min, max, mean, etc.).