当 lacs 中有数据时,如何从 dataFrame 中删除特定变量(col)的异常值

发布于 2025-01-10 02:05:47 字数 238 浏览 4 评论 0原文

plt.xticks(np.arange(0, len(x) + 1)[::365], x[::365])

plt.plot(dates, CentreLiftEffectiveCurrent)

plt.title('CentreLiftEffectiveCurrent')

我的变量 CentreLiftEffectiveCurrent 收到 1e^38 异常值。我怎样才能删除它们并用所需的值再次绘制图表

plt.xticks(np.arange(0, len(x) + 1)[::365], x[::365])

plt.plot(dates, CentreLiftEffectiveCurrent)

plt.title('CentreLiftEffectiveCurrent')

I'm getting 1e^38 abnormal values for my variable CentreLiftEffectiveCurrent. how can i remove them and plot the graph again with the desired values

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖伴 2025-01-17 02:05:47

过滤“异常”值的通常好方法是过滤离群值,即超出数据集中值范围的值:

rainfall = df["Rainfall"]
q3 = np.quantile(rainfall, 0.75)
q1 = np.quantile(rainfall, 0.25)

iqr = q3 - q1

upper_bound = q1 + 1.5 * iqr
lower_bound = q3 - 1.5 * iqr

rainfall_wo_outliers = df[(rainfall >= lower_bound) | (rainfall <= upper_bound)]["Rainfall"]

您可以绘制箱形图来查看这些离群值:

df.boxplot()

在此处输入图像描述

ps:抱歉,草图中这是 q3 而不是 q2

你可以在这里看到也有关于此的讨论

A usually good way to filter "abnormal" values is to filter the outliers, i.e. values that are outside a range around the median values fo your dataset:

rainfall = df["Rainfall"]
q3 = np.quantile(rainfall, 0.75)
q1 = np.quantile(rainfall, 0.25)

iqr = q3 - q1

upper_bound = q1 + 1.5 * iqr
lower_bound = q3 - 1.5 * iqr

rainfall_wo_outliers = df[(rainfall >= lower_bound) | (rainfall <= upper_bound)]["Rainfall"]

you can plot a box plot to see these outliers:

df.boxplot()

enter image description here

ps: sorry this is q3 and not q2 on the sketch

you can see here also a discussion about this

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文