【问题标题】:jupyter print plot and dataframe in order, for loopjupyter 按顺序打印绘图和数据框,for循环
【发布时间】:2021-05-26 22:18:38
【问题描述】:

我想按照 jupyter notebook 中代码的顺序打印数据框和绘图:

  • df
  • 情节
  • df
  • 情节

目前,它们被打印为:

  • df
  • df
  • 情节
  • 情节
from IPython.display import display
import matplotlib.pyplot as plt

df = pd.DataFrame({'x': range(5), 'y': range(5)})

for i in range(2):
    display(df)
    display(df.plot())

【问题讨论】:

    标签: python pandas matplotlib jupyter-notebook jupyter-lab


    【解决方案1】:

    绘图后强制plt.show

    for i in range(2):
        display(df)
        df.plot()
        plt.show()
    

    【讨论】:

      猜你喜欢
      • 2021-12-03
      • 2016-06-22
      • 2018-03-15
      • 2021-11-21
      • 1970-01-01
      • 2020-06-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-19
      相关资源
      最近更新 更多