python - groupby(level=0)是什么意思?
PHP中文网
PHP中文网 2017-04-18 10:32:13
0
1
3405
def _valid_price(g):
    return (((g.max() - g.min()) / g.min()) < 0.223).all()

# 按照日期分组
days = raw.groupby(level=0).agg(
    {'opening_price': lambda g: _valid_price(g) and g[0] or 0,
     'ceiling_price': lambda g: _valid_price(g) and np.max(g) or 0,
     'floor_price': lambda g: _valid_price(g) and np.min(g) or 0,
     'closing_price': lambda g: _valid_price(g) and g[-1] or 0,
     'volume': 'sum',
     'amount': 'sum'})
days.head()

能不能帮忙解读一下

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
洪涛

Conclusion: When the grouping objects (indexes) are repeated [that is, the dates may be repeated], then level = 0 the indexes are the same and separated

When level is greater than or equal to 1. The dimension of the object is greater than or equal to 3 (dimensions)
Example:

It is recommended to take a look at the documentation: http://pandas.pydata.org/pand...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template