首页 > 解决方案 > 数据框显示每天的箱线图

问题描述

我有一个 DataFrmae(choosen_merged):

在此处输入图像描述

        ax = choosen_merged.boxplot()
        ax.set_title("Boxplot"+" Sensor: "+f"{pick_column}"+" "+f"{df_date}")
        #ax.set_xlabel("x_label")
        ax.set_ylabel(f"{a_string}")
        plt.show()

输出:

在此处输入图像描述

目标: 我想从我的 df 中获取每天的箱线图。

解决方法:

找到了类似的方法,但不幸的是,它并不能帮助我在 pandas 中进一步的时间序列箱线图

最后一个答案也适用于时间戳,但在索引中。如何将其应用于列?

标签: pandasdataframegroup-byboxplot

解决方案


一个应该适用于这个特定问题的例子:

# Setting up our x-axis, the longtime column has to be of dtype 'datetime'
choosen_merged['days'] = choosen_merged.longtime.dt.day
# Using sb.boxplot, you can also use matplotlib.pyplot.boxplot
import seaborn as sb
sb.boxplot(data=choosen_merged, x='days', y='temperature_ers_lite_1_wermser_0_elsys_0')

推荐阅读