3

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.

jtlz2
  • 7,700
  • 9
  • 64
  • 114
  • 1
    use print() function – Deven Ramani Mar 08 '21 at 06:50
  • @DevenRamani How to maintain tabular pretty print? – jtlz2 Mar 08 '21 at 07:25
  • 1
    You may want to take a look at this similar question: https://stackoverflow.com/questions/38783027/jupyter-notebook-display-two-pandas-tables-side-by-side – Kastakin Mar 08 '21 at 08:01
  • 1
    Does this answer your question? [Jupyter notebook display two pandas tables side by side](https://stackoverflow.com/questions/38783027/jupyter-notebook-display-two-pandas-tables-side-by-side) – Kastakin Mar 08 '21 at 08:02
  • 1
    If you need more than one, why don't you combine them with `pd.concat()`, since the output of `describe()` is also a dataframe? – r-beginners Mar 08 '21 at 13:16

1 Answers1

2

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

jtlz2
  • 7,700
  • 9
  • 64
  • 114
Stef
  • 28,728
  • 2
  • 24
  • 52