core.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:weightedcalcs 作者: jsvine 项目源码 文件源码
def groupby_deco(func):
    def func_wrapper(self, thing, *args, **kwargs):
        if isinstance(thing, pd.core.groupby.DataFrameGroupBy):
            agg = thing.apply(lambda x: func(self, x, *args, **kwargs))
            is_series = isinstance(agg, pd.core.series.Series)
            has_multiindex = isinstance(agg.index, pd.MultiIndex)
            if is_series and has_multiindex:
                return agg.unstack()
            else:
                return agg
        return func(self, thing, *args, **kwargs)
    return func_wrapper
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号