如何绘制来自不同数据框的箱线图 2 数据 - Python

How to plot on box plot 2 data from different data frama - Python

我遇到了将 2 个箱线图绘制到同一张图中以便于比较它们的问题。 问题是每个箱形图都来自不同长度的不同数据框,但是,它们都有相同的列。

我的两个数据框是: 'headlamp_water' 和 'headlamp_crack';我要使用的列称为 'Use Period'。 我该怎么做? 任何帮助将不胜感激

你可以concat() the columns and call the boxplot()方法。

pd.concat([headlamp_water['Use Period'], headlamp_crack['Use Period']], axis=1).boxplot()

使用 axis=1,你 select 列。