Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to preview a part of a large pandas DataFrame, in iPython notebook?

I am just getting started with pandas in the IPython Notebook and encountering the following problem: When a DataFrame read from a CSV file is small, the IPython Notebook displays it in a nice table view. When the DataFrame is large, something like this is ouput:

In [27]:  evaluation = readCSV("evaluation_MO_without_VNS_quality.csv").filter(["solver", "instance", "runtime", "objective"])  In [37]:  evaluation  Out[37]:  <class 'pandas.core.frame.DataFrame'> Int64Index: 333 entries, 0 to 332 Data columns: solver       333  non-null values instance     333  non-null values runtime      333  non-null values objective    333  non-null values dtypes: int64(1), object(3) 

I would like to see a small portion of the data frame as a table just to make sure it is in the right format. What options do I have?

like image 386
clstaudt Avatar asked Feb 21 '13 15:02

clstaudt


People also ask

How do I view full DataFrame in Jupyter notebook?

To show the full data without any hiding, you can use pd. set_option('display. max_rows', 500) and pd. set_option('display.

How do you display the head of a data frame?

DataFrame - head() function This function returns the first n rows for the object based on position. It is useful for quickly testing if your object has the right type of data in it. Number of rows to select. The first n rows of the caller object.


1 Answers

df.head(5) # will print out the first 5 rows df.tail(5) # will print out the 5 last rows 
like image 119
tagoma Avatar answered Sep 26 '22 10:09

tagoma