<分区>
在 python 中:
fig1, ax1 = plt.subplots()
ax1.set_title('Basic Plot')
ax1.boxplot(data)
IQR 可以通过以下方式计算:
IQR = stats.iqr(data, interpolation = 'midpoint')
我如何获得每个框印迹的最小值和最大值“The Whiskers”?
标签 python matplotlib
<分区>
在 python 中:
fig1, ax1 = plt.subplots()
ax1.set_title('Basic Plot')
ax1.boxplot(data)
IQR 可以通过以下方式计算:
IQR = stats.iqr(data, interpolation = 'midpoint')
我如何获得每个框印迹的最小值和最大值“The Whiskers”?
最佳答案
Dataframe 具有分位数函数:
Q1 = df["COLUMN_NAME"].quantile(0.25)
Q3 = df["COLUMN_NAME"].quantile(0.75)
IQR = Q3 - Q1
Lower_Fence = Q1 - (1.5 * IQR)
Upper_Fence = Q3 + (1.5 * IQR)
因此您必须获得小于围栏值的第一个值
def iqr_fence(x):
Q1 = x.quantile(0.25)
Q3 = x.quantile(0.75)
IQR = Q3 - Q1
Lower_Fence = Q1 - (1.5 * IQR)
Upper_Fence = Q3 + (1.5 * IQR)
u = max(x[x<Upper_Fence])
l = min(x[x>Lower_Fence])
return [u,l]
关于python - 如何从 python 中的箱线图中获取最小值和最大值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62330801/