gpt4 book ai didi

python:有频率函数吗?

转载 作者:太空宇宙 更新时间:2023-11-04 07:12:40 24 4
gpt4 key购买 nike

在excel中有一个频率函数:

The Excel FREQUENCY function This useful function can analyse a series of values and summarise them into a number of specified ranges. For example the heights of some children can be grouped in to four categories of [Less than 150cm]; [151 - 160cm]; [161 - 170cm]; [More than 170cm].

Would you like to learn more?

Excel 2003 Formulas by John Walkenbach (with CD)

FREQUENCY() is an unusual array function and it works differently to most other normal functions. It can not simply be typed into a cell or even entered properly using the Excel Function Wizard.

Note that this function does not analyse values into categories e.g. household expenditure into groups such as gas, electricity, water, rates etc. To perform this kind of analysis an Advanced Filter may be appropriate.

The frequency function has two arguments - the first is the range of cells containing values to be analysed; the second is the range of cells containing the upper values of each group banding. e.g. =FREQUENCY(A3:A120, B6:B10)

The second argument (the group upper limits) will exclude any values which exceed the highest category or banding. The function allows you to take account of this and extend the range of analysis to an additional category which contains all values that exceed the specified upper limit.

http://www.meadinkent.co.uk/xlfreq.htm

python有这种东西吗?

最佳答案

import numpy
numpy.histogram( [ <data> ], [ <bins> ] )

Docs :

numpy.histogram(a, bins=10, range=None, normed=False, weights=None)

Compute the histogram of a set of data. Parameters:

a : array_like Input data. The histogram is computed over the flattened array.

bins : int or sequence of scalars, optional If bins is an int, it defines the number of equal-width bins in the given range (10, by default). If bins is a sequence, it defines the bin edges, including the rightmost edge, allowing for non-uniform bin widths.

range : (float, float), optional The lower and upper range of the bins. If not provided, range is simply (a.min(), a.max()). Values outside the range are ignored.

normed : bool, optional If False, the result will contain the number of samples in each bin. If True, the result is the value of the probability density function at the bin, normalized such that the integral over the range is 1. Note that the sum of the histogram values will not be equal to 1 unless bins of unity width are chosen; it is not a probability mass function.

weights : array_like, optional An array of weights, of the same shape as a. Each value in a only contributes its associated weight towards the bin count (instead of 1). If normed is True, the weights are normalized, so that the integral of the density over the range remains 1

Returns:

hist : array The values of the histogram. See normed and weights for a description of the possible semantics.

bin_edges : array of dtype float Return the bin edges (length(hist)+1).

您可能需要 install numpy首先。

关于python:有频率函数吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3398072/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com