notebooks.py 文件源码

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

项目:fireant 作者: kayak 项目源码 文件源码
def _set_display_options(self, dataframe, display_schema):
        """
        Replaces the dimension options with those that the user has specified manually e.g. change 'm' to 'mobile'
        """
        dataframe = dataframe.copy()

        for key, dimension in display_schema['dimensions'].items():
            if 'display_options' in dimension:
                display_values = [dimension['display_options'].get(value, value)
                                  for value in dataframe.index.get_level_values(key).unique()]

                if not display_values:
                    continue

                if isinstance(dataframe.index, pd.MultiIndex):
                    dataframe.index.set_levels(display_values, key, inplace=True)

                else:
                    dataframe.index = pd.Index(display_values)

        return dataframe
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号