pythonpandasjupyterjupyter-lab

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.


Solution

  • 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