What is the difference between pandas agg and apply function?

前端 未结 4 1201
闹比i
闹比i 2020-11-29 03:55

I can\'t figure out the difference between Pandas .aggregate and .apply functions.
Take the following as an example: I load a dataset, do a

4条回答
  •  醉酒成梦
    2020-11-29 04:39

    When using apply to a groupby I have encountered that .apply will return the grouped columns. There is a note in the documentation (pandas.pydata.org/pandas-docs/stable/groupby.html):

    "...Thus the grouped columns(s) may be included in the output as well as set the indices."

    .aggregate will not return the grouped columns.

提交回复
热议问题