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 Pandas DataFrame
. When the DataFrame
is five columns (labels) wide, I get the descriptive statistics that I want. However, if the DataFrame
has any more columns, the statistics are suppressed and something like this is returned:
>> Index: 8 entries, count to max
>> Data columns:
>> x1 8 non-null values
>> x2 8 non-null values
>> x3 8 non-null values
>> x4 8 non-null values
>> x5 8 non-null values
>> x6 8 non-null values
>> x7 8 non-null values
The "8" value is given whether there are 6 or 7 columns. What does the "8" refer to?
I have already tried dragging the IDLE window larger, as well as increasing the "Configure IDLE" width options, to no avail.
Best Answer
Update: Pandas 0.23.4 onwards
This is not necessary. Pandas autodetects the size of your terminal window if you set
pd.options.display.width = 0
. (For older versions see at bottom.)pandas.set_printoptions(...)
is deprecated. Instead, usepandas.set_option(optname, val)
, or equivalentlypd.options.<opt.hierarchical.name> = val
. Like:Here is the help for
set_option
:Older version information. Much of this has been deprecated.
As @bmu mentioned, Pandas auto detects (by default) the size of the display area, a summary view will be used when an object repr does not fit on the display. You mentioned resizing the IDLE window, to no effect. If you do
print df.describe().to_string()
does it fit on the IDLE window?The terminal size is determined by
pandas.util.terminal.get_terminal_size()
(deprecated and removed), this returns a tuple containing the(width, height)
of the display. Does the output match the size of your IDLE window? There might be an issue (there was one before when running a terminal in Emacs).Note that it is possible to bypass the autodetect,
pandas.set_printoptions(max_rows=200, max_columns=10)
will never switch to summary view if number of rows, columns does not exceed the given limits.The 'max_colwidth' option helps in seeing untruncated form of each column.