简体   繁体   中英

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.

在此处输入图像描述

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?

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.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM