AndreasInfo
AndreasInfo

Reputation: 1227

Order of printing in jupyter notebook

My code is simple as

df['col'].hist(bins = 250)
df['col'].value_counts()

What I don't understand, my output in my Jupyter notebook appears in reverse order.

enter image description here

If I change the order to

df['col'].value_counts()
df['col'].hist(bins = 250)

then just the histogramm appears.

What am I not understanding?

Upvotes: 1

Views: 754

Answers (1)

Shir
Shir

Reputation: 1649

hist() shows a visual figure while value_count() shows textual output. Unless otherwise specified, the visual data loads after textual data in a jupyter cell.

Add plt.show() after hist to refresh your window and show the visual plot before that.

enter image description here

Upvotes: 4

Related Questions