Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure display output in IPython pandas

Tags:

I'm trying to configure my IPython output in my OS X terminal, but it would seem that none of the changes I'm trying to set are taking effect. I'm trying to configure the display settings such that wider outputs like a big DataFrame will output without any truncation or as the summary info.

After importing pandas into my script, I have a few options set where I tried a whole bunch, but any one (or all, for that matter) does not seem to take effect. I'm running the script from IPython using %run. Am I doing something wrong here?

import pandas as pd  pd.set_option('display.expand_max_repr', False) pd.set_option('display.max_columns', 30) pd.set_option('display.width', None) pd.set_option('display.line_width', 200) 

I've looked at some threads on Stack and the pandas FAQ to no avail, even when using these under the display namespace (or without), as I've attempted here.

I understand that there are some ways around this, such as calling to_string() or describe() methods on your output, but these are very manual, and don't always work as intended in some cases, like one where I have calling to_string() on a groupby object yields:

    id       type 106125       puzzle       gameplay_id  sitting_id  user_id           ... 106253       frames       gameplay_id  sitting_id  user_id           ... 106260       trivia       gameplay_id  sitting_id  user_id           ... 

My terminal window size is more than sufficient to accommodate the width, and calling pd.util.terminal.get_terminal_size() is correctly finding the window size tuple, so it would seem that auto detecting the size isn't working either. Any insight would be appreciated!

like image 375
Chrispy Avatar asked Jan 21 '14 04:01

Chrispy


People also ask

How do I show output in Jupyter?

Jupyter Notebook can print the output of each cell just below the cell. When you have a lot of output you can reduce the amount of space it takes up by clicking on the left side panel of the output. This will turn the output into a scrolling window.

How do I display pandas Dataframe in Python?

The simplest and easiest way to display pandas DataFrame in a table style is by using the display() function that imports from the IPython. display module. This function displays the DataFrame in an interactive and well-formatted tabular form.

How do you display a Dataframe in Jupyter?

You can visualize a pandas dataframe in Jupyter notebooks by using the display(<dataframe-name>) function. The display() function is supported only on PySpark kernels. The Qviz framework supports 1000 rows and 100 columns. For example, you have a pandas dataframe df that reads a .


1 Answers

Just for completeness (I'll add my comment as an answer), you missed out:

pd.options.display.max_colwidth  # default is 50 

this restricted the maximum length of a single column.

There are quite a few options to configure here, if you're using ipython then tab complete to find the full set of display options:

pd.options.display.<tab> 
like image 183
Andy Hayden Avatar answered Nov 02 '22 02:11

Andy Hayden