3

We all love using pandas and how the dataframe shows us a snippet of the data. However within the ipython notebook, sometimes it is difficult to view all the data especially if it contains too many columns.

Was just wondering if there is an option to view the dataframe in a new window like Matplotlib when it renders its graph.

BernardL
  • 5,162
  • 7
  • 28
  • 47

1 Answers1

4

You can create a temporary file containing HTML of the whole table, and then use the webbrowser module to open in. It would probably be best to simply create a function for displaying data frames in a new window:

import webbrowser
import pandas as pd
from tempfile import NamedTemporaryFile

def df_window(df):
    with NamedTemporaryFile(delete=False, suffix='.html') as f:
        df.to_html(f)
    webbrowser.open(f.name)

df = pd.DataFrame({'a': [10, 10, 10, 11], 'b': [8, 8 ,8, 9]})
df_window(df)

enter image description here

Edit: In my answer here I show how to display a table in a new window with pagination, search, sort and other cool stuff using JQuery+DataTables.

Shovalt
  • 6,407
  • 2
  • 36
  • 51