3

I want to have few outputs from one cell. For this I use:

from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"

Code is doing well, but it's giving me some unwanted data.

Out[1]: <Figure size 2500x800 with 0 Axes>
Out[1]: <matplotlib.axes._subplots.AxesSubplot at 0x1a22e8ca50>
Out[1]: Text(0.5, 1.0, 'Przetrwanie, (0 = Zmarli / 1 = Ocaleni)')
Out[1]: [Text(0, 0.5, 'Liczba')]

I can use some flag options like: 'all', 'last', 'last_expr', 'none', 'last_expr_or_assign'

but none of the options solves the problem :/

Any ideas ??

Niwla23
  • 103
  • 14

2 Answers2

0

According to the documentation, "last_expr"` means outputting only the last expression. You can also refer to a nice article from https://towardsdatascience.com for more details.

If option InteractiveShell.ast_node_interactivity = "last_expr" didn't work in your case, please provide more details.

sierxue
  • 43
  • 6
0

If I understand your problem correctly I see two approaches to resolve it:

a) Use InteractiveShell.ast_node_interactivity = 'last_expr' (default) and split your cells so that they always contain the expression to display the value of as the last one. You can combine this approach with display() as shown below.

b) Use InteractiveShell.ast_node_interactivity = 'none' and the display() function to show the values you want to show:

get_ipython().ast_node_interactivity = 'none'
1 + 2
display(1 + 3)
1 + 4
display(1 + 5)
1 + 6

Output:

4
6