HISI
HISI

Reputation: 4797

run multi command in the same jupyter cells

I'm trying to display 2 output of 2 lines in the same time, I use Panda library and it seems like it display only the output of second line:

import pandas as pd
data = {"state": ["Ohio", "Ohio", "Ohio", "Nevada", "Nevada"],
     "year": [2000, 2001, 2002, 2001, 2002],
     "pop": [1.5, 1.7, 3.6, 2.4, 2.9]}

frame = pd.DataFrame(data)

this is My cell:

frame.state
frame.year

and this is the outputs:

enter image description here

Upvotes: 6

Views: 4601

Answers (2)

VrushM
VrushM

Reputation: 21

If you want to provide two outputs at the same time you can try doing it this way. type this on your jupyter notebook cell,

frame.state , frame.year

Just insert a comma in between it will print Output for both the statements.

Upvotes: 1

Oriol Mirosa
Oriol Mirosa

Reputation: 2826

You can run a cell with this at the beginning of the notebook:

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

This will run all the expressions in each cell. If you want to return to the default behavior, you can write:

InteractiveShell.ast_node_interactivity = "last_expr"

Upvotes: 9

Related Questions