我有一个1000 * 8的数据集,每列代表不同时间股票的价格,因此有8只股票。我想为所有股票绘制8个箱图,以检查python循环中的极值。你能告诉我怎么做吗?
作为直接使用matplotlib的快速替代方案,Pandas具有可以使用的合理的boxplot函数。
df = pd.DataFrame(np.random.randn(1000, 8), columns=list('ABCDEFGH')) df.boxplot(column = list(df.columns))
编辑:只是意识到你的问题要求循环执行此操作。
for c in df.columns: fig, ax = plt.subplots() ax = df.boxplot(column = c)