search

Home  >  Q&A  >  body text

python - groupby(level=0)是什么意思?

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中文网2802 days ago3433

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 10:34:13

    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...

    reply
    0
  • Cancelreply