【问题标题】:calculate how much percentage of the data is between two given points? [duplicate]计算两个给定点之间的数据百分比是多少? [复制]
【发布时间】:2021-10-15 21:55:36
【问题描述】:

我喜欢计算两个给定点之间的数据百分比?

假设我有一个浮点数组:

a = np.arange(1, 2, 0.1)
a
>>> array([1.0 , 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9])

我想知道上述数组中 1.2 到 1.7 之间的数据百分比
还有
1.2 在给定数组中的百分比是多少。

诸如分位数(25%、50%、75%)之类的东西。

【问题讨论】:

  • (a[(a>1.2)&(a
  • 感谢您的公式。无法从谷歌获得这个公式。

标签: python pandas numpy quantile percentile


【解决方案1】:

很简单:

# percentage between 1.2 and 1.7:
np.mean((a>1.2) & (a<1.7)) * 100

# percentile of 1.2:
np.mean(a<1.2) * 100

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-11
    • 2016-02-27
    • 1970-01-01
    • 1970-01-01
    • 2011-08-13
    • 1970-01-01
    • 2013-07-25
    • 1970-01-01
    相关资源
    最近更新 更多