小编Saj*_*ier的帖子

过滤掉python pandas中两个百分位数之间的数据

我有数据pandas框,我想消除列的极值。例如:我有pandas一个名为 的数据框df,并percentage在其中调用了列。我想根据以下条件过滤掉数据框,根据百分比列中的值消除前 10 个百分点和最后 10 个百分点。

我想将其过滤到第 10 个到第 90 个百分位数。

我想到了以下几点

df[(df.percentage > np.percentile(df.percentage, 10 )) & (df.percentage < np.percentile(df.percentage, 90 ))]
Run Code Online (Sandbox Code Playgroud)

这是正确的方法吗?或者有人可以推荐更快的方法吗?

python numpy pandas

1
推荐指数
1
解决办法
1673
查看次数

标签 统计

numpy ×1

pandas ×1

python ×1