繁体   English   中英

在 Jupyter 中,您是否在更新时对 pandas 表进行运行更新(隐藏)?

[英]In Jupyter, do you do a running update (hide) a pandas table as you are updating it?

在 Jupyter 中,我正在运行一个长时间运行的计算。

我想展示一个前 25 行的 Pandas 表。 前 25 名可能会在每次迭代中更新。

但是,我不想展示很多Pandas 表。 我想删除/更新现有显示的 Pandas 表。

这怎么可能?

这种方法似乎适用于 matplotlibs,但不适用于 pandas 漂亮的表格。

您可以使用clear_outputdisplay dataframe:

from IPython.display import display, clear_output
# this is just to simulate the delay
import time

i = 1
while i<10:
    time.sleep(1)
    df = pd.DataFrame(np.random.rand(4,3))
    clear_output(wait=True)
    display(df)
    i += 1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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