Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I display more than one pandas describe() output in a single jupyter cell?

This is a really basic question but I haven't been able to find an answer:

In Jupyter, if I execute two pandas df.describe() calls in the same cell, only the last one's output is displayed. The same is true for .info(), .head() etc. etc.

How do I persuade Jupyter and pandas to display all N of the above outputs sequentially as intended, with the same tabular formatting that is the default for a single output?

FWIW example code would be:

df1.describe()
#...
df2.describe()
dfN.describe() # Only the result of the final call is displayed

Points from comments addressed:

  1. print(df1.describe()) works, but does not render the table identically to how it is rendered by describe() itself.

  2. Displaying two pandas tables side-by-side (Jupyter notebook display two pandas tables side by side) may work, but doesn't scale to N tables.

like image 267
jtlz2 Avatar asked Sep 18 '25 09:09

jtlz2


2 Answers

You can configure your current session and specify what values to show by InteractiveShell.ast_node_interactivity:

%config InteractiveShell.ast_node_interactivity = 'all'

enter image description here

like image 191
Stef Avatar answered Sep 20 '25 00:09

Stef


Passing dataset with methods you need to display() function worked for me, for example:

display(df.head())
display(df.tail())

like image 44
Vladimir Avatar answered Sep 20 '25 00:09

Vladimir